PAPI 7.1.0.0
Loading...
Searching...
No Matches
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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 107 of file zero_smp.c.

108{
109 int i, retval, quiet;
110 long long elapsed_us, elapsed_cyc;
111
112 /* Set TESTS_QUIET variable */
113 quiet=tests_quiet( argc, argv );
114
116 if ( retval != PAPI_VER_CURRENT ) {
117 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
118 }
119
121
123
124#if defined(_AIX) || defined(__linux__)
125 retval =
126 PAPI_thread_init( ( unsigned long ( * )( void ) ) ( pthread_self ) );
127 if ( retval != PAPI_OK ) {
128 if ( retval == PAPI_ECMP )
129 test_skip( __FILE__, __LINE__, "PAPI_thread_init", retval );
130 else
131 test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
132 }
133#if defined(_AIX)
134#pragma ibm parallel_loop
135#endif
136
137#elif defined(sgi) && defined(mips)
138 retval =
139 PAPI_thread_init( ( unsigned long ( * )( void ) ) ( mp_my_threadnum ) );
140 if ( retval != PAPI_OK ) {
141 test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
142 }
143#pragma parallel
144#pragma local(i)
145#pragma pfor
146#elif defined(sun) && defined(sparc)
147 retval = PAPI_thread_init( ( unsigned long ( * )( void ) ) ( thr_self ) );
148 if ( retval != PAPI_OK ) {
149 test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
150 }
151#pragma MP taskloop private(i)
152#else
153 if (!quiet) {
154 printf("This test only runs on AIX/IRIX/SOLOARIS\n");
155 }
156 test_skip(__FILE__, __LINE__, "Architecture not included in this test file yet.", 0);
157#endif
158 for ( i = 1; i < 3; i++ ) {
159 Thread( i, 10000000 * i );
160 }
161
163
165
166 if ( !quiet ) {
167 printf( "Master real usec : \t%lld\n", elapsed_us );
168 printf( "Master real cycles : \t%lld\n", elapsed_cyc );
169 }
170
171 // FIXME: we don't really validate anything here
172
173 test_pass( __FILE__ );
174
175 return 0;
176}
int i
get real time counter value in clock cycles Returns the total real time passed since some arbitrary s...
get real time counter value in microseconds
initialize the PAPI library.
Initialize thread support in the PAPI library.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_ECMP
Definition: f90papi.h:214
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int quiet
Definition: rapl_overflow.c:19
long long elapsed_cyc
Definition: zero_fork.c:50
long long elapsed_us
Definition: zero_fork.c:50
int retval
Definition: zero_fork.c:53
void Thread(int t, int n)
Definition: zero_smp.c:50
Here is the call graph for this function:

◆ Thread()

void Thread ( int  t,
int  n 
)

Definition at line 50 of file zero_smp.c.

51{
52 int retval, num_tests = 1;
53 int EventSet1 = PAPI_NULL;
54 int PAPI_event, mask1;
55 int num_events1;
56 long long **values;
57 long long elapsed_us, elapsed_cyc;
59
60 /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or
61 PAPI_TOT_INS, depending on the availability of the event on the
62 platform */
64
66 if ( retval != PAPI_OK )
67 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
68
70
72 if ( retval != PAPI_OK )
73 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
74
76
78
79 do_flops( n );
80
82
84
86 if ( retval != PAPI_OK )
87 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
88
90
91 if ( !TESTS_QUIET ) {
92 printf( "Thread %#x %-12s : \t%lld\n", t, event_name,
93 values[0][1] );
94 printf( "Thread %#x PAPI_TOT_CYC : \t%lld\n", t,
95 values[0][0] );
96 }
97
99 if ( !TESTS_QUIET ) {
100 printf( "Thread %#x Real usec : \t%lld\n", t, elapsed_us );
101 printf( "Thread %#x Real cycles : \t%lld\n", t, elapsed_cyc );
102 }
104}
Convert a numeric hardware event code to a name.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
Notify PAPI that a thread has 'disappeared'.
int PAPI_event[2]
Definition: data_range.c:30
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void do_flops(int n)
Definition: multiplex.c:23
int TESTS_QUIET
Definition: test_utils.c:18
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:70
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:46
int add_two_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:640
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:201
int EventSet1
Definition: zero_fork.c:47
int num_events1
Definition: zero_fork.c:49
int mask1
Definition: zero_fork.c:48
int num_tests
Definition: zero_fork.c:53
Here is the call graph for this function:
Here is the caller graph for this function: