openfam::fam::fam_copy
Create a second copy of a data item in FAM.
Synopsis
void *fam_copy(Fam_Descriptor *src, uint64_t srcOffset, Fam_Descriptor **dest, uint64_t destOffset, uint64_t nbytes);
Description
Creates a second copy of some data item in FAM and returns a pointer to the wait object associated with this copy operation.
Input Arguments
| Name | Description |
|---|---|
| Src | Descriptor associated with the source data item in FAM. |
| srcOffset | Offset within the source descriptor where copy starts. |
| Dest | Descriptor associated with the destination data item in FAM. |
| destOffset | Offset within the destination descriptor where the copy starts. |
| Nbytes | Number of bytes to copy. |
Return Values
Returns a pointer to the wait object for the copy operation. This object is used wait for the completion of the copy operation. Throws an exception on error.
Exceptions
| Exception | Description |
|---|---|
| Fam_InvalidOption_Exception | incorrect parameters are passed. |
| FAM_ERR_NOPERM | Caller does not have access rights |
| FAM_ERR_GRPC | there is a communication error with memory server |
| FAM_ERR_RPC_CLIENT_NOTFOUND | Memory server initialization failure |
Notes
Note that the method is non-blocking: it returns after the copy has been initiated, and does not wait for completion of the transfer. Also note that fam_copy() performs an inconsistent copy, in that the copied data may reflect updates that are performed concurrently with the copy operation, rather than a point-in-time snapshot of the source data item that is consistent as of the beginning of copy operation. If the application desires a consistent copy, it is responsible for coordinating PE activity during the copy.
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");
// descriptor to new copy myItem in FAM
Fam_Descriptor *newCopy;
// create a new copy and returns a waitObject to copy operation.
void *waitObj = myFam->fam_copy(descriptor, 0, &newCopy, 0, 10*sizeof(int));
// Wait for copy operation to complete.
myFam->fam_copy_wait(waitObj);
printf("Copy to new location in FAM successful\n");
} catch (Fam_Exception &e) {
printf("fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
}
// ... subsequent code here
}