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

Go to the source code of this file.

Functions

void Thread (int t, int n)
 
int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 103 of file zero_smp.c.

104 {
105  int i, retval;
106  long long elapsed_us, elapsed_cyc;
107 
108  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
109 
111  if ( retval != PAPI_VER_CURRENT )
112  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
113 
114  elapsed_us = PAPI_get_real_usec( );
115 
116  elapsed_cyc = PAPI_get_real_cyc( );
117 
118 #if defined(_AIX)
119  retval =
120  PAPI_thread_init( ( unsigned long ( * )( void ) ) ( pthread_self ) );
121  if ( retval != PAPI_OK ) {
122  if ( retval == PAPI_ECMP )
123  test_skip( __FILE__, __LINE__, "PAPI_thread_init", retval );
124  else
125  test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
126  }
127 #pragma ibm parallel_loop
128 #elif defined(sgi) && defined(mips)
129  retval =
130  PAPI_thread_init( ( unsigned long ( * )( void ) ) ( mp_my_threadnum ) );
131  if ( retval != PAPI_OK ) {
132  test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
133  }
134 #pragma parallel
135 #pragma local(i)
136 #pragma pfor
137 #elif defined(sun) && defined(sparc)
138  retval = PAPI_thread_init( ( unsigned long ( * )( void ) ) ( thr_self ) );
139  if ( retval != PAPI_OK ) {
140  test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
141  }
142 #pragma MP taskloop private(i)
143 #else
144  test_skip(__FILE__, __LINE__, "Architecture not included in this test file yet.", 0);
145 #endif
146  for ( i = 1; i < 3; i++ )
147  Thread( i, 10000000 * i );
148 
149  elapsed_cyc = PAPI_get_real_cyc( ) - elapsed_cyc;
150 
151  elapsed_us = PAPI_get_real_usec( ) - elapsed_us;
152 
153  if ( !TESTS_QUIET ) {
154  printf( "Master real usec : \t%lld\n", elapsed_us );
155  printf( "Master real cycles : \t%lld\n", elapsed_cyc );
156  }
157  test_pass( __FILE__, NULL, 0 );
158  exit( 1 );
159 }
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
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_thread_init(unsigned long int(*id_fn)(void))
Definition: papi.c:118
int PAPI_library_init(int version)
Definition: papi.c:495
int i
Definition: fileop.c:140
long long elapsed_cyc
Definition: zero_fork.c:43
#define PAPI_ECMP
Definition: fpapi.h:109
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
void * Thread(void *arg)
long long PAPI_get_real_usec(void)
Definition: papi.c:6138
long long PAPI_get_real_cyc(void)
Definition: papi.c:6091
ssize_t retval
Definition: libasync.c:338
long long elapsed_us
Definition: zero_fork.c:43
void exit()

Here is the call graph for this function:

void Thread ( int  t,
int  n 
)

Definition at line 46 of file zero_smp.c.

47 {
48  int retval, num_tests = 1;
49  int EventSet1 = PAPI_NULL;
50  int PAPI_event, mask1;
51  int num_events1;
52  long long **values;
53  long long elapsed_us, elapsed_cyc;
55 
56  /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or
57  PAPI_TOT_INS, depending on the availability of the event on the
58  platform */
59  EventSet1 = add_two_events( &num_events1, &PAPI_event, &mask1 );
60 
61  retval = PAPI_event_code_to_name( PAPI_event, event_name );
62  if ( retval != PAPI_OK )
63  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
64 
65  values = allocate_test_space( num_tests, num_events1 );
66 
67  retval = PAPI_start( EventSet1 );
68  if ( retval != PAPI_OK )
69  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
70 
71  elapsed_us = PAPI_get_real_usec( );
72 
73  elapsed_cyc = PAPI_get_real_cyc( );
74 
75  do_flops( n );
76 
77  elapsed_us = PAPI_get_real_usec( ) - elapsed_us;
78 
79  elapsed_cyc = PAPI_get_real_cyc( ) - elapsed_cyc;
80 
81  retval = PAPI_stop( EventSet1, values[0] );
82  if ( retval != PAPI_OK )
83  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
84 
85  remove_test_events( &EventSet1, mask1 );
86 
87  if ( !TESTS_QUIET ) {
88  printf( "Thread %#x %-12s : \t%lld\n", t, event_name,
89  values[0][1] );
90  printf( "Thread %#x PAPI_TOT_CYC : \t%lld\n", t,
91  values[0][0] );
92  }
93 
94  free_test_space( values, num_tests );
95  if ( !TESTS_QUIET ) {
96  printf( "Thread %#x Real usec : \t%lld\n", t, elapsed_us );
97  printf( "Thread %#x Real cycles : \t%lld\n", t, elapsed_cyc );
98  }
100 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int mask1
Definition: zero_fork.c:41
int PAPI_event[2]
Definition: data_range.c:24
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
int num_events1
Definition: zero_fork.c:42
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
int TESTS_QUIET
Definition: test_utils.c:11
t
Definition: iozone.c:23562
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
long long elapsed_cyc
Definition: zero_fork.c:43
int add_two_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:680
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:131
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
int num_tests
Definition: zero_fork.c:46
void do_flops(int n)
Definition: multiplex.c:23
long long PAPI_get_real_usec(void)
Definition: papi.c:6138
int PAPI_unregister_thread(void)
Definition: papi.c:239
long long PAPI_get_real_cyc(void)
Definition: papi.c:6091
int PAPI_start(int EventSet)
Definition: papi.c:2026
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long elapsed_us
Definition: zero_fork.c:43
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:107
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:277
int EventSet1
Definition: zero_fork.c:40
int n
Definition: mendes-alt.c:164

Here is the call graph for this function: