PAPI 7.1.0.0
Loading...
Searching...
No Matches
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 (const 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

◆ NWUNIT_cleanup_eventset()

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}
#define PAPI_OK
Definition: f90papi.h:73
int _common_deleteRecreate(int *EventGroup_ptr)
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:

◆ NWUNIT_ctl()

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}

◆ NWUNIT_init_component()

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}
papi_vector_t _NWunit_vector
Definition: linux-NWunit.c:23
static int cidx
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20

◆ NWUNIT_init_control_state()

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)
Here is the call graph for this function:

◆ NWUNIT_init_thread()

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}

◆ NWUNIT_ntv_code_to_bits()

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}

◆ NWUNIT_ntv_code_to_descr()

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}
#define OFFSET
Definition: linux-CNKunit.h:36
const char * name
Definition: rocs.c:225
Here is the call graph for this function:

◆ NWUNIT_ntv_code_to_name()

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: f90papi.h:139
#define MAX_COUNTERS
Definition: perfctr-x86.h:8

◆ NWUNIT_ntv_enum_events()

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_EVENTS ) {
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_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_EINVAL
Definition: f90papi.h:115
#define NWUNIT_MAX_EVENTS
Definition: linux-NWunit.h:37

◆ NWUNIT_ntv_name_to_code()

int NWUNIT_ntv_name_to_code ( const 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_EVENTS ) // not a NWUnit event
385 return PAPI_ENOEVNT;
386 else
387 *event_code = ( ret - OFFSET ) ;
388
389 return PAPI_OK;
390}

◆ NWUNIT_read()

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}
int i
char events[MAX_EVENTS][BUFSIZ]
long_long _common_getEventValue(unsigned event_id, int EventGroup)
long long counts[NWUNIT_MAX_COUNTERS]
Definition: linux-NWunit.h:59
Here is the call graph for this function:

◆ NWUNIT_reset()

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}
Here is the call graph for this function:

◆ NWUNIT_set_domain()

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}
#define PAPI_DOM_USER
Definition: f90papi.h:174
#define PAPI_DOM_OTHER
Definition: f90papi.h:21
#define PAPI_DOM_KERNEL
Definition: f90papi.h:254

◆ NWUNIT_shutdown_thread()

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}

◆ NWUNIT_start()

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}
Here is the call graph for this function:

◆ NWUNIT_stop()

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}
Here is the call graph for this function:

◆ NWUNIT_update_control_state()

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}
static long count
static int native
Here is the call graph for this function:

Variable Documentation

◆ _NWunit_vector

papi_vector_t _NWunit_vector

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