PAPI 7.1.0.0
Loading...
Searching...
No Matches
linux-CNKunit.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-CNKunit.c:

Go to the source code of this file.

Functions

int CNKUNIT_init_thread (hwd_context_t *ctx)
 
int CNKUNIT_init_component (int cidx)
 
int CNKUNIT_init_control_state (hwd_control_state_t *ptr)
 
int CNKUNIT_start (hwd_context_t *ctx, hwd_control_state_t *ptr)
 
int CNKUNIT_stop (hwd_context_t *ctx, hwd_control_state_t *ptr)
 
int CNKUNIT_read (hwd_context_t *ctx, hwd_control_state_t *ptr, long_long **events, int flags)
 
int CNKUNIT_shutdown_thread (hwd_context_t *ctx)
 
int CNKUNIT_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
int CNKUNIT_update_control_state (hwd_control_state_t *ptr, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
int CNKUNIT_set_domain (hwd_control_state_t *cntrl, int domain)
 
int CNKUNIT_reset (hwd_context_t *ctx, hwd_control_state_t *ptr)
 
int CNKUNIT_cleanup_eventset (hwd_control_state_t *ctrl)
 
int CNKUNIT_ntv_enum_events (unsigned int *EventCode, int modifier)
 
int CNKUNIT_ntv_name_to_code (const char *name, unsigned int *event_code)
 
int CNKUNIT_ntv_code_to_name (unsigned int EventCode, char *name, int len)
 
int CNKUNIT_ntv_code_to_descr (unsigned int EventCode, char *name, int len)
 
int CNKUNIT_ntv_code_to_bits (unsigned int EventCode, hwd_register_t *bits)
 

Variables

papi_vector_t _CNKunit_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 / CNKunit component

Tested version of bgpm (early access)

Definition in file linux-CNKunit.c.

Function Documentation

◆ CNKUNIT_cleanup_eventset()

int CNKUNIT_cleanup_eventset ( hwd_control_state_t ctrl)

Definition at line 307 of file linux-CNKunit.c.

308{
309#ifdef DEBUG_BGQ
310 printf( "CNKUNIT_cleanup_eventset\n" );
311#endif
312 int retval;
313
314 CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ctrl;
315
316 // create a new empty bgpm eventset
317 // reason: bgpm doesn't permit to remove events from an eventset;
318 // hence we delete the old eventset and create a new one
319 retval = _common_deleteRecreate( &this_state->EventGroup ); // HJ try to use delete() only
320 if ( retval < 0 ) return retval;
321
322 return ( PAPI_OK );
323}
#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:

◆ CNKUNIT_ctl()

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

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

186{
187#ifdef DEBUG_BGQ
188 printf( "CNKUNIT_ctl\n" );
189#endif
190 ( void ) ctx;
191 ( void ) code;
192 ( void ) option;
193 return ( PAPI_OK );
194}

◆ CNKUNIT_init_component()

int CNKUNIT_init_component ( int  cidx)

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

50{
51#ifdef DEBUG_BGQ
52 printf( "CNKUNIT_init_component\n" );
53#endif
54
56#ifdef DEBUG_BGQ
57 printf( "CNKUNIT_init_component cidx = %d\n", cidx );
58#endif
59
60 return ( PAPI_OK );
61}
papi_vector_t _CNKunit_vector
Definition: linux-CNKunit.c:23
static int cidx
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20

◆ CNKUNIT_init_control_state()

int CNKUNIT_init_control_state ( hwd_control_state_t ptr)

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

70{
71#ifdef DEBUG_BGQ
72 printf( "CNKUNIT_init_control_state\n" );
73#endif
74 int retval;
75
76 CNKUNIT_control_state_t * this_state = ( CNKUNIT_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:

◆ CNKUNIT_init_thread()

int CNKUNIT_init_thread ( hwd_context_t ctx)

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

34{
35#ifdef DEBUG_BGQ
36 printf( "CNKUNIT_init_thread\n" );
37#endif
38
39 ( void ) ctx;
40 return PAPI_OK;
41}

◆ CNKUNIT_ntv_code_to_bits()

int CNKUNIT_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
)

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

448{
449#ifdef DEBUG_BGQ
450 printf( "CNKUNIT_ntv_code_to_bits\n" );
451#endif
452 ( void ) EventCode;
453 ( void ) bits;
454 return ( PAPI_OK );
455}

◆ CNKUNIT_ntv_code_to_descr()

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

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

427{
428#ifdef DEBUG_BGQ
429 //printf( "CNKUNIT_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:

◆ CNKUNIT_ntv_code_to_name()

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

Definition at line 396 of file linux-CNKunit.c.

397{
398#ifdef DEBUG_BGQ
399 //printf( "CNKUNIT_ntv_code_to_name\n" );
400#endif
401 int index;
402
403 index = ( EventCode ) + OFFSET;
404
405 if ( index >= MAX_COUNTERS )
406 return PAPI_ENOEVNT;
407
408 strncpy( name, Bgpm_GetEventIdLabel( index ), len );
409 //printf("----%s----\n", name);
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

◆ CNKUNIT_ntv_enum_events()

int CNKUNIT_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)

Definition at line 330 of file linux-CNKunit.c.

331{
332#ifdef DEBUG_BGQ
333// printf( "CNKUNIT_ntv_enum_events\n" );
334#endif
335
336 switch ( modifier ) {
337 case PAPI_ENUM_FIRST:
338 *EventCode = 0;
339
340 return ( PAPI_OK );
341 break;
342
343 case PAPI_ENUM_EVENTS:
344 {
345 int index = ( *EventCode ) + OFFSET;
346
347 if ( index < CNKUNIT_MAX_COUNTERS ) {
348 *EventCode = *EventCode + 1;
349 return ( PAPI_OK );
350 } else
351 return ( PAPI_ENOEVNT );
352
353 break;
354 }
355 default:
356 return ( PAPI_EINVAL );
357 }
358 return ( PAPI_EINVAL );
359}
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_EINVAL
Definition: f90papi.h:115
#define CNKUNIT_MAX_COUNTERS
Definition: linux-CNKunit.h:35

◆ CNKUNIT_ntv_name_to_code()

int CNKUNIT_ntv_name_to_code ( const char *  name,
unsigned int event_code 
)

Definition at line 366 of file linux-CNKunit.c.

367{
368#ifdef DEBUG_BGQ
369 printf( "CNKUNIT_ntv_name_to_code\n" );
370#endif
371 int ret;
372
373 /* Return event id matching a given event label string */
374 ret = Bgpm_GetEventIdFromLabel ( name );
375
376 if ( ret <= 0 ) {
377#ifdef DEBUG_BGPM
378 printf ("Error: ret value is %d for BGPM API function '%s'.\n",
379 ret, "Bgpm_GetEventIdFromLabel" );
380#endif
381 return PAPI_ENOEVNT;
382 }
383 else if ( ret < OFFSET || ret > CNKUNIT_MAX_COUNTERS ) // not a CNKUnit event
384 return PAPI_ENOEVNT;
385 else
386 *event_code = ( ret - OFFSET ) ;
387
388 return PAPI_OK;
389}

◆ CNKUNIT_read()

int CNKUNIT_read ( hwd_context_t ctx,
hwd_control_state_t ptr,
long_long **  events,
int  flags 
)

Definition at line 138 of file linux-CNKunit.c.

140{
141#ifdef DEBUG_BGQ
142 printf( "CNKUNIT_read\n" );
143#endif
144 ( void ) ctx;
145 ( void ) flags;
146 int i, numEvts;
147 CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
148
149 numEvts = Bgpm_NumEvents( this_state->EventGroup );
150 if ( numEvts == 0 ) {
151#ifdef DEBUG_BGPM
152 printf ("Error: ret value is %d for BGPM API function Bgpm_NumEvents.\n", numEvts );
153#endif
154 //return ( EXIT_FAILURE );
155 }
156
157 for ( i = 0; i < numEvts; i++ )
158 this_state->counts[i] = _common_getEventValue( i, this_state->EventGroup );
159
160 *events = this_state->counts;
161
162 return ( PAPI_OK );
163}
int i
char events[MAX_EVENTS][BUFSIZ]
long_long _common_getEventValue(unsigned event_id, int EventGroup)
long long counts[CNKUNIT_MAX_COUNTERS]
Definition: linux-CNKunit.h:57
Here is the call graph for this function:

◆ CNKUNIT_reset()

int CNKUNIT_reset ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 276 of file linux-CNKunit.c.

277{
278#ifdef DEBUG_BGQ
279 printf( "CNKUNIT_reset\n" );
280#endif
281 ( void ) ctx;
282 int retval;
283 CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
284
285 /* we can't simply call Bgpm_Reset() since PAPI doesn't have the
286 restriction that an EventSet has to be stopped before resetting is
287 possible. However, BGPM does have this restriction.
288 Hence we need to stop, reset and start */
289 retval = Bgpm_Stop( this_state->EventGroup );
290 retval = _check_BGPM_error( retval, "Bgpm_Stop" );
291 if ( retval < 0 ) return retval;
292
293 retval = Bgpm_ResetStart( this_state->EventGroup );
294 retval = _check_BGPM_error( retval, "Bgpm_ResetStart" );
295 if ( retval < 0 ) return retval;
296
297 return ( PAPI_OK );
298}
Here is the call graph for this function:

◆ CNKUNIT_set_domain()

int CNKUNIT_set_domain ( hwd_control_state_t cntrl,
int  domain 
)

Definition at line 248 of file linux-CNKunit.c.

249{
250#ifdef DEBUG_BGQ
251 printf( "CNKUNIT_set_domain\n" );
252#endif
253 int found = 0;
254 ( void ) cntrl;
255
256 if ( PAPI_DOM_USER & domain )
257 found = 1;
258
259 if ( PAPI_DOM_KERNEL & domain )
260 found = 1;
261
262 if ( PAPI_DOM_OTHER & domain )
263 found = 1;
264
265 if ( !found )
266 return ( PAPI_EINVAL );
267
268 return ( PAPI_OK );
269}
#define PAPI_DOM_USER
Definition: f90papi.h:174
#define PAPI_DOM_OTHER
Definition: f90papi.h:21
#define PAPI_DOM_KERNEL
Definition: f90papi.h:254

◆ CNKUNIT_shutdown_thread()

int CNKUNIT_shutdown_thread ( hwd_context_t ctx)

Definition at line 170 of file linux-CNKunit.c.

171{
172#ifdef DEBUG_BGQ
173 printf( "CNKUNIT_shutdown_thread\n" );
174#endif
175 ( void ) ctx;
176 return ( PAPI_OK );
177}

◆ CNKUNIT_start()

int CNKUNIT_start ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

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

91{
92#ifdef DEBUG_BGQ
93 printf( "CNKUNIT_start\n" );
94#endif
95 ( void ) ctx;
96 int retval;
97 CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
98
99 retval = Bgpm_Apply( this_state->EventGroup );
100 retval = _check_BGPM_error( retval, "Bgpm_Apply" );
101 if ( retval < 0 ) return retval;
102
103 /* Bgpm_Apply() does an implicit reset;
104 hence no need to use Bgpm_ResetStart */
105 retval = Bgpm_Start( this_state->EventGroup );
106 retval = _check_BGPM_error( retval, "Bgpm_Start" );
107 if ( retval < 0 ) return retval;
108
109 return ( PAPI_OK );
110}
Here is the call graph for this function:

◆ CNKUNIT_stop()

int CNKUNIT_stop ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 117 of file linux-CNKunit.c.

118{
119#ifdef DEBUG_BGQ
120 printf( "CNKUNIT_stop\n" );
121#endif
122 ( void ) ctx;
123 int retval;
124 CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
125
126 retval = Bgpm_Stop( this_state->EventGroup );
127 retval = _check_BGPM_error( retval, "Bgpm_Stop" );
128 if ( retval < 0 ) return retval;
129
130 return ( PAPI_OK );
131}
Here is the call graph for this function:

◆ CNKUNIT_update_control_state()

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

Definition at line 202 of file linux-CNKunit.c.

205{
206#ifdef DEBUG_BGQ
207 printf( "CNKUNIT_update_control_state: count = %d\n", count );
208#endif
209 ( void ) ctx;
210 int retval, index, i;
211 CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
212
213 // Delete and re-create BGPM eventset
214 retval = _common_deleteRecreate( &this_state->EventGroup );
215 if ( retval < 0 ) return retval;
216
217 // otherwise, add the events to the eventset
218 for ( i = 0; i < count; i++ ) {
219 index = ( native[i].ni_event ) + OFFSET;
220
221 native[i].ni_position = i;
222
223#ifdef DEBUG_BGQ
224 printf("CNKUNIT_update_control_state: ADD event: i = %d, index = %d\n", i, index );
225#endif
226
227 /* Add events to the BGPM eventGroup */
228 retval = Bgpm_AddEvent( this_state->EventGroup, index );
229 retval = _check_BGPM_error( retval, "Bgpm_AddEvent" );
230 if ( retval < 0 ) return retval;
231 }
232
233 return ( PAPI_OK );
234}
static long count
static int native
Here is the call graph for this function:

Variable Documentation

◆ _CNKunit_vector

papi_vector_t _CNKunit_vector

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