OpenFAM Reference Implementation

openfam::fam::fam_or

Atomically replace a value in FAM with the Bitwise OR of that value and some given value.

Synopsis

void fam_or(Fam_Descriptor *descriptor, uint64_t offset, uint32_t value);

void fam_or(Fam_Descriptor *descriptor, uint64_t offset, uint64_t value);

Description

These methods atomically replace a value in FAM with the Bitwise OR of the value given and the existing value.

Input Arguments

NameDescription
descriptorDescriptor associated with the data item.
offsetOffset within the data item in FAM where value is located.
valueValue to be combined with the existing value at the given location.

Return Values

None. Throws Fam_Exception on error.

Fam Error Numbers

ErrorDescription
FAM_ERR_INVALIDAPI called with incorrect parameters.
FAM_ERR_NOPERMCaller does not have access rights.
FAM_ERR_LIBFABRICLibfabric error occurred.
FAM_ERR_NOTFOUNDItem not found in the region.
FAM_ERR_RPC_CLIENT_NOTFOUNDRPC service not available.
FAM_ERR_METADATAMetadata service error.
FAM_ERR_MEMORYMemory service error.
FAM_ERR_RESOURCEResource not available.

Notes

These methods atomically replace a value in FAM with the Bitwise OR of the existing value and the value given in the method, and return before the operation is complete. Note that the offset argument must point to the correct value for the data type. Availability of these methods is dependent on hardware support for the operations.

Successful completion of a subsequent fam_quiet() call ensures the completion of this atomic operation.

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 {
		// look up the descriptor to a previously allocated data item
		// (an integer array with at least 10 elements)
		Fam_Descriptor *descriptor = myFam->fam_lookup("myItem", "myRegion");
	
		// Atomically replace a value of first integer element in the array
		// with the Bitwise OR of it and a value of 0x444
		uint32_t value = 0x444;
		myFam->fam_or(descriptor, 0, value);
	
		// ensure that the OR operation is complete
		myFam->fam_quiet();
	
		// The first integer in FAM is now bitwise OR with a value of 0x444
	
		// ... subsequent code here
	} catch (Fam_Exception &e) {
		printf("fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
	}
	
	// ... Finalization code follows
}