75 test_fail( __FILE__, __LINE__,
"PAPI_get_component_info", 0 );
78 if ( cmpinfo->
attach == 0 ) {
80 "Platform does not support attaching", 0 );
109 if ( ptrace( PTRACE_ATTACH,
pid, NULL, NULL ) == -1 ) {
110 perror(
"ptrace(PTRACE_ATTACH)" );
113 if ( waitpid(
pid, &
status, 0 ) == -1 ) {
114 perror(
"waitpid()" );
117 if ( WIFSTOPPED(
status ) == 0 ) {
119 "Child process didnt return true to WIFSTOPPED", 0 );
122 if ( ptrace( PTRACE_ATTACH, pid2, NULL, NULL ) == -1 ) {
123 perror(
"ptrace(PTRACE_ATTACH)" );
126 if ( waitpid( pid2, &
status, 0 ) == -1 ) {
127 perror(
"waitpid()" );
130 if ( WIFSTOPPED(
status ) == 0 ) {
132 "Child process didnt return true to WIFSTOPPED", 0 );
147 sprintf( add_event_str,
"PAPI_add_event[%s]",
event_name );
161 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
162 perror(
"ptrace(PTRACE_CONT)" );
165 if ( waitpid(
pid, &
status, 0 ) == -1 ) {
166 perror(
"waitpid()" );
169 if ( WIFSTOPPED(
status ) == 0 ) {
171 "Child process didn't return true to WIFSTOPPED", 0 );
173 if ( WSTOPSIG(
status ) != SIGSTOP ) {
175 "Child process didn't stop on SIGSTOP", 0 );
178 if ( ptrace( PTRACE_CONT, pid2, NULL, NULL ) == -1 ) {
179 perror(
"ptrace(PTRACE_CONT)" );
182 if ( waitpid( pid2, &
status, 0 ) == -1 ) {
183 perror(
"waitpid()" );
186 if ( WIFSTOPPED(
status ) == 0 ) {
188 "Child process didn't return true to WIFSTOPPED", 0 );
190 if ( WSTOPSIG(
status ) != SIGSTOP ) {
192 "Child process didn't stop on SIGSTOP", 0 );
210 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
211 perror(
"ptrace(PTRACE_ATTACH)" );
214 if ( waitpid(
pid, &
status, 0 ) == -1 ) {
215 perror(
"waitpid()" );
218 if ( WIFSTOPPED(
status ) == 0 ) {
220 "Child process didn't return true to WIFSTOPPED", 0 );
222 if ( WSTOPSIG(
status ) != SIGSTOP ) {
224 "Child process didn't stop on SIGSTOP", 0 );
228 if ( ptrace( PTRACE_CONT, pid2, NULL, NULL ) == -1 ) {
229 perror(
"ptrace(PTRACE_ATTACH)" );
232 if ( waitpid( pid2, &
status, 0 ) == -1 ) {
233 perror(
"waitpid()" );
236 if ( WIFSTOPPED(
status ) == 0 ) {
238 "Child process didn't return true to WIFSTOPPED", 0 );
240 if ( WSTOPSIG(
status ) != SIGSTOP ) {
242 "Child process didn't stop on SIGSTOP", 0 );
254 printf(
"Warning: PAPI_stop returned error %d, probably ok.\n",
261 printf(
"Warning: PAPI_stop returned error %d, probably ok.\n",
271 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
272 perror(
"ptrace(PTRACE_CONT)" );
275 if ( ptrace( PTRACE_CONT, pid2, NULL, NULL ) == -1 ) {
276 perror(
"ptrace(PTRACE_CONT)" );
281 if ( waitpid(
pid, &
status, 0 ) == -1 ) {
282 perror(
"waitpid()" );
285 if ( WIFEXITED(
status ) == 0 ) {
287 "Child process didn't return true to WIFEXITED", 0 );
290 if ( waitpid( pid2, &
status, 0 ) == -1 ) {
291 perror(
"waitpid()" );
294 if ( WIFEXITED(
status ) == 0 ) {
296 "Child process didn't return true to WIFEXITED", 0 );
304 printf(
"Test case: multiple 3rd party attach start, stop.\n" );
305 printf(
"-----------------------------------------------\n" );
307 printf(
"Default domain is: %d (%s)\n",
tmp,
310 printf(
"Default granularity is: %d (%s)\n",
tmp,
312 printf(
"Using %d iterations of c += a*b\n",
NUM_FLOPS );
313 printf(
"-------------------------------------------------------------------------\n" );
315 sprintf( add_event_str,
"(PID %jd) %-12s : \t", ( intmax_t )
pid,
318 sprintf( add_event_str,
"(PID %jd) PAPI_TOT_CYC : \t",
321 sprintf( add_event_str,
"(PID %jd) %-12s : \t", ( intmax_t ) pid2,
324 sprintf( add_event_str,
"(PID %jd) PAPI_TOT_CYC : \t",
329 printf(
TAB1,
"Virt usec : \t", elapsed_virt_us );
330 printf(
TAB1,
"Virt cycles : \t", elapsed_virt_cyc );
332 printf(
"-------------------------------------------------------------------------\n" );
334 printf(
"Verification: pid %d results should be %dx pid %d\n",
345 printf(
"\tFLOPS ratio %lld/%lld = %lf\n",
349 double ratio1_high,ratio1_low,ratio2_high,ratio2_low;
354 if ((ratio1 > ratio1_high ) || (ratio1 < ratio1_low)) {
355 printf(
"Ratio out of range, should be ~%lf not %lf\n",
358 "Error: Counter ratio not two", 0 );
362 printf(
"\tCycles ratio %lld/%lld = %lf\n",
369 if ((ratio2 > ratio2_high ) || (ratio2 < ratio2_low )) {
370 printf(
"Ratio out of range, should be ~%lf, not %lf\n",
373 "Known issue: Counter ratio not two", 0 );
char event_name[2][PAPI_MAX_STR_LEN]
int PAPI_stop(int EventSet, long long *values)
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
void test_pass(const char *filename)
long long PAPI_get_virt_usec(void)
char * stringify_granularity(int granularity)
long long PAPI_get_virt_cyc(void)
void test_skip(const char *file, int line, const char *call, int retval)
int PAPI_library_init(int version)
char * stringify_all_domains(int domains)
unsigned int attach_must_ptrace
int PAPI_get_opt(int option, PAPI_option_t *ptr)
static int wait_for_attach_and_loop(int num)
int add_two_events(int *num_events, int *papi_event, int *mask)
long long PAPI_get_real_usec(void)
int tests_quiet(int argc, char **argv)
void test_fail(const char *file, int line, const char *call, int retval)
int PAPI_attach(int EventSet, unsigned long tid)
long long PAPI_get_real_cyc(void)
int PAPI_start(int EventSet)
static long long values[NUM_EVENTS]
long long ** allocate_test_space(int num_tests, int num_events)
int remove_test_events(int *EventSet, int mask)