receive_incoming_walkers   xtlang


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

Implementation

(bind-func receive_incoming_walkers
  (lambda (incoming_walkers:WalkerArray* world_rank:i32 world_size:i32)
    ;; Probe for new incoming walkers
    (let ((status:MPI_Status* (salloc))
          ;; Receive from the process before you. If you are process zero,
          ;; receive from the last process
          (incoming_rank (if (= world_rank 0)
                             (- world_size 1)
                             (- world_rank 1)))
          (incoming_walkers_size_ptr:i32* (salloc)))
      (MPI_Probe incoming_rank 0 MPI_COMM_WORLD status)
      ;; Resize your incoming walker buffer based on how much data is
      ;; being received
      (MPI_Get_count status MPI_BYTE incoming_walkers_size_ptr)
      ;; incoming_walkers->resize(incoming_walkers_size / sizeof(Walker));
      (MPI_Recv (convert (tref incoming_walkers 1) i8*)
                (pref incoming_walkers_size_ptr 0)
                MPI_BYTE incoming_rank 0 MPI_COMM_WORLD
                MPI_STATUS_IGNORE)
      (tset! incoming_walkers 0 (/ (pref incoming_walkers_size_ptr 0) 8)))))


Back to Index

Similar Entries