OpenFAM Reference Implementation

openfam::fam::fam_fetch_TYPE

Atomically fetches a value from FAM.

Synopsis

int32_t fam_fetch_int32(Fam_Descriptor *descriptor, uint64_t offset);

int64_t fam_fetch_int64(Fam_Descriptor *descriptor, uint64_t offset);

uint32_t fam_fetch_uint32(Fam_Descriptor *descriptor, uint64_t offset);

uint64_t fam_fetch_uint64(Fam_Descriptor *descriptor, uint64_t offset);

float fam_fetch_float(Fam_Descriptor *descriptor, uint64_t offset);

double fam_fetch_double(Fam_Descriptor *descriptor, uint64_t offset);

int128_t fam_fetch_int128(Fam_Descriptor *descriptor, uint64_t offset);

Description

These methods atomically fetches a value from FAM.

Input Arguments

Name Description
descriptor Descriptor associated with the data item.
offset Offset within the data item in FAM where value is located.

Return Values

The value from FAM. 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_RPCCommunication error from grpc layer.
FAM_ERR_RPC_CLIENT_NOTFOUNDRPC service not available.
FAM_ERR_METADATAMetadata service error.
FAM_ERR_MEMORYMemory service error.
FAM_ERR_RESOURCEResource not available.
FAM_ERR_TIMEOUTNumber of libfabric retry count reached.

Notes

These methods atomically fetch a value from 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.

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
		Fam_Descriptor *descriptor = myFam->fam_lookup("myItem", "myRegion");
	
                // Fetching int32 value from offset 0 using FAM descriptor 
		uint32_t value = myFam->fam_fetch_int32(descriptor, 0);

		// The first integer in FAM is in local variable value
	
		// ... subsequent code here
	} catch (Fam_Exception &e) {
		printf("fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
	}
	
	// ... Finalization code follows
}