PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dmem_info.c
Go to the documentation of this file.
1 /*
2  * This file perfoms the following test: dynamic memory info
3  * The pages used should increase steadily.
4  *
5  * Author: Kevin London
6  * london@cs.utk.edu
7  */
8 #include "papi_test.h"
9 
10 #define ALLOCMEM 200000
11 static void
12 dump_memory_info( FILE * output, PAPI_dmem_info_t * d )
13 {
14  fprintf( output, "\n--------\n" );
15  fprintf( output, "Mem Size:\t\t%lld\n", d->size );
16  fprintf( output, "Mem Peak Size:\t\t%lld\n", d->peak );
17  fprintf( output, "Mem Resident:\t\t%lld\n", d->resident );
18  fprintf( output, "Mem High Water Mark:\t%lld\n", d->high_water_mark );
19  fprintf( output, "Mem Shared:\t\t%lld\n", d->shared );
20  fprintf( output, "Mem Text:\t\t%lld\n", d->text );
21  fprintf( output, "Mem Library:\t\t%lld\n", d->library );
22  fprintf( output, "Mem Heap:\t\t%lld\n", d->heap );
23  fprintf( output, "Mem Locked:\t\t%lld\n", d->locked );
24  fprintf( output, "Mem Stack:\t\t%lld\n", d->stack );
25  fprintf( output, "Mem Pagesize:\t\t%lld\n", d->pagesize );
26  fprintf( output, "Mem Page Table Entries:\t\t%lld\n", d->pte );
27  fprintf( output, "--------\n\n" );
28 }
29 
30 int
31 main( int argc, char **argv )
32 {
33  PAPI_dmem_info_t dmem;
34  long long value[7];
35  int retval, i = 0, j = 0;
36  double *m[7];
37 
38  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
40  if ( retval != PAPI_VER_CURRENT )
41  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
42 
43  for ( i = 0; i < 7; i++ ) {
44  retval = PAPI_get_dmem_info( &dmem );
45  if ( retval != PAPI_OK )
46  test_fail( __FILE__, __LINE__, "PAPI_get_dmem_info", retval );
47 /* dump_memory_info(stdout,&dmem); */
48  value[i] = dmem.size;
49  m[i] = ( double * ) malloc( ALLOCMEM * sizeof ( double ) );
50  touch_dummy( m[j], ALLOCMEM );
51  }
52 
53  if ( !TESTS_QUIET ) {
54  printf( "Test case: Dynamic Memory Information.\n" );
55  dump_memory_info( stdout, &dmem );
56  printf
57  ( "------------------------------------------------------------------------\n" );
58  for ( i = 0; i < 7; i++ )
59  printf( "Malloc additional: %d KB Memory Size in KB: %d\n",
60  ( int ) ( ( sizeof ( double ) * ALLOCMEM ) / 1024 ),
61  ( int ) value[i] );
62  printf
63  ( "------------------------------------------------------------------------\n" );
64  }
65  if ( value[6] >= value[5] && value[5] >= value[4] && value[4] >= value[3]
66  && value[3] >= value[2] && value[2] >= value[1] &&
67  value[1] >= value[0] )
68  test_pass( __FILE__, NULL, 0 );
69  else
70  test_fail( __FILE__, __LINE__, "Calculating Resident Memory",
71  ( int ) value[6] );
72 
73  exit( 1 );
74 }
static void dump_memory_info(FILE *output, PAPI_dmem_info_t *d)
Definition: dmem_info.c:12
long long peak
Definition: papi.h:869
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
long long heap
Definition: papi.h:876
#define printf
Definition: papi_test.h:125
void double value
Definition: iozone.c:18781
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
int i
Definition: fileop.c:140
long long resident
Definition: papi.h:871
A pointer to the following is passed to PAPI_get_dmem_info()
Definition: papi.h:868
#define ALLOCMEM
Definition: dmem_info.c:10
long long pagesize
Definition: papi.h:879
long long locked
Definition: papi.h:877
long long library
Definition: papi.h:875
void touch_dummy(double *array, int size)
Definition: dummy.c:41
int PAPI_get_dmem_info(PAPI_dmem_info_t *dest)
Definition: papi.c:5989
long long shared
Definition: papi.h:873
long long pte
Definition: papi.h:880
long long text
Definition: papi.h:874
long long stack
Definition: papi.h:878
long j
Definition: iozone.c:19135
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223
long long size
Definition: papi.h:870
int main(int argc, char **argv)
List all appio events codes and names.
void exit()
char * m
Definition: iozone.c:1620
long long high_water_mark
Definition: papi.h:872