openfam::fam::fam_put
Copy a segment of memory from local memory to FAM.
Synopsis
int 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
The non-blocking call does not return a value on success; the blocking call returns an integer value following normal C convention of 0 for successful completion. Both non-blocking and blocking call throws an exception on error.
Exceptions
| Exception | Description |
|---|---|
| Fam_InvalidOption_Exception | incorrect parameters are passed. |
| Fam_Datapath_Exception | error occurred during write operation over fabric. |
| FAM_ERR_LIBFABRIC | libfabric error occurred. |
| Fam_Timeout_Exception | number of libfabric retry count reached the timeout limit. (Only for blocking call) |
| FAM_ERR_NOPERM | Caller does not have access rights |
| FAM_ERR_ALREADYEXIST | the data item name is already present in FAM |
| FAM_ERR_GRPC | there is a communication error with memory server |
| FAM_ERR_RPC_CLIENT_NOTFOUND | Memory server initialization failure |
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
}