PAPI 7.1.0.0
Loading...
Searching...
No Matches
pthread_hl.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <stdlib.h>
3#include <time.h>
4#include <pthread.h>
5#include "papi.h"
6#include "papi_test.h"
7#include "do_loops.h"
8
9#define NUM_THREADS 4
10
11typedef struct papi_args
12{
13 long tid;
14 int quiet;
16
17void *CallMatMul(void *args)
18{
19 long tid;
20 int retval, quiet;
21 char* region_name;
22
23 papi_args_t* papi_args = (papi_args_t*)args;
24 tid = (*papi_args).tid;
25 quiet = (*papi_args).quiet;
26 region_name = "do_flops";
27
28 if ( !quiet ) {
29 printf("\nThread %ld: instrument flops\n", tid);
30 }
31
32 retval = PAPI_hl_region_begin(region_name);
33 if ( retval != PAPI_OK ) {
34 test_fail( __FILE__, __LINE__, "PAPI_hl_region_begin", retval );
35 }
36
38
39 retval = PAPI_hl_region_end(region_name);
40 if ( retval != PAPI_OK ) {
41 test_fail( __FILE__, __LINE__, "PAPI_hl_region_end", retval );
42 }
43
44 pthread_exit(NULL);
45}
46
47int main( int argc, char **argv )
48{
49 pthread_t threads[NUM_THREADS];
51 int rc;
52 long t;
53 int quiet = 0;
54
55 /* Set TESTS_QUIET variable */
56 quiet = tests_quiet( argc, argv );
57
58 for( t = 0; t < NUM_THREADS; t++) {
59 args[t].tid = t;
60 args[t].quiet = quiet;
61 rc = pthread_create(&threads[t], NULL, CallMatMul, (void *)&args[t]);
62 if (rc) {
63 printf("ERROR; return code from pthread_create() is %d\n", rc);
64 exit(-1);
65 }
66 }
67
68 for( t = 0; t < NUM_THREADS; t++) {
69 pthread_join(threads[t], NULL);
70 }
71
72
73 for( t = 0; t < NUM_THREADS; t++) {
74 args[t].tid = t;
75 args[t].quiet = quiet;
76 rc = pthread_create(&threads[t], NULL, CallMatMul, (void *)&args[t]);
77 if (rc) {
78 printf("ERROR; return code from pthread_create() is %d\n", rc);
79 exit(-1);
80 }
81 }
82
83 for( t = 0; t < NUM_THREADS; t++) {
84 pthread_join(threads[t], NULL);
85 }
86
87 test_hl_pass( __FILE__ );
88
89 return 0;
90}
Read performance events at the beginning of a region.
Read performance events at the end of a region and store the difference to the corresponding beginnin...
#define PAPI_OK
Definition: f90papi.h:73
void do_flops(int n)
Definition: multiplex.c:23
Return codes and api definitions.
unsigned long int pthread_t
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_hl_pass(const char *filename)
Definition: test_utils.c:467
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
int main()
Definition: pernode.c:20
rc
Definition: pscanf.h:23
void * CallMatMul(void *args)
Definition: pthread_hl.c:17
#define NUM_THREADS
Definition: pthread_hl.c:9
int quiet
Definition: rapl_overflow.c:19
#define NUM_FLOPS
Definition: sdsc-mpx.c:24
int retval
Definition: zero_fork.c:53