PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
papi_vector.c
Go to the documentation of this file.
1 /*
2  * File: papi_vector.c
3  * Author: Kevin London
4  * london@cs.utk.edu
5  * Mods: Haihang You
6  * you@cs.utk.edu
7  * Mods: <Your name here>
8  * <Your email here>
9  */
10 
11 #include "papi.h"
12 #include "papi_internal.h"
13 #include "papi_vector.h"
14 #include "papi_memory.h"
15 
16 #include <string.h>
17 
18 #ifdef _AIX
19 
20 /* needed because the get_virt_usec() code uses a hardware context */
21 /* which is a pmapi definition on AIX. */
22 #include <pmapi.h>
23 #endif
24 
25 
26 void
28 {
29  SUBDBG( "function is not implemented in the component!\n" );
30  exit( PAPI_ECMP );
31 }
32 
33 int
35 {
36  return PAPI_OK;
37 }
38 
39 int
41 {
42  return 1;
43 }
44 
45 int
47 {
48  return PAPI_ECMP;
49 }
50 
51 void *
53 {
54  return NULL;
55 }
56 
57 void
59 {
60  return;
61 }
62 
63 long long
65 {
66  return PAPI_ECMP;
67 }
68 
69 long long
71 {
72  (void) ignored;
73 
74  return PAPI_ECMP;
75 }
76 
77 char *
79 {
80  return NULL;
81 }
82 
83 long
85 {
86  return PAPI_ECMP;
87 }
88 
89 long long vec_virt_cycles(void)
90 {
91  return ((long long) _papi_os_vector.get_virt_usec() *
93 }
94 
95 long long vec_real_nsec_dummy(void)
96 {
97  return ((long long) _papi_os_vector.get_real_usec() * 1000);
98 
99 }
100 
101 long long vec_virt_nsec_dummy(void)
102 {
103  return ((long long) _papi_os_vector.get_virt_usec() * 1000);
104 
105 }
106 
107 
108 int
110 {
111  if ( !v )
112  return ( PAPI_EINVAL );
113 
114  /* component function pointers */
115  if ( !v->dispatch_timer )
116  v->dispatch_timer =
117  ( void ( * )( int, hwd_siginfo_t *, void * ) ) vec_void_dummy;
118  if ( !v->get_overflow_address )
120  ( void *( * )( int, char *, int ) ) vec_void_star_dummy;
121  if ( !v->start )
122  v->start = ( int ( * )( hwd_context_t *, hwd_control_state_t * ) )
124  if ( !v->stop )
125  v->stop = ( int ( * )( hwd_context_t *, hwd_control_state_t * ) )
127  if ( !v->read )
128  v->read = ( int ( * )
129  ( hwd_context_t *, hwd_control_state_t *, long long **,
130  int ) ) vec_int_dummy;
131  if ( !v->reset )
132  v->reset = ( int ( * )( hwd_context_t *, hwd_control_state_t * ) )
134  if ( !v->write )
135  v->write =
136  ( int ( * )( hwd_context_t *, hwd_control_state_t *, long long[] ) )
138  if ( !v->cleanup_eventset )
139  v->cleanup_eventset = ( int ( * )( hwd_control_state_t * ) ) vec_int_ok_dummy;
140  if ( !v->stop_profiling )
141  v->stop_profiling =
142  ( int ( * )( ThreadInfo_t *, EventSetInfo_t * ) ) vec_int_dummy;
143  if ( !v->init_component )
144  v->init_component = ( int ( * )( int ) ) vec_int_ok_dummy;
145  if ( !v->init_thread )
146  v->init_thread = ( int ( * )( hwd_context_t * ) ) vec_int_ok_dummy;
147  if ( !v->init_control_state )
148  v->init_control_state =
149  ( int ( * )( hwd_control_state_t * ptr ) ) vec_void_dummy;
150  if ( !v->update_control_state )
151  v->update_control_state = ( int ( * )
152  ( hwd_control_state_t *, NativeInfo_t *,
154  if ( !v->ctl )
155  v->ctl = ( int ( * )( hwd_context_t *, int, _papi_int_option_t * ) )
157  if ( !v->set_overflow )
158  v->set_overflow =
159  ( int ( * )( EventSetInfo_t *, int, int ) ) vec_int_dummy;
160  if ( !v->set_profile )
161  v->set_profile =
162  ( int ( * )( EventSetInfo_t *, int, int ) ) vec_int_dummy;
163 
164  if ( !v->set_domain )
165  v->set_domain =
166  ( int ( * )( hwd_control_state_t *, int ) ) vec_int_dummy;
167  if ( !v->ntv_enum_events )
168  v->ntv_enum_events = ( int ( * )( unsigned int *, int ) ) vec_int_dummy;
169  if ( !v->ntv_name_to_code )
170  v->ntv_name_to_code =
171  ( int ( * )( char *, unsigned int * ) ) vec_int_dummy;
172  if ( !v->ntv_code_to_name )
173  v->ntv_code_to_name =
174  ( int ( * )( unsigned int, char *, int ) ) vec_int_dummy;
175  if ( !v->ntv_code_to_descr )
176  v->ntv_code_to_descr =
177  ( int ( * )( unsigned int, char *, int ) ) vec_int_ok_dummy;
178  if ( !v->ntv_code_to_bits )
179  v->ntv_code_to_bits =
180  ( int ( * )( unsigned int, hwd_register_t * ) ) vec_int_dummy;
181  if ( !v->ntv_code_to_info )
182  v->ntv_code_to_info =
183  ( int ( * )( unsigned int, PAPI_event_info_t * ) ) vec_int_dummy;
184 
185  if ( !v->allocate_registers )
186  v->allocate_registers =
187  ( int ( * )( EventSetInfo_t * ) ) vec_int_ok_dummy;
188 
189  if ( !v->shutdown_thread )
190  v->shutdown_thread = ( int ( * )( hwd_context_t * ) ) vec_int_dummy;
191  if ( !v->shutdown_component )
192  v->shutdown_component = ( int ( * )( void ) ) vec_int_ok_dummy;
193  if ( !v->user )
194  v->user = ( int ( * )( int, void *, void * ) ) vec_int_dummy;
195  return PAPI_OK;
196 }
197 
198 
199 int
201 {
202  if ( !v )
203  return ( PAPI_EINVAL );
204 
205  if ( !v->get_real_cycles )
207  if ( !v->get_real_usec )
209  if ( !v->get_real_nsec )
211  if ( !v->get_virt_cycles )
213  if ( !v->get_virt_usec )
215  if ( !v->get_virt_nsec )
217 
218  if ( !v->update_shlib_info )
219  v->update_shlib_info = ( int ( * )( papi_mdi_t * ) ) vec_int_dummy;
220  if ( !v->get_system_info )
221  v->get_system_info = ( int ( * )( ) ) vec_int_dummy;
222 
223  if ( !v->get_memory_info )
224  v->get_memory_info =
225  ( int ( * )( PAPI_hw_info_t *, int ) ) vec_int_dummy;
226 
227  if ( !v->get_dmem_info )
228  v->get_dmem_info = ( int ( * )( PAPI_dmem_info_t * ) ) vec_int_dummy;
229 
230  return PAPI_OK;
231 }
232 
233 /* not used? debug only? */
234 #if 0
235 static void *
236 vector_find_dummy( void *func, char **buf )
237 {
238  void *ptr = NULL;
239 
240  if ( vec_int_ok_dummy == ( int ( * )( ) ) func ) {
241  ptr = ( void * ) vec_int_ok_dummy;
242  if ( buf != NULL )
243  *buf = papi_strdup( "vec_int_ok_dummy" );
244  } else if ( vec_int_one_dummy == ( int ( * )( ) ) func ) {
245  ptr = ( void * ) vec_int_one_dummy;
246  if ( buf != NULL )
247  *buf = papi_strdup( "vec_int_one_dummy" );
248  } else if ( vec_int_dummy == ( int ( * )( ) ) func ) {
249  ptr = ( void * ) vec_int_dummy;
250  if ( buf != NULL )
251  *buf = papi_strdup( "vec_int_dummy" );
252  } else if ( vec_void_dummy == ( void ( * )( ) ) func ) {
253  ptr = ( void * ) vec_void_dummy;
254  if ( buf != NULL )
255  *buf = papi_strdup( "vec_void_dummy" );
256  } else if ( vec_void_star_dummy == ( void *( * )( ) ) func ) {
257  ptr = ( void * ) vec_void_star_dummy;
258  if ( buf != NULL )
259  *buf = papi_strdup( "vec_void_star_dummy" );
260  } else if ( vec_long_long_dummy == ( long long ( * )( ) ) func ) {
261  ptr = ( void * ) vec_long_long_dummy;
262  if ( buf != NULL )
263  *buf = papi_strdup( "vec_long_long_dummy" );
264  } else if ( vec_char_star_dummy == ( char *( * )( ) ) func ) {
265  ptr = ( void * ) vec_char_star_dummy;
266  *buf = papi_strdup( "vec_char_star_dummy" );
267  } else if ( vec_long_dummy == ( long ( * )( ) ) func ) {
268  ptr = ( void * ) vec_long_dummy;
269  if ( buf != NULL )
270  *buf = papi_strdup( "vec_long_dummy" );
271  } else {
272  ptr = NULL;
273  }
274  return ( ptr );
275 }
276 
277 
278 static void
279 vector_print_routine( void *func, char *fname, int pfunc )
280 {
281  void *ptr = NULL;
282  char *buf = NULL;
283 
284  ptr = vector_find_dummy( func, &buf );
285  if ( ptr ) {
286  printf( "DUMMY: %s is mapped to %s.\n",
287  fname, buf );
288  papi_free( buf );
289  } else if ( ( !ptr && pfunc ) )
290  printf( "function: %s is mapped to %p.\n",
291  fname, func );
292 }
293 
294 static void
295 vector_print_table( papi_vector_t * v, int print_func )
296 {
297 
298  if ( !v )
299  return;
300 
301  vector_print_routine( ( void * ) v->dispatch_timer,
302  "_papi_hwd_dispatch_timer", print_func );
303  vector_print_routine( ( void * ) v->get_overflow_address,
304  "_papi_hwd_get_overflow_address", print_func );
305  vector_print_routine( ( void * ) v->start, "_papi_hwd_start", print_func );
306  vector_print_routine( ( void * ) v->stop, "_papi_hwd_stop", print_func );
307  vector_print_routine( ( void * ) v->read, "_papi_hwd_read", print_func );
308  vector_print_routine( ( void * ) v->reset, "_papi_hwd_reset", print_func );
309  vector_print_routine( ( void * ) v->write, "_papi_hwd_write", print_func );
310  vector_print_routine( ( void * ) v->cleanup_eventset,
311  "_papi_hwd_cleanup_eventset", print_func );
312 
313  vector_print_routine( ( void * ) v->stop_profiling,
314  "_papi_hwd_stop_profiling", print_func );
315  vector_print_routine( ( void * ) v->init_component,
316  "_papi_hwd_init_component", print_func );
317  vector_print_routine( ( void * ) v->init_thread, "_papi_hwd_init_thread", print_func );
318  vector_print_routine( ( void * ) v->init_control_state,
319  "_papi_hwd_init_control_state", print_func );
320  vector_print_routine( ( void * ) v->ctl, "_papi_hwd_ctl", print_func );
321  vector_print_routine( ( void * ) v->set_overflow, "_papi_hwd_set_overflow",
322  print_func );
323  vector_print_routine( ( void * ) v->set_profile, "_papi_hwd_set_profile",
324  print_func );
325  vector_print_routine( ( void * ) v->set_domain, "_papi_hwd_set_domain",
326  print_func );
327  vector_print_routine( ( void * ) v->ntv_enum_events,
328  "_papi_hwd_ntv_enum_events", print_func );
329  vector_print_routine( ( void * ) v->ntv_name_to_code,
330  "_papi_hwd_ntv_name_to_code", print_func );
331  vector_print_routine( ( void * ) v->ntv_code_to_name,
332  "_papi_hwd_ntv_code_to_name", print_func );
333  vector_print_routine( ( void * ) v->ntv_code_to_descr,
334  "_papi_hwd_ntv_code_to_descr", print_func );
335  vector_print_routine( ( void * ) v->ntv_code_to_bits,
336  "_papi_hwd_ntv_code_to_bits", print_func );
337  vector_print_routine( ( void * ) v->ntv_code_to_info,
338  "_papi_hwd_ntv_code_to_info", print_func );
339 
340  vector_print_routine( ( void * ) v->allocate_registers,
341  "_papi_hwd_allocate_registers", print_func );
342 
343  vector_print_routine( ( void * ) v->shutdown_thread, "_papi_hwd_shutdown_thread",
344  print_func );
345  vector_print_routine( ( void * ) v->shutdown_component,
346  "_papi_hwd_shutdown_component", print_func );
347  vector_print_routine( ( void * ) v->user, "_papi_hwd_user", print_func );
348 }
349 
350 #endif
long long(* get_real_nsec)(void)
Definition: papi_vector.h:65
int _papi_hwi_innoculate_os_vector(papi_os_vector_t *v)
Definition: papi_vector.c:200
int vec_int_one_dummy()
Definition: papi_vector.c:40
Hardware info structure.
Definition: papi.h:775
int(* ntv_code_to_name)(unsigned int, char *, int)
Definition: papi_vector.h:45
#define papi_free(a)
Definition: papi_memory.h:35
int(* read)(hwd_context_t *, hwd_control_state_t *, long long **, int)
Definition: papi_vector.h:30
char * vec_char_star_dummy()
Definition: papi_vector.c:78
long long(* get_real_usec)(void)
Definition: papi_vector.h:63
int(* init_control_state)(hwd_control_state_t *ptr)
Definition: papi_vector.h:37
int vec_int_ok_dummy()
Definition: papi_vector.c:34
int(* update_shlib_info)(papi_mdi_t *mdi)
Definition: papi_vector.h:67
return PAPI_OK
Definition: linux-nvml.c:458
#define papi_strdup(a)
Definition: papi_memory.h:39
void(* func[])()
Definition: iozone.c:1198
long long(* get_virt_usec)(void)
Definition: papi_vector.h:64
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define printf
Definition: papi_test.h:125
long long(* get_real_cycles)(void)
Definition: papi_vector.h:61
Return codes and api definitions.
int(* shutdown_thread)(hwd_context_t *)
Definition: papi_vector.h:53
void *(* get_overflow_address)(int, char *, int)
Definition: papi_vector.h:27
int(* shutdown_component)(void)
Definition: papi_vector.h:54
int(* user)(int, void *, void *)
Definition: papi_vector.h:55
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
int(* stop_profiling)(ThreadInfo_t *, EventSetInfo_t *)
Definition: papi_vector.h:34
char buf[200]
Definition: iozone.c:19609
A pointer to the following is passed to PAPI_get_dmem_info()
Definition: papi.h:866
long long vec_virt_cycles(void)
Definition: papi_vector.c:89
int(* write)(hwd_context_t *, hwd_control_state_t *, long long[])
Definition: papi_vector.h:32
int vec_int_dummy()
Definition: papi_vector.c:46
#define PAPI_ECMP
Definition: fpapi.h:109
long long vec_real_nsec_dummy(void)
Definition: papi_vector.c:95
int(* start)(hwd_context_t *, hwd_control_state_t *)
Definition: papi_vector.h:28
int(* ntv_code_to_bits)(unsigned int, hwd_register_t *)
Definition: papi_vector.h:47
void vec_void_dummy()
Definition: papi_vector.c:58
int(* reset)(hwd_context_t *, hwd_control_state_t *)
Definition: papi_vector.h:31
void _vectors_error()
Definition: papi_vector.c:27
int _papi_hwi_innoculate_vector(papi_vector_t *v)
Definition: papi_vector.c:109
int(* allocate_registers)(EventSetInfo_t *)
Definition: papi_vector.h:49
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int(* ntv_code_to_info)(unsigned int, PAPI_event_info_t *)
Definition: papi_vector.h:48
int(* ctl)(hwd_context_t *, int, _papi_int_option_t *)
Definition: papi_vector.h:39
long long(* get_virt_nsec)(void)
Definition: papi_vector.h:66
long long vec_virt_nsec_dummy(void)
Definition: papi_vector.c:101
int(* set_domain)(hwd_control_state_t *, int)
Definition: papi_vector.h:42
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
PAPI_hw_info_t hw_info
int(* get_system_info)(papi_mdi_t *mdi)
Definition: papi_vector.h:68
int(* stop)(hwd_context_t *, hwd_control_state_t *)
Definition: papi_vector.h:29
int(* cleanup_eventset)(hwd_control_state_t *)
Definition: papi_vector.h:33
long vec_long_dummy()
Definition: papi_vector.c:84
int(* ntv_enum_events)(unsigned int *, int)
Definition: papi_vector.h:43
long long(* get_virt_cycles)(void)
Definition: papi_vector.h:62
int cpu_max_mhz
Definition: papi.h:791
int
Definition: iozone.c:18528
int(* update_control_state)(hwd_control_state_t *, NativeInfo_t *, int, hwd_context_t *)
Definition: papi_vector.h:38
int(* ntv_name_to_code)(char *, unsigned int *)
Definition: papi_vector.h:44
long long vec_long_long_dummy()
Definition: papi_vector.c:64
long long vec_long_long_context_dummy(hwd_context_t *ignored)
Definition: papi_vector.c:70
int(* ntv_code_to_descr)(unsigned int, char *, int)
Definition: papi_vector.h:46
int(* init_thread)(hwd_context_t *)
Definition: papi_vector.h:36
int(* set_profile)(EventSetInfo_t *, int, int)
Definition: papi_vector.h:41
int(* get_dmem_info)(PAPI_dmem_info_t *)
Definition: papi_vector.h:70
void(* dispatch_timer)(int, hwd_siginfo_t *, void *)
Definition: papi_vector.h:26
int(* get_memory_info)(PAPI_hw_info_t *, int)
Definition: papi_vector.h:69
void exit()
int(* init_component)(int)
Definition: papi_vector.h:35
int(* set_overflow)(EventSetInfo_t *, int, int)
Definition: papi_vector.h:40
void * vec_void_star_dummy()
Definition: papi_vector.c:52
char * ptr
Definition: iozone.c:23586