genpapifdef.c File Reference

Include dependency graph for genpapifdef.c:

Go to the source code of this file.

Defines

#define PAPI_EVENTS_IN_DERIVED_EVENT   8

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'

Define Documentation

#define PAPI_EVENTS_IN_DERIVED_EVENT   8

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.

00233 {
00234     int i, j;
00235     /* compute the size of the predefined array */
00236     j = size / sizeof ( hwi_describe_t );
00237 
00238     /* create defines for each line in the general arrays */
00239     printf( "\n%c\n%c  %s\n%c\n\n", comment_char, comment_char, title,
00240             comment_char );
00241     for ( i = 0; i < j; i++ )
00242         define_val( descr[i].name, descr[i].value, deftype );
00243 }

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.

00197 {
00198     char value[20];
00199     /* The Fortran spec defines negative numbers as the negation of a positive number.
00200        Because of that definition, the largest possible 2's complement negative
00201        number cannot be legally expressed in Fortran. Compiler behavior is undefined
00202        and unpredictable on this issue.
00203        Several FORTRAN compilers (GNU Fortran (GCC) > 4.2.3, others?)
00204        will throw errors or warnings for an explicit numeric value of -2147483648,
00205        However, they don't object to an arithmetic evaluation that produces the
00206        desired value. This value happens to be used for the PAPI preset
00207        PAPI_L1_DCM, and PAPI_DOM_HWSPEC. 
00208        The hack below works around that limitation.
00209      */
00210     if ( ( ( unsigned ) val ) == 0x80000000 ) {
00211         sprintf( value, "((-2147483647) - 1)" );
00212     } else {
00213         sprintf( value, "%d", val );
00214     }
00215 
00216     switch ( deftype ) {
00217     case CDEFINE:
00218         printf( "#define %-18s %s\n", val_string, value );
00219         break;
00220     case F77DEFINE:
00221         printf( "      INTEGER %-18s\n      PARAMETER (%s=%s)\n", val_string,
00222                 val_string, value );
00223         break;
00224     case F90DEFINE:
00225         printf( "      INTEGER, PARAMETER :: %-18s = %s\n", val_string, value );
00226         break;
00227     }
00228 }

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 247 of file genpapifdef.c.

00248 {
00249     int i;
00250     enum deftype_t deftype = CDEFINE;
00251 
00252     if ( argc > 1 ) {
00253         if ( strcmp( argv[1], "-f77" ) == 0 ) {
00254             deftype = F77DEFINE;
00255             comment_char = '!';
00256         } else if ( strcmp( argv[1], "-f90" ) == 0 ) {
00257             deftype = F90DEFINE;
00258             comment_char = '!';
00259         } else if ( strcmp( argv[1], "-c" ) == 0 ) {
00260             deftype = CDEFINE;
00261             comment_char = 'C';
00262         } else {
00263             fprintf( stderr, "Usage: %s [ -c | -f77 | -f90 ]\n", argv[0] );
00264             exit( 1 );
00265         }
00266     }
00267 
00268     /* print a file header block */
00269     printf
00270         ( "%c\n%c  This file contains defines required by the PAPI Fortran interface.\n",
00271           comment_char, comment_char );
00272     printf( "%c  It is automagically generated by genpapifdef.c\n",
00273             comment_char );
00274     printf( "%c  DO NOT modify its contents and expect the changes to stick.\n",
00275             comment_char );
00276     printf( "%c  Changes MUST be made in genpapifdef.c instead.\n%c\n\n",
00277             comment_char, comment_char );
00278 
00279     /* create defines for the internal array pairs */
00280     createDef( "General purpose defines.", _papi_def, sizeof ( _papi_def ),
00281                deftype );
00282     /* create defines for each member of the PRESET array */
00283     printf( "\n%c\n%c  PAPI preset event values.\n%c\n\n", comment_char,
00284             comment_char, comment_char );
00285 
00286     for ( i = 0; i < PAPI_MAX_PRESET_EVENTS; i++ ) {
00287         if ( _papi_hwi_presets[i].symbol ) {    /* if the event is in the preset table */
00288             define_val( _papi_hwi_presets[i].symbol,
00289                         ( i | PAPI_PRESET_MASK ), deftype );
00290         }
00291     }
00292     exit( 0 );
00293 }

Here is the call graph for this function:


Variable Documentation

Definition at line 50 of file genpapifdef.c.

char comment_char = 'C' [static]

Definition at line 193 of file genpapifdef.c.


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1