30 May 2022
In Orca, one process acts as a master process (first process with id 0) driving the execution of the computation defined in the kernel code, while the worker processes wait for the commands from the master process and perform the computation. Orca utilizes MPI routines for communication between processes. In this post, I implemented a simple parallel application using Orca’s
rpc-make function to print the numbers of all worker processes.
Orca APIs are categorized into three classes: utility APIs such as
rpc-worker-process-size; bootstrapping APIs such as
rpc-start, and compute APIs (
rpc-apply-scatter etc.) performing computation on a given expression in parallel. To give information on some of the basic Orca APIs:
rpc-startis required to be called by all processes to bootstrap the execution environment. When a worker process calls
rpc-start, the process enters a loop and the flow of the execution never goes beyond the
rpc-start. On the other hand, when
rpc-startis called in the context of the master process, the execution continues. Note that in Orca the process with id 0 acts as master process but also joins the computation like a worker process.
rpc-finalizeis called by the master process to terminate the execution environment. When the function is invoked, a finalize message is sent to all worker processes that instruct them to terminate the loop, and then worker processes exit.
size − 1.
size) joining the computation.
rpc-makereturns a list of values where each i-th element in the list is the result of the computation from the i-th worker.
In the example, the kernel code (rpc-print-process-ids.scm) prints the numbers of all worker processes. The symbolic expression
(process-id-message) given to the
rpc-make function as an argument is broadcasted to all worker processes where the function
process-id-message is invoked by all worker processes. Because
rpc-start blocks the execution of worker processes, the function
process-id-message must be defined before the
rpc-start call in the kernel code. Each worker process constructs a string message containing the process id using Orca’s
(use-modules (orca)) (define (process-id-message) (format #f "process ~a" (rpc-worker-process-id))) (rpc-start) (format #t "I'm master process. Received ~s ~%" (rpc-make '(process-id-message))) (rpc-finalize)
Start the MPI application with 4 processes via:
mpirun -n 4 ./rpc-print-process-ids.scm
I'm master process. Received ("process 0" "process 1" "process 2" "process 3")
For more Orca examples, please navigate to here.
Copyright © 2020, 2021, 2022 Ahmet Artu Yıldırım.
<ahmet at artulab period com
> | GPG Key
Verbatim copying and redistribution of any material in this page is permitted under the Creative Commons Noderivs license version 3.0 or later.