36{
37 int j;
40 int ret;
41 long nthr;
42
44
47 test_fail( __FILE__, __LINE__,
"PAPI_library_init", ret );
48
49 if ( ( ret =
51 long ( * )( void ) ) ( pthread_self ) ) ) !=
53 test_fail( __FILE__, __LINE__,
"PAPI_thread_init", ret );
54
55 pthread_attr_init( &attr );
56#ifdef PTHREAD_CREATE_UNDETACHED
57 pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_UNDETACHED );
58#endif
59#ifdef PTHREAD_SCOPE_SYSTEM
60 ret = pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM );
61 if ( ret != 0 )
62 test_skip( __FILE__, __LINE__,
"pthread_attr_setscope", ret );
63
64#endif
65
67
69 printf( "Creating %d threads for %d iterations each of:\n",
70 ( int ) nthr, 1 );
71 printf( "\tregister\n" );
72 printf( "\tcreate_eventset\n" );
73 printf( "\tdestroy_eventset\n" );
74 printf( "\tunregister\n" );
75 }
77 if ( th == NULL )
79
80 for ( j = 0; j < nthr; j++ ) {
81 ret = pthread_create( &th[j], &attr, &
Thread, NULL );
82 if ( ret ) {
83 printf( "Failed to create thread: %d\n", j );
84 if ( j < 10 ) {
85 free(th);
87 }
88 printf( "Continuing test with %d threads.\n", j - 1 );
89 nthr = j - 1;
91 ( size_t ) nthr *
93 break;
94 }
95 }
96
97 for ( j = 0; j < nthr; j++ ) {
98 pthread_join( th[j], NULL );
99 }
100
101 free(th);
103
104 return 0;
105}
initialize the PAPI library.
Initialize thread support in the PAPI library.
unsigned long int pthread_t
int tests_quiet(int argc, char **argv)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
void * Thread(void *data)