Towards the Completion of Parallel Lisp

Kenichi Sasagawa
2 min readApr 29, 2024

Ver3.90

Released Easy-ISLisp ver3.90 on 2024/4/29. Added parallel functionality via multiprocessing. Lately, I’ve been conducting computational experiments using multiprocessing. This approach allows us to leverage modern multicore CPUs. In addition to the traditional multithreading approach, parallel functionality via multicore has been added.

Parallel Syntax

Several parallel syntaxes have been added. Also, regarding those of the conventional thread-based approach, some name changes have been made. The following syntaxes have been prepared.

Multiprocessing

mp-create 
mp-close
mp-call
mp-exec
mp-let

Multithreading

mt-call (pcall)
mt-exec (pexec)
mt-let (plet)
mt-lock (plock)

Please refer to the documents PARA.md and PARA1.md for detailed functionality.

Example of Execution with Compiler

Below is an example of Fibonacci numbers, often used in benchmarks.

(defun fib* (n)
(mp-call #'+ (fib (- n 1))
(fib (- n 2))))


(defun fib (n)
(cond ((= n 1) 1)
((= n 2) 1)
(t (+ (fib (- n 1)) (fib (- n 2)))) ))

Compile as follows:

Easy-ISLisp Ver3.90
> (compile-file "./tests/para.lsp")
type inference
warning TARAI numerical argument type mismatch (- X 1)
warning TARAI type mismatch (IF (<= X Y) Y (TARAI (TARAI (- X 1) Y Z) (TARAI (- Y 1) Z X) (TARAI (- Z 1) X Y)))
initialize
pass1
pass2
compiling FOO
compiling BAR
compiling BOO
compiling TARAI*
compiling TARAI
compiling FIB*
compiling FIB
finalize
invoke CC
T
>

To launch multiprocessing, use the function (mp-call n). This will start n child Lisps. They communicate with the parent Lisp via pipes. (load fn) has been extended. Even in each child Lisp, the same code will be loaded if it is operating with multiprocessing.

Please see the following example of execution.

It can be seen that the calculation of Fibonacci numbers has been accelerated.

Outlook

Bugs are inevitable in software. We will repeat bug fixes and improvements towards ver4.0. If readers notice any issues, please inform us on Github’s issues page. Thank you.

sasagawa888/eisl: ISLisp interpreter/compiler (github.com)

I have achieved my goal. Thank you, everyone.

--

--