OpenFAM Reference Implementation

openfam::fam::fam_barrier_all

Suspends the execution of the calling PE until all other PEs issue a call to this particular fam_barrier_all() statement.

Synopsis

void fam_barrier_all(void);

Description

This method is used to suspend the execution of the calling PE until all other PEs issue a call to a corresponding fam_barrier_all() statement.

Input Arguments

None.

Return Values

None.

Notes

The OpenFAM library suspends the execution of calling PE until all other cooperating PEs issue a call to this function. This call should be preceded by a fam_quiet() if non-blocking calls are pending since it does not wait for pending non-blocking calls to complete.

Example

#include <string.h>
#include <fam/fam.h>
#include <fam/fam_exception.h>
using namespace std;
using namespace openfam;

int main(void) {
	fam *myFam = new fam();
	// ... Initialization code here

	try {
		Fam_Region_Descriptor *region = myFam->fam_lookup_region("myRegion");
		// create 50 element unnamed integer array in FAM with 0600
		// (read/write by owner) permissions in myRegion
		Fam_Descriptor *descriptor = myFam->fam_allocate((uint64_t)(50 * sizeof(int)), 0600, region);

		printf("Successfully allocated 50 unnamed integer elements\n");
	} catch (Fam_Exception &e) {
		printf("fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
	}
	
	// Wait for all PEs to complete allocation
	myFam->fam_barrier_all();
	
	// Continue with the application
	
	try{
		// free allocated space in FAM
		myFam->fam_deallocate(descriptor);
		printf("Successfully de-allocated 50 unnamed integer elements\n");
	} catch (Fam_Exception &e) {
		printf("fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
	 }
	 // ... Finalization code here
}