-- | Variant of 'reduceSend' and 'reduceRecv', where result is delivered to all participating processes.
allreduce :: (SendFrom v, RecvInto v) =>
             Comm -- ^ Communicator engaged in reduction/
             -> Operation -- ^ Reduction operation
             -> v -- ^ Value supplied by this process
             -> v -- ^ Reduction result
             -> IO ()
allreduce comm op sendVal recvVal =
  sendFrom sendVal $ \sendPtr sendElements sendType ->
    recvInto recvVal $ \recvPtr _ _ ->
      Internal.allreduce (castPtr sendPtr) (castPtr recvPtr) sendElements sendType op comm
allreduce :: (SendFrom v, RecvInto v) =>
             Comm -- ^ Communicator engaged in reduction/
             -> Operation -- ^ Reduction operation
             -> v -- ^ Value supplied by this process
             -> v -- ^ Reduction result
             -> IO ()
allreduce comm op sendVal recvVal =
  sendFrom sendVal $ \sendPtr sendElements sendType ->
    recvInto recvVal $ \recvPtr _ _ ->
      Internal.allreduce (castPtr sendPtr) (castPtr recvPtr) sendElements sendType op comm
allreduce comm op sendVal recvVal =
  sendFrom sendVal $ \sendPtr sendElements sendType ->
    recvInto recvVal $ \recvPtr _ _ ->
      Internal.allreduce (castPtr sendPtr) (castPtr recvPtr) sendElements sendType op comm