OpenFAM Reference Implementation

openfam::fam::fam_map

Map a data item in FAM to the process virtual address space.

Synopsis

void *fam_map(Fam_Descriptor *descriptor);

Description

This method maps a data item in FAM to the PE's virtual address space.

Input Arguments

Name Description
Descriptor Descriptor associated with the data item or region in FAM.

Return Values

A pointer in the PE's virtual address space that can be used to directly manipulate contents of FAM. Throws an exception on error.

Exceptions

ExceptionDescription
Fam_InvalidOption_Exceptionincorrect parameters are passed.
Fam_Unimplemented_ExceptionAPI not implemented error. (Only for memory server allocator)
FAM_ERR_NOPERMCaller does not have access rights
FAM_ERR_ALREADYEXISTthe data item name is already present in FAM
FAM_ERR_GRPCthere is a communication error with memory server
FAM_ERR_RPC_CLIENT_NOTFOUNDMemory server initialization failure

Notes

Note that if multiple PEs simultaneously access a data item in FAM when at least one has mapped it, they are responsible for enforcing concurrency control and for ensuring that processor caches are managed appropriately. The implementation may limit the FAM size (hence the size of data items) that can be mapped into the processor address space at one time.

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");

		// map it into our local address space
		int *fam_array = (int *) myFam->fam_map(descriptor);

		// now we can directly manipulate the data in FAM
		for(int i = 0; i < 10; i++){
			printf("%d\n", fam_array[i]); // print it
			fam_array[i]++; // increment it
		}

		// unmap it
		myFam->fam_unmap(fam_array, descriptor); // we are done...
	} catch (Fam_Exception &e) {
		printf("fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
	}
	// ... Finalization code follows
}