PAPI 7.1.0.0
Loading...
Searching...
No Matches
Lib_With_Recorder.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <stdint.h>
3#include <stdlib.h>
4#include "sde_lib.h"
5
6static const char *event_names[1] = {
7 "simple_recording"
8};
9
10#define BRNG() {\
11 b = ((z1 << 6) ^ z1) >> 13;\
12 z1 = ((z1 & 4294967294U) << 18) ^ b;\
13 b = ((z2 << 2) ^ z2) >> 27;\
14 z2 = ((z2 & 4294967288U) << 2) ^ b;\
15 b = ((z3 << 13) ^ z3) >> 21;\
16 z3 = ((z3 & 4294967280U) << 7) ^ b;\
17 b = ((z4 << 3) ^ z4) >> 12;\
18 z4 = ((z4 & 4294967168U) << 13) ^ b;\
19 z1++;\
20 result = z1 ^ z2 ^ z3 ^ z4;\
21}
22volatile int result;
23volatile unsigned int b, z1, z2, z3, z4;
24
26
27// API functions.
28void recorder_init_(void);
29void recorder_do_work_(void);
30
31void recorder_init_(void){
32 papi_handle_t tmp_handle;
33
34 tmp_handle = papi_sde_init("Lib_With_Recorder");
36
37 z1=42;
38 z2=420;
39 z3=42000;
40 z4=424242;
41
42 return;
43}
44
46 long long r;
47 BRNG();
48 if( result < 0 )
49 result *= -1;
50 r = result%123456;
51 papi_sde_record(rcrd_handle, sizeof(r), &r);
52 return;
53}
54
55// Hook for papi_native_avail utility. No user code which links against this library should call
56// this function because it has the same name in all SDE-enabled libraries. papi_native_avail
57// uses dlopen and dlclose on each library so it only has one version of this symbol at a time.
59 papi_handle_t tmp_handle;
60 tmp_handle = fptr_struct->init("Lib_With_Recorder");
61 fptr_struct->create_recorder(tmp_handle, event_names[0], sizeof(long long), papi_sde_compare_long_long, &rcrd_handle);
62 return tmp_handle;
63}
#define BRNG()
volatile int result
papi_handle_t papi_sde_hook_list_events(papi_sde_fptr_struct_t *fptr_struct)
volatile unsigned int z1
static const char * event_names[1]
void recorder_init_(void)
void * rcrd_handle
volatile unsigned int b
volatile unsigned int z2
void recorder_do_work_(void)
volatile unsigned int z3
volatile unsigned int z4
papi_handle_t papi_sde_init(const char *name_of_library)
Definition: sde_lib.c:119
int papi_sde_compare_long_long(const void *p1, const void *p2)
Definition: sde_lib.c:1052
int papi_sde_create_recorder(papi_handle_t handle, const char *event_name, size_t typesize, int(*cmpr_func_ptr)(const void *p1, const void *p2), void **record_handle)
Definition: sde_lib.c:794
int papi_sde_record(void *record_handle, size_t typesize, const void *value)
Definition: sde_lib.c:909
SDE prototypes and macros.
void * papi_handle_t
Definition: sde_lib.h:100
int(* create_recorder)(papi_handle_t handle, const char *event_name, size_t typesize, int(*cmpr_func_ptr)(const void *p1, const void *p2), void **record_handle)
Definition: sde_lib.h:112
papi_handle_t(* init)(const char *lib_name)
Definition: sde_lib.h:103