PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
linux-NWunit.c File Reference

This file has the source code for a component that enables PAPI-C to access hardware monitoring counters for BG/Q through the bgpm library. More...

Include dependency graph for linux-NWunit.c:

Go to the source code of this file.

Functions

int NWUNIT_init_thread (hwd_context_t *ctx)
 
int NWUNIT_init_component (int cidx)
 
int NWUNIT_init_control_state (hwd_control_state_t *ptr)
 
int NWUNIT_start (hwd_context_t *ctx, hwd_control_state_t *ptr)
 
int NWUNIT_stop (hwd_context_t *ctx, hwd_control_state_t *ptr)
 
int NWUNIT_read (hwd_context_t *ctx, hwd_control_state_t *ptr, long_long **events, int flags)
 
int NWUNIT_shutdown_thread (hwd_context_t *ctx)
 
int NWUNIT_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
int NWUNIT_update_control_state (hwd_control_state_t *ptr, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
int NWUNIT_set_domain (hwd_control_state_t *cntrl, int domain)
 
int NWUNIT_reset (hwd_context_t *ctx, hwd_control_state_t *ptr)
 
int NWUNIT_cleanup_eventset (hwd_control_state_t *ctrl)
 
int NWUNIT_ntv_enum_events (unsigned int *EventCode, int modifier)
 
int NWUNIT_ntv_name_to_code (char *name, unsigned int *event_code)
 
int NWUNIT_ntv_code_to_name (unsigned int EventCode, char *name, int len)
 
int NWUNIT_ntv_code_to_descr (unsigned int EventCode, char *name, int len)
 
int NWUNIT_ntv_code_to_bits (unsigned int EventCode, hwd_register_t *bits)
 

Variables

papi_vector_t _NWunit_vector
 

Detailed Description

Author
Heike Jagode jagod.nosp@m.e@ee.nosp@m.cs.ut.nosp@m.k.ed.nosp@m.u Mods: < your name here > < your email address > BGPM / NWunit component

Tested version of bgpm (early access)

Definition in file linux-NWunit.c.

Function Documentation

int NWUNIT_cleanup_eventset ( hwd_control_state_t ctrl)

Definition at line 310 of file linux-NWunit.c.

311 {
312 #ifdef DEBUG_BGQ
313  printf( "NWUNIT_cleanup_eventset\n" );
314 #endif
315  int retval;
316 
317  NWUNIT_control_state_t * this_state = ( NWUNIT_control_state_t * ) ctrl;
318 
319  // create a new empty bgpm eventset
320  // reason: bgpm doesn't permit to remove events from an eventset;
321  // hence we delete the old eventset and create a new one
322  retval = _common_deleteRecreate( &this_state->EventGroup ); // HJ try to use delete() only
323  if ( retval < 0 ) return retval;
324 
325  return ( PAPI_OK );
326 }
int _common_deleteRecreate(int *EventGroup_ptr)
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int NWUNIT_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)

Definition at line 185 of file linux-NWunit.c.

186 {
187 #ifdef DEBUG_BGQ
188  printf( "NWUNIT_ctl\n" );
189 #endif
190 
191  ( void ) ctx;
192  ( void ) code;
193  ( void ) option;
194  return ( PAPI_OK );
195 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
int NWUNIT_init_component ( int  cidx)

Definition at line 49 of file linux-NWunit.c.

50 {
51 #ifdef DEBUG_BGQ
52  printf( "NWUNIT_init_component\n" );
53 #endif
54 
56 #ifdef DEBUG_BGQ
57  printf( "NWUNIT_init_component cidx = %d\n", cidx );
58 #endif
59 
60  return ( PAPI_OK );
61 }
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
#define printf
Definition: papi_test.h:125
static int cidx
Definition: event_info.c:40
papi_vector_t _NWunit_vector
Definition: linux-NWunit.c:23
int NWUNIT_init_control_state ( hwd_control_state_t ptr)

Definition at line 69 of file linux-NWunit.c.

70 {
71 #ifdef DEBUG_BGQ
72  printf( "NWUNIT_init_control_state\n" );
73 #endif
74  int retval;
75 
76  NWUNIT_control_state_t * this_state = ( NWUNIT_control_state_t * ) ptr;
77 
78  this_state->EventGroup = Bgpm_CreateEventSet();
79  retval = _check_BGPM_error( this_state->EventGroup, "Bgpm_CreateEventSet" );
80  if ( retval < 0 ) return retval;
81 
82  return PAPI_OK;
83 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int NWUNIT_init_thread ( hwd_context_t ctx)

Definition at line 33 of file linux-NWunit.c.

34 {
35 #ifdef DEBUG_BGQ
36  printf( "NWUNIT_init_thread\n" );
37 #endif
38 
39  ( void ) ctx;
40  return PAPI_OK;
41 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
int NWUNIT_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
)

Definition at line 447 of file linux-NWunit.c.

448 {
449 #ifdef DEBUG_BGQ
450  printf( "NWUNIT_ntv_code_to_bits\n" );
451 #endif
452  ( void ) EventCode;
453  ( void ) bits;
454  return ( PAPI_OK );
455 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
int NWUNIT_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 426 of file linux-NWunit.c.

427 {
428 #ifdef DEBUG_BGQ
429  //printf( "NWUNIT_ntv_code_to_descr\n" );
430 #endif
431  int retval, index;
432 
433  index = ( EventCode ) + OFFSET;
434 
435  retval = Bgpm_GetLongDesc( index, name, &len );
436  retval = _check_BGPM_error( retval, "Bgpm_GetLongDesc" );
437  if ( retval < 0 ) return retval;
438 
439  return ( PAPI_OK );
440 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
#define OFFSET
Definition: linux-CNKunit.h:36
char * name
Definition: iozone.c:23648
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int NWUNIT_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 397 of file linux-NWunit.c.

398 {
399 #ifdef DEBUG_BGQ
400  //printf( "NWUNIT_ntv_code_to_name\n" );
401 #endif
402  int index;
403 
404  index = ( EventCode ) + OFFSET;
405 
406  if ( index >= MAX_COUNTERS )
407  return PAPI_ENOEVNT;
408 
409  strncpy( name, Bgpm_GetEventIdLabel( index ), len );
410 
411  if ( name == NULL ) {
412 #ifdef DEBUG_BGPM
413  printf ("Error: ret value is NULL for BGPM API function Bgpm_GetEventIdLabel.\n" );
414 #endif
415  return PAPI_ENOEVNT;
416  }
417 
418  return ( PAPI_OK );
419 }
#define PAPI_ENOEVNT
Definition: fpapi.h:112
#define MAX_COUNTERS
Definition: perfctr-x86.h:8
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
#define OFFSET
Definition: linux-CNKunit.h:36
char * name
Definition: iozone.c:23648
int NWUNIT_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)

Definition at line 333 of file linux-NWunit.c.

334 {
335  //printf( "NWUNIT_ntv_enum_events\n" );
336 
337  switch ( modifier ) {
338  case PAPI_ENUM_FIRST:
339  *EventCode = 0;
340 
341  return ( PAPI_OK );
342  break;
343 
344  case PAPI_ENUM_EVENTS:
345  {
346  int index = ( *EventCode ) + OFFSET;
347 
348  if ( index < NWUNIT_MAX_COUNTERS ) {
349  *EventCode = *EventCode + 1;
350  return ( PAPI_OK );
351  } else
352  return ( PAPI_ENOEVNT );
353 
354  break;
355  }
356  default:
357  return ( PAPI_EINVAL );
358  }
359  return ( PAPI_EINVAL );
360 }
#define PAPI_ENOEVNT
Definition: fpapi.h:112
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define NWUNIT_MAX_COUNTERS
Definition: linux-NWunit.h:35
#define OFFSET
Definition: linux-CNKunit.h:36
int NWUNIT_ntv_name_to_code ( char *  name,
unsigned int event_code 
)

Definition at line 367 of file linux-NWunit.c.

368 {
369 #ifdef DEBUG_BGQ
370  printf( "NWUNIT_ntv_name_to_code\n" );
371 #endif
372  int ret;
373 
374  /* Return event id matching a given event label string */
375  ret = Bgpm_GetEventIdFromLabel ( name );
376 
377  if ( ret <= 0 ) {
378 #ifdef DEBUG_BGPM
379  printf ("Error: ret value is %d for BGPM API function '%s'.\n",
380  ret, "Bgpm_GetEventIdFromLabel" );
381 #endif
382  return PAPI_ENOEVNT;
383  }
384  else if ( ret < OFFSET || ret > NWUNIT_MAX_COUNTERS ) // not a NWUnit event
385  return PAPI_ENOEVNT;
386  else
387  *event_code = ( ret - OFFSET ) ;
388 
389  return PAPI_OK;
390 }
#define PAPI_ENOEVNT
Definition: fpapi.h:112
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
#define NWUNIT_MAX_COUNTERS
Definition: linux-NWunit.h:35
long long ret
Definition: iozone.c:1346
#define OFFSET
Definition: linux-CNKunit.h:36
char * name
Definition: iozone.c:23648
int NWUNIT_read ( hwd_context_t ctx,
hwd_control_state_t ptr,
long_long **  events,
int  flags 
)

Definition at line 137 of file linux-NWunit.c.

139 {
140 #ifdef DEBUG_BGQ
141  printf( "NWUNIT_read\n" );
142 #endif
143  ( void ) ctx;
144  ( void ) flags;
145  int i, numEvts;
146  NWUNIT_control_state_t * this_state = ( NWUNIT_control_state_t * ) ptr;
147 
148  numEvts = Bgpm_NumEvents( this_state->EventGroup );
149  if ( numEvts == 0 ) {
150 #ifdef DEBUG_BGPM
151  printf ("Error: ret value is %d for BGPM API function Bgpm_NumEvents.\n", numEvts );
152 #endif
153  //return ( EXIT_FAILURE );
154  }
155 
156  for ( i = 0; i < numEvts; i++ )
157  this_state->counts[i] = _common_getEventValue( i, this_state->EventGroup );
158 
159  *events = this_state->counts;
160 
161  return ( PAPI_OK );
162 }
long long flags
Definition: iozone.c:12330
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
int i
Definition: fileop.c:140
char events[MAX_EVENTS][BUFSIZ]
long_long _common_getEventValue(unsigned event_id, int EventGroup)
long long counts[NWUNIT_MAX_COUNTERS]
Definition: linux-NWunit.h:57

Here is the call graph for this function:

int NWUNIT_reset ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 279 of file linux-NWunit.c.

280 {
281 #ifdef DEBUG_BGQ
282  printf( "NWUNIT_reset\n" );
283 #endif
284  ( void ) ctx;
285  int retval;
286  NWUNIT_control_state_t * this_state = ( NWUNIT_control_state_t * ) ptr;
287 
288  /* we can't simply call Bgpm_Reset() since PAPI doesn't have the
289  restriction that an EventSet has to be stopped before resetting is
290  possible. However, BGPM does have this restriction.
291  Hence we need to stop, reset and start */
292  retval = Bgpm_Stop( this_state->EventGroup );
293  retval = _check_BGPM_error( retval, "Bgpm_Stop" );
294  if ( retval < 0 ) return retval;
295 
296  retval = Bgpm_ResetStart( this_state->EventGroup );
297  retval = _check_BGPM_error( retval, "Bgpm_ResetStart" );
298  if ( retval < 0 ) return retval;
299 
300  return ( PAPI_OK );
301 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int NWUNIT_set_domain ( hwd_control_state_t cntrl,
int  domain 
)

Definition at line 251 of file linux-NWunit.c.

252 {
253 #ifdef DEBUG_BGQ
254  printf( "NWUNIT_set_domain\n" );
255 #endif
256  int found = 0;
257  ( void ) cntrl;
258 
259  if ( PAPI_DOM_USER & domain )
260  found = 1;
261 
262  if ( PAPI_DOM_KERNEL & domain )
263  found = 1;
264 
265  if ( PAPI_DOM_OTHER & domain )
266  found = 1;
267 
268  if ( !found )
269  return ( PAPI_EINVAL );
270 
271  return ( PAPI_OK );
272 }
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_DOM_OTHER
Definition: fpapi.h:23
#define PAPI_DOM_KERNEL
Definition: fpapi.h:22
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define printf
Definition: papi_test.h:125
long long found
Definition: libasync.c:735
#define PAPI_DOM_USER
Definition: fpapi.h:21
int NWUNIT_shutdown_thread ( hwd_context_t ctx)

Definition at line 169 of file linux-NWunit.c.

170 {
171 #ifdef DEBUG_BGQ
172  printf( "NWUNIT_shutdown_thread\n" );
173 #endif
174 
175  ( void ) ctx;
176  return ( PAPI_OK );
177 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
int NWUNIT_start ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 90 of file linux-NWunit.c.

91 {
92 #ifdef DEBUG_BGQ
93  printf( "NWUNIT_start\n" );
94 #endif
95 
96  ( void ) ctx;
97  int retval;
98  NWUNIT_control_state_t * this_state = ( NWUNIT_control_state_t * ) ptr;
99 
100  retval = Bgpm_Attach( this_state->EventGroup, UPC_NW_ALL_LINKS, 0);
101  retval = _check_BGPM_error( retval, "Bgpm_Attach" );
102  if ( retval < 0 ) return retval;
103 
104  retval = Bgpm_ResetStart( this_state->EventGroup );
105  retval = _check_BGPM_error( retval, "Bgpm_ResetStart" );
106  if ( retval < 0 ) return retval;
107 
108  return ( PAPI_OK );
109 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int NWUNIT_stop ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 116 of file linux-NWunit.c.

117 {
118 #ifdef DEBUG_BGQ
119  printf( "NWUNIT_stop\n" );
120 #endif
121  ( void ) ctx;
122  int retval;
123  NWUNIT_control_state_t * this_state = ( NWUNIT_control_state_t * ) ptr;
124 
125  retval = Bgpm_Stop( this_state->EventGroup );
126  retval = _check_BGPM_error( retval, "Bgpm_Stop" );
127  if ( retval < 0 ) return retval;
128 
129  return ( PAPI_OK );
130 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int NWUNIT_update_control_state ( hwd_control_state_t ptr,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)

Definition at line 205 of file linux-NWunit.c.

208 {
209 #ifdef DEBUG_BGQ
210  printf( "NWUNIT_update_control_state: count = %d\n", count );
211 #endif
212  ( void ) ctx;
213  int retval, index, i;
214  NWUNIT_control_state_t * this_state = ( NWUNIT_control_state_t * ) ptr;
215 
216  // Delete and re-create BGPM eventset
217  retval = _common_deleteRecreate( &this_state->EventGroup );
218  if ( retval < 0 ) return retval;
219 
220  // otherwise, add the events to the eventset
221  for ( i = 0; i < count; i++ ) {
222  index = ( native[i].ni_event ) + OFFSET;
223 
224  native[i].ni_position = i;
225 
226 #ifdef DEBUG_BGQ
227  printf("NWUNIT_update_control_state: ADD event: i = %d, index = %d\n", i, index );
228 #endif
229 
230  /* Add events to the BGPM eventGroup */
231  retval = Bgpm_AddEvent( this_state->EventGroup, index );
232  retval = _check_BGPM_error( retval, "Bgpm_AddEvent" );
233  if ( retval < 0 ) return retval;
234  }
235 
236  return ( PAPI_OK );
237 }
int _common_deleteRecreate(int *EventGroup_ptr)
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
int i
Definition: fileop.c:140
#define OFFSET
Definition: linux-CNKunit.h:36
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Variable Documentation

papi_vector_t _NWunit_vector

Definition at line 23 of file linux-NWunit.c.