cray_upc_sheap_info
- Date:
04-03-2014
NAME
cray_upc_sheap_info - Returns symmetric heap usage information
SYNOPSIS
#include <upc_cray.h>
shared void *cray_upc_sheap_info( int value );
IMPLEMENTATION
Cray Linux Environment (CLE)
DESCRIPTION
The cray_upc_sheap_info() function returns symmetric heap usage information depending on input value, which may be CRAY_UPC_SHEAP_IS_FIXED, CRAY_UPC_CURR_SIZE, CRAY_UPC_SHEAP_MAX_SIZE, or CRAY_UPC_SHEAP_HIGH_WATER, defined in upc_cray.h.
There are multiple implementations of the symmetric heap, not all of which track these statistics. The implementation used is based on the underlying network and the number of PEs and nodes in use. If PGAS_DEBUG=sheap=1 is set at runtime, then all calls to the symmetric heap are wrapped in a generic debug wrapper that tracks additional statistics even if the underlying heap implementation does not.
RETURN VALUE
Assuming that the symmetric heap information is available, the return value depends on input value as follows:
CRAY_UPC_SHEAP_IS_FIXED
Returns 1 if symmetric heap has a fixed size.
CRAY_UPC_CURR_SIZE
Returns the number of currently allocated bytes in the symmetric heap.
CRAY_UPC_SHEAP_MAX_SIZE
Returns the maximum size of the symmetric heap in bytes. If the symmetric heap does not have a fixed size, this is the current size possibly including free regions.
CRAY_UPC_SHEAP_HIGH_WATER
Returns the largest number of allocated bytes in the symmetric heap over the execution of the program up to the call. If the information is not available in the current runtime, the function returns (size_t)-1.
EXAMPLE
#include<stdio.h>
#include<upc.h>
#include<upc_cray.h>
void print_sheap_info()
{
size_t is_fixed = cray_upc_sheap_info( CRAY_UPC_SHEAP_IS_FIXED );
size_t curr_sz = cray_upc_sheap_info( CRAY_UPC_SHEAP_CURR_SIZE );
size_t max_sz = cray_upc_sheap_info( CRAY_UPC_SHEAP_MAX_SIZE );
size_t hw = cray_upc_sheap_info( CRAY_UPC_SHEAP_HIGH_WATER );
printf(" %s\n curr: %lu bytes\n max: %lu bytes\n hw: %lu bytes\n",
is_fixed?"fixed":"dynamic",curr_sz,max_sz,hw);
}
int main()
{
if ( !MYTHREAD ) {
puts("Before allocation:");
print_sheap_info();
}
shared void *p = upc_all_alloc( THREADS, 32ul * 1024ul * 1024ul );
upc_barrier;
if ( !MYTHREAD ) {
puts("After allocation:");
print_sheap_info();
}
upc_all_free( p );
return 0;
}