main   xtlang


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

Implementation

(bind-func main
  (let ((limit 10))
    (lambda ()
      (MPI_Init null null)
      (let ((world_size_ptr:i32* (salloc))
            (world_size (begin
                          (MPI_Comm_size MPI_COMM_WORLD world_size_ptr)
                          (pref world_size_ptr 0)))
            (world_rank_ptr:i32* (salloc))
            (world_rank (begin
                          (MPI_Comm_rank MPI_COMM_WORLD world_rank_ptr)
                          (pref world_rank_ptr 0)))
            (number:i32* (salloc)))
        (if (< world_size 2)
            (begin
              (println "World size must be greater than 1")
              (MPI_Abort MPI_COMM_WORLD 1)))
        (let ((count_ptr:i32* (salloc))
              (partner_rank (% (+ world_rank 1) 2)))
          (pset! count_ptr 0 0)
          (while (< (pref count_ptr 0) limit)
            (if (= world_rank (% (pref count_ptr 0) 2))
                (begin
                  (pset! count_ptr 0 (+ (pref count_ptr 0) 1))
                  (MPI_Send (convert count_ptr) 1 MPI_INT partner_rank 0 MPI_COMM_WORLD)
                  (printf "%d sent and incremented count %d to %d\n" world_rank (pref count_ptr 0) partner_rank))
                (begin
                  (MPI_Recv (convert count_ptr) 1 MPI_INT partner_rank 0 MPI_COMM_WORLD MPI_STATUS_IGNORE)
                  (printf "%d received count %d from %d\n" world_rank (pref count_ptr 0) partner_rank)))))
        (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