decompose_domain   xtlang


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

Implementation

(bind-func decompose_domain
  (lambda (domain_size:i32
      world_rank:i32
      world_size:i32)
    (if (> world_size domain_size)
        ;; Don't worry about this special case. Assume the domain size
        ;; is greater than the world size.
        (MPI_Abort MPI_COMM_WORLD 1))
    (let ((start (* (/ domain_size world_size) world_rank))
          (size (/ domain_size world_size)))
      (if (= world_rank (- world_size 1))
          ;; Give remainder to last process
          (set! size (+ size (% domain_size world_size))))
      (DomainRegion start size))))


Back to Index