PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
genpapifdef.c File Reference
Include dependency graph for genpapifdef.c:

Go to the source code of this file.

Macros

#define PAPI_EVENTS_IN_DERIVED_EVENT   8 /* to satisfy papi_preset.h */
 

Enumerations

enum  deftype_t { CDEFINE, F77DEFINE, F90DEFINE }
 

Functions

static void define_val (const char *val_string, int val, enum deftype_t deftype)
 
static void createDef (char *title, const hwi_describe_t *descr, int size, enum deftype_t deftype)
 
int main (int argc, char **argv)
 

Variables

const hwi_describe_t _papi_def []
 
static char comment_char = 'C'
 

Macro Definition Documentation

#define PAPI_EVENTS_IN_DERIVED_EVENT   8 /* to satisfy papi_preset.h */

Definition at line 39 of file genpapifdef.c.

Enumeration Type Documentation

enum deftype_t
Enumerator
CDEFINE 
F77DEFINE 
F90DEFINE 

Definition at line 191 of file genpapifdef.c.

Function Documentation

static void createDef ( char *  title,
const hwi_describe_t descr,
int  size,
enum deftype_t  deftype 
)
static

Definition at line 231 of file genpapifdef.c.

233 {
234  int i, j;
235  /* compute the size of the predefined array */
236  j = size / sizeof ( hwi_describe_t );
237 
238  /* create defines for each line in the general arrays */
239  printf( "\n%c\n%c %s\n%c\n\n", comment_char, comment_char, title,
240  comment_char );
241  for ( i = 0; i < j; i++ )
242  define_val( descr[i].name, descr[i].value, deftype );
243 }
static void define_val(const char *val_string, int val, enum deftype_t deftype)
Definition: genpapifdef.c:196
#define printf
Definition: papi_test.h:125
void double value
Definition: iozone.c:18781
int i
Definition: fileop.c:140
char *long long size
Definition: iozone.c:12023
static char comment_char
Definition: genpapifdef.c:193
char * name
Definition: iozone.c:23648
long j
Definition: iozone.c:19135

Here is the call graph for this function:

Here is the caller graph for this function:

static void define_val ( const char *  val_string,
int  val,
enum deftype_t  deftype 
)
static

Definition at line 196 of file genpapifdef.c.

197 {
198  char value[20];
199  /* The Fortran spec defines negative numbers as the negation of a positive number.
200  Because of that definition, the largest possible 2's complement negative
201  number cannot be legally expressed in Fortran. Compiler behavior is undefined
202  and unpredictable on this issue.
203  Several FORTRAN compilers (GNU Fortran (GCC) > 4.2.3, others?)
204  will throw errors or warnings for an explicit numeric value of -2147483648,
205  However, they don't object to an arithmetic evaluation that produces the
206  desired value. This value happens to be used for the PAPI preset
207  PAPI_L1_DCM, and PAPI_DOM_HWSPEC.
208  The hack below works around that limitation.
209  */
210  if ( ( ( unsigned ) val ) == 0x80000000 ) {
211  sprintf( value, "((-2147483647) - 1)" );
212  } else {
213  sprintf( value, "%d", val );
214  }
215 
216  switch ( deftype ) {
217  case CDEFINE:
218  printf( "#define %-18s %s\n", val_string, value );
219  break;
220  case F77DEFINE:
221  printf( " INTEGER %-18s\n PARAMETER (%s=%s)\n", val_string,
222  val_string, value );
223  break;
224  case F90DEFINE:
225  printf( " INTEGER, PARAMETER :: %-18s = %s\n", val_string, value );
226  break;
227  }
228 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
int val
Definition: libbif.c:235
#define printf
Definition: papi_test.h:125
void double value
Definition: iozone.c:18781

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 247 of file genpapifdef.c.

248 {
249  int i;
250  enum deftype_t deftype = CDEFINE;
251 
252  if ( argc > 1 ) {
253  if ( strcmp( argv[1], "-f77" ) == 0 ) {
254  deftype = F77DEFINE;
255  comment_char = '!';
256  } else if ( strcmp( argv[1], "-f90" ) == 0 ) {
257  deftype = F90DEFINE;
258  comment_char = '!';
259  } else if ( strcmp( argv[1], "-c" ) == 0 ) {
260  deftype = CDEFINE;
261  comment_char = 'C';
262  } else {
263  fprintf( stderr, "Usage: %s [ -c | -f77 | -f90 ]\n", argv[0] );
264  exit( 1 );
265  }
266  }
267 
268  /* print a file header block */
269  printf
270  ( "%c\n%c This file contains defines required by the PAPI Fortran interface.\n",
272  printf( "%c It is automagically generated by genpapifdef.c\n",
273  comment_char );
274  printf( "%c DO NOT modify its contents and expect the changes to stick.\n",
275  comment_char );
276  printf( "%c Changes MUST be made in genpapifdef.c instead.\n%c\n\n",
278 
279  /* create defines for the internal array pairs */
280  createDef( "General purpose defines.", _papi_def, sizeof ( _papi_def ),
281  deftype );
282  /* create defines for each member of the PRESET array */
283  printf( "\n%c\n%c PAPI preset event values.\n%c\n\n", comment_char,
285 
286  for ( i = 0; i < PAPI_MAX_PRESET_EVENTS; i++ ) {
287  if ( _papi_hwi_presets[i].symbol ) { /* if the event is in the preset table */
288  define_val( _papi_hwi_presets[i].symbol,
289  ( i | PAPI_PRESET_MASK ), deftype );
290  }
291  }
292  exit( 0 );
293 }
static void define_val(const char *val_string, int val, enum deftype_t deftype)
Definition: genpapifdef.c:196
#define PAPI_PRESET_MASK
#define printf
Definition: papi_test.h:125
int int argc
Definition: iozone.c:1609
char ** argv
Definition: iozone.c:1610
int i
Definition: fileop.c:140
static void createDef(char *title, const hwi_describe_t *descr, int size, enum deftype_t deftype)
Definition: genpapifdef.c:231
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
static char comment_char
Definition: genpapifdef.c:193
deftype_t
Definition: genpapifdef.c:191
#define PAPI_MAX_PRESET_EVENTS
Definition: fpapi.h:16
const hwi_describe_t _papi_def[]
Definition: genpapifdef.c:50
void exit()

Here is the call graph for this function:

Variable Documentation

const hwi_describe_t _papi_def[]

Definition at line 50 of file genpapifdef.c.

char comment_char = 'C'
static

Definition at line 193 of file genpapifdef.c.