OpenFAM Reference Implementation

openfam::fam::fam_stat

Get the size, permissions and name of a region or data item.

Synopsis

void fam_stat(Fam_Descriptor *descriptor, Fam_Stat *famInfo);

void fam_stat(Fam_Region_Descriptor *descriptor, Fam_Stat *famInfo);

Description

These methods return the size, permissions and name associated with the data item or region descriptor.

Input Arguments

NameDescription
descriptorDescriptor associated with the region or the data item.
famInfoA pointer to the structure where the information is copied.

fam_stat() takes a pointer to the Fam_Stat structure as input to copy the information associated with region or data item descriptor.

typedef struct {
    uint64_t size;
    mode_t perm;
    uint32_t uid;
    uint32_t gid;
    char *name;    
    Fam_Region_Attributes region_attributes;
    int num_memservers;
    int interleaveSize;
    int *memory_servers;

} Fam_Stat;
	
NameDescriptionDefault Value
sizeSize of the region or data item in bytes none
permpermissions associated with the region or data itemnone
uiduid associated with the region or data itemnone
gidgid associated with the region or data itemnone
nameName of the region or data item. none
region_attributesRegion-specific attributes like redundancy level, MemoryType, InterleaveDisabled/Enabled . 0
num_memserversNumber of memory servers used for a region or data item. none
interleaveSizedata item interleaving size used for a given region. none
memory_serversList of memory servers used for a given data item allocation. The list is ordered such that data item offset will be obtained as a multiple of list_element_index and interleaveSize. If the data item goes beyond available memory servers, the allocation is done again from the beginning of list. In that case data item offset calculation on any memory server can be obtained as a multiple of (list_element_index * intereleaveSize) % num_memservers, added with (num_memservers * interleaveSize), each time we rollback to the beginning of list. none

Return Values

None. Throws Fam_Exception on error.

Fam Error Numbers

ErrorDescription
FAM_ERR_INVALIDAPI called with incorrect parameters.
FAM_ERR_NOPERMCaller does not have access rights.
FAM_ERR_NOTFOUNDItem or region name was not found by the metadata service.
FAM_ERR_RPCCommunication error from grpc layer.
FAM_ERR_RPC_CLIENT_NOTFOUNDRPC service not available.
FAM_ERR_METADATAMetadata service error.

Example

#include <stdlib.h>
#include <stdio.h>
#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");
		
		// allocate space for Fam_Stat structure.
		Fam_Stat *info = (Fam_Stat *)calloc(1, sizeof(Fam_Stat));
		myFam->fam_stat(region, info);
		printf("Region_size: %lu\n", info->size);
		
		// Get a descriptor (created by another PE) via the metadata service
		Fam_Descriptor *arrayDescriptor = myFam->fam_lookup("myArray", "myOtherRegion");
		
		// Get data item info
		myFam->fam_stat(arrayDescriptor, info);
		printf("array_size: %lu\n", info->size);
		
	} catch (Fam_Exception &e) {
		printf("Fam API failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
	}
		
	// ... continuation code here
}