OpenFAM Reference Implementation

openfam::fam::fam_put

Copy a segment of memory from local memory to FAM.

Synopsis

void fam_put_blocking(void *local, Fam_Descriptor *descriptor, uint64_t offset, uint64_t nbytes);
void fam_put_nonblocking(void *local, Fam_Descriptor *descriptor, uint64_t offset, uint64_t nbytes);

Description

Copy (part of) some data item from local memory to FAM.

Input Arguments

Name Description
local Appropriately sized area of local memory to use as source.
descriptor Descriptor associated with the data item in FAM for the destination.
offset Byte offset from the start of the data item in FAM.
nbytes Number of bytes to copy.

Return Values

These calls do not return a value on success; Both non-blocking and blocking calls throw 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

See notes for fam_get.

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
		// (a 50 element integer array)
		Fam_Descriptor *descriptor = myFam->fam_lookup("myItem", "myRegion");
		
		// allocate an integer array and initialize it
		int local[] = {0,1,2,3,4,5,6,7,8,9};
		
		// replace elements 6-15 of the data item in FAM with values in local memory

		myFam->fam_put_blocking(local, descriptor, 6*sizeof(int), 10*sizeof(int));

		// ... we now have completed a copy from local memory to FAM
		printf("Completed a copy from local memory to FAM\n");
	 } catch (Fam_Exception &e) {
		printf("fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
	 }
	 // ... Finalization code follows
}