OpenFAM Reference Implementation

openfam::fam::fam_set

Atomically set a value in FAM.

Synopsis

void fam_set(Fam_Descriptor *descriptor, uint64_t offset, int32_t value);

void fam_set(Fam_Descriptor *descriptor, uint64_t offset, int64_t value);

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

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

void fam_set(Fam_Descriptor *descriptor, uint64_t offset, float value);

void fam_set(Fam_Descriptor *descriptor, uint64_t offset, double value);

void fam_set(Fam_Descriptor *descriptor, uint64_t offset, int128_t value);

Description

These methods atomically set a value in FAM.

Input Arguments

Name Description
Descriptor Descriptor associated with the data item.
Offset Offset within the data item in FAM where value is located.
Value Value to be set at the given location.

Return Values

None. Throws an exception on error.

Exceptions

ExceptionDescription
Fam_InvalidOption_Exceptionincorrect parameters are passed.
Fam_Datapath_Exceptionerror occurred during atomic operation over fabric.
FAM_ERR_NOPERMCaller does not have access rights.
FAM_ERR_LIBFABRIClibfabric error occurred.
FAM_ERR_NOTFOUNDItem not found in the region.
FAM_ERR_GRPCif there is a communication error with memory server
FAM_ERR_RPC_CLIENT_NOTFOUND Memory server initialization failure

Notes

These methods atomically set a value in FAM. 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.

A subsequent successful completion of 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 set the value of first integer element in the array
		myFam->fam_set(descriptor, 0, 10);
	
		// ensure that the set operation is complete
		myFam->fam_quiet();
	
		// we now have the set the first integer in FAM to value of 10
	
	 } catch (Fam_Exception &e) {
		printf("fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
	 }
	
	 // ... Finalization code follows
}