OpenFAM Reference Implementation

openfam::fam::fam_resize_region

Resize an existing region in FAM

Synopsis

int fam_resize_region(Fam_Region_Descriptor *descriptor, uint64_t nbytes);

Description

This method resizes a region in FAM.

Input Arguments

NameDescription
DescriptorDescriptor of the region to be resized.
NbytesNew requested size of the region.

Return Values

Returns 0 on Success. Throws an exception on error.

Exceptions

ExceptionDescription
FAM_ERR_NOPERMCaller does not have access rights
FAM_ERR_NOTFOUNDthe region name is not present in FAM
FAM_ERR_GRPCthere is a communication error with memory server
FAM_ERR_RPC_CLIENT_NOTFOUNDMemory server initialization failure

Notes

Regions may safely be increased in size (subject to system-wide limits). Reducing the region size (although allowed) implies that any data items in the truncated part of the region will be lost. The behavior of the library if those items are accessed later is implementation dependent.

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 {
		// create a 10 GB region with 0777 permissions and RAID5 redundancy
		Fam_Region_Descriptor *rd =	myFam->fam_create_region("myRegion", (uint64_t)10000000000, 0777, RAID5);
			
		// use the created region...
		printf("fam_create_region successful\n");
			
		// resize the region to 20 GB
		myFam->fam_resize_region(rd, (uint64_t)20000000000);
			
		// use the re-sized region
		printf("fam_resize_region successful\n");
		// ... continuation code here
			
		// we are finished. Destroy the region and everything in it
		myFam->fam_destroy_region(rd);
		printf("fam_destroy_region successful\n");
	} catch (Fam_Allocator_Exception &e) {
		printf("Create/Destroy region failed: %d: %s\n", e.fam_error(), e.fam_error_msg());
	}
	// ... finalization code here
}