OpenFAM Reference Implementation

openfam::fam::fam_get_option

Get the value for a pre-defined option in the FAM library.

Synopsis

const void *fam_get_option(char *optionName);

Description

This method can be used to retrieve values of state variables maintained within OpenFAM or set using the options argument to fam_initialize(). The supported names (and returned types) are implementation specific.

Input Arguments

NameDescription
optionNameName of the option to be retrieved.
The following optionNames are available:
NameDescriptionReturn typeDefault Value
"VERSION" Version of the current implementation of the OpenFAM API. char* "0.0.1"
"DEFAULT_REGION_NAME" The default Region name used with in the program. char* "default"
"MEMORY_SERVER" Memory server set by the application. char* "0:127.0.0.1"
"GRPC_PORT" Grpc port used by memory server allocator. char* "8787"
"LIBFABRIC_PORT" Port used for libfabric operations in memory server allocator char* "7500"
"LIBFABRIC_PROVIDER" Libfabric provider type set by the application. char* "sockets"
"FAM_THREAD_MODEL" Thread model used by the application. char* "FAM_THREAD_SERIALIZE"
"ALLOCATOR" Allocator type used by the application. char* "grpc"
"FAM_CONTEXT_MODEL" Fam context model used by the application. char* "FAM_CONTEXT_DEFAULT"
"PE_COUNT" Number of PEs running the application program. int* 1
"PE_ID" PE id of the current program. int* 0
"RUNTIME" Runtime environment used by the application. char* "PMIX"
"NUM_CONSUMER" Number of consumer threads running in shared memory allocator. char* "1"

 

Note: The following options are not supported in current implementation and should not be used. It return the default values. "DEFAULT_REGION_NAME", "FAM_THREAD_MODEL" and "FAM_CONTEXT_MODEL"

Return Values

A pointer to the value of the option. Throws an exception on error.

Exceptions

Fam_InvaidOption_Exception if optionName not found.

Notes

None.

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 {
		// assume that library version is one of the supported options
		const char * libraryVersion = (const char *)myFam->fam_get_option(strdup("VERSION"));
		printf("%s\n", libraryVersion);
	} catch (Fam_Exception& e) {
		printf("FAM API failed: %s\n", e.fam_error_msg());
		myFam->fam_abort(-1); // abort the program
		return -1;
	}
	
	// ... finalization code here

}