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 key;
    uint64_t size;
    mode_t perm;
    char *name;
} Fam_Stat;
	
NameDescriptionDefault Value
keyKey associated with region or data item. To be used in future. none
sizeSize of the region or data item in bytes none
permpermissions associated with the region or data itemnone
nameName of the region or data item. 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
}