main   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/contrib/mpi/send-recv.xtm

Implementation

(bind-func main
  (lambda ()
    ;; Initialize the MPI environment. The two arguments to MPI Init are not
    ;; currently used by MPI implementations, but are there in case future
    ;; implementations might need the arguments.
    (MPI_Init null null)
    ;; Get the number of processes
    (letz ((world_size_ptr:i32* (zalloc))
           (world_rank_ptr:i32* (zalloc))
           (number:i32* (zalloc)))
      (MPI_Comm_size MPI_COMM_WORLD world_size_ptr)
      (MPI_Comm_rank MPI_COMM_WORLD world_rank_ptr)
      (if (< (pref world_size_ptr 0) 2)
          (begin
            (println "World size must be greater than 1")
            (MPI_Abort MPI_COMM_WORLD 1)))
      (if (= (pref world_rank_ptr 0) 0)
          ;; If we are rank 0, set the number to -1 and send it to process 1
          (begin
            (pset! number 0 -1)
            (MPI_Send (convert number) 1 MPI_INT 1 0 MPI_COMM_WORLD))
          (if (= (pref world_rank_ptr 0) 1)
              (begin
                (MPI_Recv (convert number) 1 MPI_INT 0 0 MPI_COMM_WORLD MPI_STATUS_IGNORE)
                (printf "Process 1 received number %d from process 0\n" (pref number 0)))))
      ;; Finalize the MPI environment. No more MPI calls can be made after this
      (MPI_Finalize))))


Back to Index

Similar Entries

  • _glib_main_loop_call    xtlang
  • _glib_main_loop_call    xtlang
  • _glib_main_loop_call    xtlang
  • _gst_main_loop_call    xtlang
  • cerberus_main_cc    xtlang
  • clock_scheduler_main_callback    xtlang
  • decompose_domain    xtlang
  • get_main_frame    xtlang
  • glib-main-loop    scheme
  • glib-main-loop    scheme
  • glib_main_loop    xtlang
  • gst-main-loop    scheme
  • main    xtlang
  • main    xtlang
  • main    xtlang
  • main    xtlang
  • main    xtlang
  • main    xtlang
  • main    xtlang
  • main    xtlang
  • main    xtlang
  • main    xtlang
  • mainLoop    xtlang
  • mainLoop    xtlang
  • main_cc    xtlang
  • main_gain    xtlang
  • main_reverb    xtlang
  • run_main_event_loop    xtlang
  • set_dl_main    xtlang