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 Fam_Exception
on error.
Fam Error Numbers
Error | Description |
---|---|
FAM_ERR_INVALID | API called with incorrect parameters. |
FAM_ERR_UNIMPL | Calling unimplemented functions/APIs. |
FAM_ERR_NOPERM | Caller does not have access rights |
FAM_ERR_LIBFABRIC | Libfabric error occurred. |
FAM_ERR_NOTFOUND | Item not found in the region. |
FAM_ERR_RPC_CLIENT_NOTFOUND | RPC service not available. |
FAM_ERR_METADATA | Metadata service error. |
FAM_ERR_MEMORY | Memory service error. |
FAM_ERR_RESOURCE | Resource not available. |
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.
fam_map()
and fam_unmap()
are currently only supported in the scale-up (shared memory) configuration of the OpenFAM reference implementation.
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 }