AP_recv_count

query the result of an asynchronous reduction

Synopsis

int AP_recv_count(int *count)

SUBROUTINE AP_RECV_COUNT(count, return_value)
INTEGER count, return_value

Parameters

count
result of the reduction

Description

Queries the result of the pending asynchronous reduction to determine how many messages from the prior batch of sends were sent to this processor.

Return value

If it returns zero, the asynchronous reduction is not yet complete. The user code must call AP_recv() with the expectation of receiving more messages. If desired, it is safe to block as long as the AP_DROPOUT flag is specified (this flag makes AP_recv() unblock and return 0 if any reduction-related messages are seen). AP_recv_count() can then be queried again.

If it returns nonzero, the asynchronous reduction is complete (at least as far as this processor is concerned) and *count is set to the number of messages whose destination is this processor. It is up to the caller to compare this with the number received so far to determine whether more messages are yet to arrive. After AP_recv_count() returns nonzero, it is not necessary for this processor to call AP_recv() any longer.

Overview

The general organization of user code should be as follows. Each processor calls AP_send_begin(), then does some sends, then calls AP_send_end(). Then it loops calling AP_recv(), blocking if desired (but using the AP_DROPOUT flag if blocking). AP_recv_count() will indicate when the loop should terminate. It is not necessary to synchronize the processors at any point during this process.