PAPI 7.1.0.0
Loading...
Searching...
No Matches
roc_profiler.h File Reference
Include dependency graph for roc_profiler.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int rocp_init_environment (void)
 
int rocp_init (void)
 
int rocp_shutdown (void)
 
int rocp_evt_enum (uint64_t *event_code, int modifier)
 
int rocp_evt_code_to_descr (uint64_t event_code, char *descr, int len)
 
int rocp_evt_name_to_code (const char *name, uint64_t *event_code)
 
int rocp_evt_code_to_name (uint64_t event_code, char *name, int len)
 
int rocp_evt_code_to_info (uint64_t event_code, PAPI_event_info_t *info)
 
int rocp_ctx_open (uint64_t *events_id, int num_events, rocp_ctx_t *ctx)
 
int rocp_ctx_close (rocp_ctx_t ctx)
 
int rocp_ctx_start (rocp_ctx_t ctx)
 
int rocp_ctx_stop (rocp_ctx_t ctx)
 
int rocp_ctx_read (rocp_ctx_t ctx, long long **counts)
 
int rocp_ctx_reset (rocp_ctx_t ctx)
 

Detailed Description

Author
Giuseppe Congiu gcong.nosp@m.iu@i.nosp@m.cl.ut.nosp@m.k.ed.nosp@m.u

Definition in file roc_profiler.h.

Function Documentation

◆ rocp_ctx_close()

int rocp_ctx_close ( rocp_ctx_t  ctx)

Definition at line 401 of file roc_profiler.c.

402{
404 return sampling_ctx_close(rocp_ctx);
405 }
406
407 return intercept_ctx_close(rocp_ctx);
408}
static int intercept_ctx_close(rocp_ctx_t)
static int sampling_ctx_close(rocp_ctx_t)
Definition: roc_profiler.c:952
unsigned int rocm_prof_mode
Definition: roc_profiler.c:84
#define ROCM_PROFILE_SAMPLING_MODE
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_ctx_open()

int rocp_ctx_open ( uint64_t *  events_id,
int  num_events,
rocp_ctx_t *  ctx 
)

Definition at line 390 of file roc_profiler.c.

391{
393 return sampling_ctx_open(events_id, num_events, rocp_ctx);
394 }
395
396 return intercept_ctx_open(events_id, num_events, rocp_ctx);
397}
static int num_events
static int sampling_ctx_open(uint64_t *, int, rocp_ctx_t *)
Definition: roc_profiler.c:921
static int intercept_ctx_open(uint64_t *, int, rocp_ctx_t *)
uint64_t * events_id
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_ctx_read()

int rocp_ctx_read ( rocp_ctx_t  ctx,
long long **  counts 
)

Definition at line 434 of file roc_profiler.c.

435{
437 return sampling_ctx_read(rocp_ctx, counts);
438 }
439
440 return intercept_ctx_read(rocp_ctx, counts);
441}
static int intercept_ctx_read(rocp_ctx_t, long long **)
static int sampling_ctx_read(rocp_ctx_t, long long **)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_ctx_reset()

int rocp_ctx_reset ( rocp_ctx_t  ctx)

Definition at line 445 of file roc_profiler.c.

446{
448 return sampling_ctx_reset(rocp_ctx);
449 }
450
451 return intercept_ctx_reset(rocp_ctx);
452}
static int intercept_ctx_reset(rocp_ctx_t)
static int sampling_ctx_reset(rocp_ctx_t)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_ctx_start()

int rocp_ctx_start ( rocp_ctx_t  ctx)

Definition at line 412 of file roc_profiler.c.

413{
415 return sampling_ctx_start(rocp_ctx);
416 }
417
418 return intercept_ctx_start(rocp_ctx);
419}
static int intercept_ctx_start(rocp_ctx_t)
static int sampling_ctx_start(rocp_ctx_t)
Definition: roc_profiler.c:973
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_ctx_stop()

int rocp_ctx_stop ( rocp_ctx_t  ctx)

Definition at line 423 of file roc_profiler.c.

424{
426 return sampling_ctx_stop(rocp_ctx);
427 }
428
429 return intercept_ctx_stop(rocp_ctx);
430}
static int intercept_ctx_stop(rocp_ctx_t)
static int sampling_ctx_stop(rocp_ctx_t)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_evt_code_to_descr()

int rocp_evt_code_to_descr ( uint64_t  event_code,
char *  descr,
int  len 
)

Definition at line 260 of file roc_profiler.c.

261{
262 int papi_errno;
263
264 event_info_t info;
265 papi_errno = evt_id_to_info(event_code, &info);
266 if (papi_errno != PAPI_OK) {
267 return papi_errno;
268 }
269
270 snprintf(descr, (size_t) len, "%s", ntv_table_p->events[info.nameid].descr);
271 return papi_errno;
272}
#define PAPI_OK
Definition: f90papi.h:73
static ntv_event_table_t * ntv_table_p
Definition: roc_profiler.c:146
static int evt_id_to_info(uint64_t event_id, event_info_t *info)
Definition: roc_profiler.c:774
char * descr
Definition: roc_profiler.c:44
ntv_event_t * events
Definition: roc_profiler.c:50
char * descr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_evt_code_to_info()

int rocp_evt_code_to_info ( uint64_t  event_code,
PAPI_event_info_t info 
)

Definition at line 331 of file roc_profiler.c.

332{
333 int papi_errno;
334
335 event_info_t inf;
336 papi_errno = evt_id_to_info(event_code, &inf);
337 if (papi_errno != PAPI_OK) {
338 return papi_errno;
339 }
340
341 switch (inf.flags) {
342 case 0:
343 sprintf(info->symbol, "%s", ntv_table_p->events[inf.nameid].name);
344 sprintf(info->long_descr, "%s", ntv_table_p->events[inf.nameid].descr);
345 break;
346 case (DEVICE_FLAG | INSTAN_FLAG):
347 {
348 int i;
349 char devices[PAPI_MAX_STR_LEN] = { 0 };
350 for (i = 0; i < device_table_p->count; ++i) {
352 sprintf(devices + strlen(devices), "%i,", i);
353 }
354 }
355 *(devices + strlen(devices) - 1) = 0;
356 sprintf(info->symbol, "%s:device=%i:instance=%i", ntv_table_p->events[inf.nameid].name, inf.device, inf.instance);
357 sprintf(info->long_descr, "%s, masks:Mandatory device qualifier [%s]:Mandatory instance qualifier in range [0-%i]",
359 break;
360 }
361 case DEVICE_FLAG:
362 {
363 int i;
364 char devices[PAPI_MAX_STR_LEN] = { 0 };
365 for (i = 0; i < device_table_p->count; ++i) {
367 sprintf(devices + strlen(devices), "%i,", i);
368 }
369 }
370 *(devices + strlen(devices) - 1) = 0;
371 sprintf(info->symbol, "%s:device=%i", ntv_table_p->events[inf.nameid].name, inf.device);
372 sprintf(info->long_descr, "%s, masks:Mandatory device qualifier [%s]",
374 break;
375 }
376 case INSTAN_FLAG:
377 sprintf(info->symbol, "%s:instance=%i", ntv_table_p->events[inf.nameid].name, inf.instance);
378 sprintf(info->long_descr, "%s, masks:Mandatory instance qualifier in range [0-%i]",
380 break;
381 default:
382 papi_errno = PAPI_EINVAL;
383 }
384
385 return papi_errno;
386}
int i
#define PAPI_EINVAL
Definition: f90papi.h:115
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
static nvmlDevice_t * devices
Definition: linux-nvml.c:146
int rocc_dev_check(rocc_bitmap_t bitmap, int i)
Definition: roc_common.c:187
device_table_t * device_table_p
Definition: roc_common.c:19
#define INSTAN_FLAG
Definition: roc_profiler.c:40
#define DEVICE_FLAG
Definition: roc_profiler.c:39
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
rocc_bitmap_t device_map
Definition: roc_profiler.c:46
char * name
Definition: roc_profiler.c:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_evt_code_to_name()

int rocp_evt_code_to_name ( uint64_t  event_code,
char *  name,
int  len 
)

Definition at line 324 of file roc_profiler.c.

325{
326 return evt_code_to_name(event_code, name, len);
327}
static int evt_code_to_name(uint64_t event_code, char *name, int len)
Definition: roc_profiler.c:739
const char * name
Definition: rocs.c:225
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_evt_enum()

int rocp_evt_enum ( uint64_t *  event_code,
int  modifier 
)

Definition at line 193 of file roc_profiler.c.

194{
195 int papi_errno = PAPI_OK;
196 event_info_t info;
197 SUBDBG("ENTER: event_code: %lu, modifier: %d\n", *event_code, modifier);
198
199
200 switch(modifier) {
201 case PAPI_ENUM_FIRST:
202 if (ntv_table_p->count == 0) {
203 papi_errno = PAPI_ENOEVNT;
204 break;
205 }
206 info.device = 0;
207 info.instance = 0;
208 info.flags = 0;
209 info.nameid = 0;
210 papi_errno = evt_id_create(&info, event_code);
211 break;
212 case PAPI_ENUM_EVENTS:
213 papi_errno = evt_id_to_info(*event_code, &info);
214 if (papi_errno != PAPI_OK) {
215 break;
216 }
217 if (ntv_table_p->count > info.nameid + 1) {
218 info.device = 0;
219 info.instance = 0;
220 info.flags = 0;
221 info.nameid++;
222 papi_errno = evt_id_create(&info, event_code);
223 break;
224 }
225 papi_errno = PAPI_END;
226 break;
228 papi_errno = evt_id_to_info(*event_code, &info);
229 if (papi_errno != PAPI_OK) {
230 break;
231 }
232 if (info.flags == 0) {
233 info.device = 0;
234 info.instance = 0;
235 info.flags = DEVICE_FLAG;
236 papi_errno = evt_id_create(&info, event_code);
237 break;
238 }
239 if (info.flags & DEVICE_FLAG) {
240 if (ntv_table_p->events[info.nameid].instances > 1) {
241 info.device = 0;
242 info.instance = 0;
243 info.flags = INSTAN_FLAG;
244 papi_errno = evt_id_create(&info, event_code);
245 break;
246 }
247 }
248 papi_errno = PAPI_END;
249 break;
250 default:
251 papi_errno = PAPI_EINVAL;
252 }
253
254 SUBDBG("EXIT: %s\n", PAPI_strerror(papi_errno));
255 return papi_errno;
256}
Returns a string describing the PAPI error code.
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_ENOEVNT
Definition: f90papi.h:139
#define PAPI_END
Definition: f90papi.h:303
#define PAPI_NTV_ENUM_UMASKS
Definition: f90papi.h:66
#define SUBDBG(format, args...)
Definition: papi_debug.h:64
static int evt_id_create(event_info_t *info, uint64_t *event_id)
Definition: roc_profiler.c:764
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_evt_name_to_code()

int rocp_evt_name_to_code ( const char *  name,
uint64_t *  event_code 
)

Definition at line 276 of file roc_profiler.c.

277{
278 int papi_errno = PAPI_OK;
279 int htable_errno;
280 SUBDBG("ENTER: name: %s, event_code: %p\n", name, event_code);
281
282 int device;
283 papi_errno = evt_name_to_device(name, &device);
284 if (papi_errno != PAPI_OK) {
285 goto fn_exit;
286 }
287
288 int instance;
289 papi_errno = evt_name_to_instance(name, &instance);
290 if (papi_errno != PAPI_OK) {
291 goto fn_exit;
292 }
293
294 char base[PAPI_MAX_STR_LEN] = { 0 };
295 papi_errno = evt_name_to_basename(name, base, PAPI_MAX_STR_LEN);
296 if (papi_errno != PAPI_OK) {
297 goto fn_exit;
298 }
299
300 ntv_event_t *event;
301 htable_errno = htable_find(htable, base, (void **) &event);
302 if (htable_errno != HTABLE_SUCCESS) {
303 papi_errno = (htable_errno == HTABLE_ENOVAL) ? PAPI_ENOEVNT : PAPI_ECMP;
304 goto fn_exit;
305 }
306
307 int flags = (event->instances > 1) ? (DEVICE_FLAG | INSTAN_FLAG) : DEVICE_FLAG;
308 int nameid = (int) (event - ntv_table_p->events);
309 event_info_t info = { device, instance, flags, nameid };
310 papi_errno = evt_id_create(&info, event_code);
311 if (papi_errno != PAPI_OK) {
312 goto fn_exit;
313 }
314
315 papi_errno = evt_id_to_info(*event_code, &info);
316
317 fn_exit:
318 SUBDBG("EXIT: %s\n", PAPI_strerror(papi_errno));
319 return papi_errno;
320}
#define HTABLE_ENOVAL
Definition: cuda/htable.h:18
#define HTABLE_SUCCESS
Definition: cuda/htable.h:17
static int htable_find(void *handle, const char *key, void **out)
Definition: cuda/htable.h:161
#define PAPI_ECMP
Definition: f90papi.h:214
static int evt_name_to_basename(const char *name, char *base, int len)
Definition: roc_profiler.c:851
static void * htable
Definition: roc_profiler.c:147
static int evt_name_to_instance(const char *name, int *instance)
Definition: roc_profiler.c:820
static int evt_name_to_device(const char *name, int *device)
Definition: roc_profiler.c:809
int
Definition: sde_internal.h:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_init()

int rocp_init ( void  )

Definition at line 159 of file roc_profiler.c.

160{
161 int papi_errno = PAPI_OK;
162 SUBDBG("ENTER\n");
163
164 papi_errno = load_rocp_sym();
165 if (papi_errno != PAPI_OK) {
166 goto fn_fail;
167 }
168
170
173 }
174
175 papi_errno = init_event_table();
176 if (papi_errno != PAPI_OK) {
177 (*hsa_shut_down_p)();
178 goto fn_fail;
179 }
180
182
183 fn_exit:
184 SUBDBG("EXIT: %s\n", PAPI_strerror(papi_errno));
185 return papi_errno;
186 fn_fail:
188 goto fn_exit;
189}
static int htable_init(void **handle)
Definition: cuda/htable.h:55
static ntv_event_table_t ntv_table
Definition: roc_profiler.c:145
static int load_rocp_sym(void)
Definition: roc_profiler.c:470
static int unload_rocp_sym(void)
Definition: roc_profiler.c:545
static void * htable_intercept
Definition: roc_profiler.c:148
static int init_event_table(void)
Definition: roc_profiler.c:682
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_init_environment()

int rocp_init_environment ( void  )

Definition at line 152 of file roc_profiler.c.

153{
154 return init_rocp_env();
155}
static int init_rocp_env(void)
Definition: roc_profiler.c:580
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocp_shutdown()

int rocp_shutdown ( void  )

Definition at line 456 of file roc_profiler.c.

457{
459 return sampling_shutdown();
460 }
461
462 return intercept_shutdown();
463}
static int intercept_shutdown(void)
static int sampling_shutdown(void)
Here is the call graph for this function:
Here is the caller graph for this function: