Lisp HUG Maillist Archive

initializing packages while running lw from command prompt

how do i run functions from the multiprocessing package from command  
prompt?

if this is the code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load-all-patches)
(defun test-process ()
   (dotimes (x (* 10000 (1+ (random 10))))
     (setq i x))
   (format t "~a" i)
   )
(defun main ()
   (dotimes (x 1000)
     (mp:process-run-function
      "test-process" '() 'test-process)))
(main)
(quit)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

and i compile it, and then run it from command prompt (OS X, lw 4.4.5):

/Applications/LispWorks\ 4.4.5/LispWorks.app/Contents/MacOS/ 
lispworks-4-4-5-darwin -init test.nfasl


it gives me this error:

Error: Cannot create processes before multiprocessing is initialized.



*****************************
this is what is looks like:

/Applications/LispWorks\ 4.4.5/LispWorks.app/Contents/MacOS/ 
lispworks-4-4-5-darwin -multiprocessing -init test.nfasl
LispWorks(R): The Common Lisp Programming Environment
Copyright (C) 1987-2005 LispWorks Ltd.  All rights reserved.
Version 4.4.5
Saved by LispWorks as lispworks-4-4-5-darwin, at 11 Apr 2005 19:58
User danv on vdv.local
; Loading text file /Applications/LispWorks 4.4.5/Library/lib/4-4-0-0/ 
config/siteinit.lisp
;  Loading text file /Applications/LispWorks 4.4.5/Library/lib/ 
4-4-0-0/private-patches/load.lisp
; Loading fasl file /Users/danv/ vdv/lisp/test.nfasl
;  Loading text file /Applications/LispWorks 4.4.5/Library/lib/ 
4-4-0-0/private-patches/load.lisp

Error: Cannot create processes before multiprocessing is initialized.
   1 (continue) Try loading /Users/danv/ vdv/lisp/test.nfasl again.
   2 Give up loading /Users/danv/ vdv/lisp/test.nfasl.
   3 Try loading another file instead of /Users/danv/ vdv/lisp/ 
test.nfasl.
   4 (abort) Abort initialization.

Type :b for backtrace, :c <option number> to proceed,  or :? for  
other options

MP 1 : 1 >



Re: initializing packages while running lw from command prompt


> how do i run functions from the multiprocessing package from command
> prompt?

Running from script from the command prompt in LispWorks is harder
than you might think.  What I usually do is either use deliver to
create a stand alone executable for my program, or for quick things I
use a lisp-shell executable that I can run under Unix.

LispWorks feature request: Have options similar to clisp to make
writing small Lisp scripts easy.

Cheers,
Chris Dean


Re: initializing packages while running lw from command prompt

On 1/11/07, V. D. Veksler <vekslv@rpi.edu> wrote:
>
> how do i run functions from the multiprocessing package from command
> prompt?

By initializing multiprocessing before creating processes:

 (mp:initialize-multiprocessing)


Re: initializing packages while running lw from command prompt

On 1/12/07, V. D. Veksler <vekslv@rpi.edu> wrote:
> delivering doesn't work, "Error: Delivery is only available in a
> non-multiprocessing image"
>
> i want to be able to submit lw parallel jobs to a grid, so i need a single
> command line that would submit the job
> delivery would've worked, if it worked........

Huh?  When you deliver an executable, you create a delivery script to
load the code that comprises your program and then you dump an
executable.  You shouldn't be doing any actual work in the delivery
script, so you shouldn't need multiprocessing while delivering.

Did calling MP:INITIALIZE-MULTIPROCESSING not solve your problem?


Re: initializing packages while running lw from command prompt


"V. D. Veksler" <vekslv@rpi.edu> writes:
> delivering doesn't work, "Error: Delivery is only available in a non- 
> multiprocessing image"

Deliver works for me, fwiw.   Try the code below and see if you can
run the mp-test executable.

Cheers,
Chris Dean




;;;; deliver-mp-test

(load-all-patches)

(defun test-process ()
  (let ((name (mp:process-name mp:*current-process*)))
    (format t "Starting ~a~%" name)
    (let ((i 0))
      (dotimes (x (* 10000 (1+ (random 10))))
        (setq i x))
      (format t "Done ~a: ~a~%" name i))))
  
(defun main ()
  (dotimes (x 10)
    (mp:process-run-function 
     (format nil "test-process ~a" x) '() 'test-process)))

(deliver 'main
         "mp-test"
         0
         :multiprocessing t)

(quit)


Re: initializing packages while running lw from command prompt

On 1/12/07, V. D. Veksler <vekslv@rpi.edu> wrote:
> no, (mp:initialize-multiprocessing) did not solve my problem....
> it got rid of the 'multiprocessing not initialized' error, but
> everything else stopped working.
>
> delivering any code that has the mp:initialize-multiprocessing line
> will not work at all:
> "Error: Delivery is only available in a multi-processing image"

What does your delivery script look like?

The problem is most likely that you call MAIN at the end of this file.
 Instead, leave just the definitions in and remove the MAIN and QUIT
calls.  Then your delivery script should be something like:

  (load-all-patches)
  (load "test")

  (deliver #'main "target-file")

HTH,
Bill


Re: initializing packages while running lw from command prompt

On 1/12/07, Bill Atkins <atkinw@rpi.edu> wrote:
>   (deliver #'main "target-file")

(deliver #'main "target-file" 0)

-- 
Bill Atkins


Updated at: 2020-12-10 08:46 UTC