openfam::fam::fam_close
Close the descriptor of a data item in FAM.
Synopsis
void fam_close(Fam_Descriptor *descriptor);
Description
This method reduces the reference count of the region within which the data item represented by the descriptor is allocated. OpenFAM internally uses this reference count for optimal usage of resources. Fam_close() helps to release unused resources back to the system.
Input Arguments
Name | Description |
---|---|
descriptor | Descriptor associated with the space to deallocate. |
Return Values
None. Throws Fam_Exception
on error.
Fam Error Numbers
Error | Description |
---|---|
FAM_ERR_NOPERM | Caller does not have access rights. |
FAM_ERR_NOTFOUND | Item or region name was not found by the metadata service. |
FAM_ERR_RPC | Communication error from grpc layer. |
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
There is no explicit open method for a data item descriptor. The reference count of a region is increased when a PE obtains a valid descriptor for a data item belonging to that region (either when data item is allocated or while validating the descriptor in any data path or atomic API call).
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 { // get a region descriptor from the metadata service Fam_Region_Descriptor *region = myFam->fam_lookup_region("myRegion"); // create 50 element unnamed integer array in FAM with 0600 // (read/write by owner) permissions in myRegion Fam_Descriptor *descriptor = myFam->fam_allocate((uint64_t)(50 * sizeof(int)), 0600, region); printf("Successfully allocated 50 unnamed integer elements\n"); // close the descriptor myFam->fam_close(descriptor); printf("Successfully closed the data item descriptor\n"); } catch (Fam_Exception &e) { printf("Fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg()); } // ... Finalization code here }