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

Go to the source code of this file.

Data Structures

struct  device_table_t
 

Macros

#define PAPI_ROCM_MAX_DEV_COUNT   (32)
 

Typedefs

typedef int64_t rocc_bitmap_t
 
typedef int(* rocc_dev_get_map_cb) (uint64_t event_id, int *dev_id)
 

Functions

int rocc_init (void)
 
int rocc_shutdown (void)
 
int rocc_err_get_last (const char **error_string)
 
int rocc_dev_get_map (rocc_dev_get_map_cb cb, uint64_t *events_id, int num_events, rocc_bitmap_t *bitmap)
 
int rocc_dev_acquire (rocc_bitmap_t bitmap)
 
int rocc_dev_release (rocc_bitmap_t bitmap)
 
int rocc_dev_get_count (rocc_bitmap_t bitmap, int *num_devices)
 
int rocc_dev_get_id (rocc_bitmap_t bitmap, int dev_count, int *device_id)
 
int rocc_dev_get_agent_id (hsa_agent_t agent, int *dev_id)
 
int rocc_dev_set (rocc_bitmap_t *bitmap, int i)
 
int rocc_dev_check (rocc_bitmap_t bitmap, int i)
 
int rocc_thread_get_id (unsigned long *tid)
 

Variables

hsa_status_t(* hsa_init_p )(void)
 
hsa_status_t(* hsa_shut_down_p )(void)
 
hsa_status_t(* hsa_iterate_agents_p )(hsa_status_t(*)(hsa_agent_t, void *), void *)
 
hsa_status_t(* hsa_system_get_info_p )(hsa_system_info_t, void *)
 
hsa_status_t(* hsa_agent_get_info_p )(hsa_agent_t, hsa_agent_info_t, void *)
 
hsa_status_t(* hsa_queue_destroy_p )(hsa_queue_t *)
 
hsa_status_t(* hsa_status_string_p )(hsa_status_t, const char **)
 
char error_string [PAPI_MAX_STR_LEN]
 
device_table_tdevice_table_p
 

Macro Definition Documentation

◆ PAPI_ROCM_MAX_DEV_COUNT

#define PAPI_ROCM_MAX_DEV_COUNT   (32)

Definition at line 16 of file roc_common.h.

Typedef Documentation

◆ rocc_bitmap_t

typedef int64_t rocc_bitmap_t

Definition at line 19 of file roc_common.h.

◆ rocc_dev_get_map_cb

typedef int(* rocc_dev_get_map_cb) (uint64_t event_id, int *dev_id)

Definition at line 20 of file roc_common.h.

Function Documentation

◆ rocc_dev_acquire()

int rocc_dev_acquire ( rocc_bitmap_t  bitmap)

Definition at line 93 of file roc_common.c.

94{
95 rocc_bitmap_t device_map_acq = bitmap;
96
97 if (device_map_acq & global_device_map) {
98 return PAPI_EINVAL;
99 }
100 global_device_map |= device_map_acq;
101
102 return PAPI_OK;
103}
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_EINVAL
Definition: f90papi.h:115
static rocc_bitmap_t global_device_map
Definition: roc_common.c:20
int64_t rocc_bitmap_t
Definition: roc_common.h:19
Here is the caller graph for this function:

◆ rocc_dev_check()

int rocc_dev_check ( rocc_bitmap_t  bitmap,
int  i 
)

Definition at line 187 of file roc_common.c.

188{
189 return (bitmap & (1ULL << i));
190}
int i
Here is the caller graph for this function:

◆ rocc_dev_get_agent_id()

int rocc_dev_get_agent_id ( hsa_agent_t  agent,
int dev_id 
)

Definition at line 169 of file roc_common.c.

170{
171 for (*dev_id = 0; *dev_id < device_table_p->count; ++(*dev_id)) {
172 if (memcmp(&device_table_p->devices[*dev_id], &agent, sizeof(agent)) == 0) {
173 break;
174 }
175 }
176 return PAPI_OK;
177}
device_table_t * device_table_p
Definition: roc_common.c:19
hsa_agent_t devices[PAPI_ROCM_MAX_DEV_COUNT]
Definition: roc_common.h:23
Here is the caller graph for this function:

◆ rocc_dev_get_count()

int rocc_dev_get_count ( rocc_bitmap_t  bitmap,
int num_devices 
)

Definition at line 121 of file roc_common.c.

122{
123 return dev_get_count(bitmap, num_devices);
124}
static int dev_get_count(rocc_bitmap_t bitmap, int *num_devices)
Definition: roc_common.c:127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocc_dev_get_id()

int rocc_dev_get_id ( rocc_bitmap_t  bitmap,
int  dev_count,
int device_id 
)

Definition at line 140 of file roc_common.c.

141{
142 int count = 0;
143
144 dev_get_count(bitmap, &count);
145 if (dev_count >= count) {
146 return PAPI_EMISC;
147 }
148
149 count = 0;
150 rocc_bitmap_t lsb = 0;
151 while (bitmap) {
152 lsb = bitmap & (~bitmap + 1);
153 bitmap -= lsb;
154 if (count++ == dev_count) {
155 break;
156 }
157 }
158
159 *device_id = 0;
160 while (!(lsb & 0x1)) {
161 ++(*device_id);
162 lsb >>= 1;
163 }
164
165 return PAPI_OK;
166}
static long count
#define PAPI_EMISC
Definition: f90papi.h:122
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocc_dev_get_map()

int rocc_dev_get_map ( rocc_dev_get_map_cb  cb,
uint64_t *  events_id,
int  num_events,
rocc_bitmap_t bitmap 
)

Definition at line 74 of file roc_common.c.

75{
76 int i;
77 rocc_bitmap_t device_map_acq = 0;
78
79 for (i = 0; i < num_events; ++i) {
80 int dev_id;
81 if (query_dev_id(events_id[i], &dev_id)) {
82 return PAPI_EMISC;
83 }
84
85 device_map_acq |= (1 << dev_id);
86 }
87
88 *bitmap = device_map_acq;
89 return PAPI_OK;
90}
static int num_events
uint64_t * events_id
Here is the caller graph for this function:

◆ rocc_dev_release()

int rocc_dev_release ( rocc_bitmap_t  bitmap)

Definition at line 106 of file roc_common.c.

107{
108 rocc_bitmap_t device_map_rel = bitmap;
109
110 if ((device_map_rel & global_device_map) != device_map_rel) {
111 return PAPI_EINVAL;
112 }
113 global_device_map &= ~device_map_rel;
114
115 return PAPI_OK;
116}
Here is the caller graph for this function:

◆ rocc_dev_set()

int rocc_dev_set ( rocc_bitmap_t bitmap,
int  i 
)

Definition at line 180 of file roc_common.c.

181{
182 *bitmap |= (1ULL << i);
183 return PAPI_OK;
184}
Here is the caller graph for this function:

◆ rocc_err_get_last()

int rocc_err_get_last ( const char **  error_string)

Definition at line 67 of file roc_common.c.

68{
69 *err_string = error_string;
70 return PAPI_OK;
71}
char error_string[PAPI_MAX_STR_LEN]
Definition: roc_common.c:17
Here is the caller graph for this function:

◆ rocc_init()

int rocc_init ( void  )

Definition at line 29 of file roc_common.c.

30{
31 int papi_errno = load_hsa_sym();
32 if (papi_errno != PAPI_OK) {
33 goto fn_fail;
34 }
35
36 hsa_status_t status = hsa_init_p();
37 if (status != HSA_STATUS_SUCCESS) {
38 papi_errno = PAPI_EMISC;
39 goto fn_fail;
40 }
41
42 papi_errno = init_device_table();
43 if (papi_errno != PAPI_OK) {
44 (*hsa_shut_down_p)();
45 goto fn_fail;
46 }
47
50
51 fn_exit:
52 return papi_errno;
53 fn_fail:
55 goto fn_exit;
56}
static int unload_hsa_sym(void)
Definition: roc_common.c:248
static int load_hsa_sym(void)
Definition: roc_common.c:200
hsa_status_t(* hsa_init_p)(void)
Definition: roc_common.c:8
static device_table_t device_table
Definition: roc_common.c:18
static void init_thread_id_fn(void)
Definition: roc_common.c:311
static int init_device_table(void)
Definition: roc_common.c:270
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocc_shutdown()

int rocc_shutdown ( void  )

Definition at line 59 of file roc_common.c.

60{
63 return PAPI_OK;
64}
hsa_status_t(* hsa_shut_down_p)(void)
Definition: roc_common.c:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rocc_thread_get_id()

int rocc_thread_get_id ( unsigned long tid)

Definition at line 193 of file roc_common.c.

194{
195 *tid = thread_id_fn();
196 return PAPI_OK;
197}
static unsigned long(* thread_id_fn)(void)
Definition: roc_common.c:26
Here is the caller graph for this function:

Variable Documentation

◆ device_table_p

device_table_t* device_table_p
extern

Definition at line 19 of file roc_common.c.

◆ error_string

char error_string[PAPI_MAX_STR_LEN]
extern

Definition at line 17 of file roc_common.c.

◆ hsa_agent_get_info_p

hsa_status_t(* hsa_agent_get_info_p) (hsa_agent_t, hsa_agent_info_t, void *) ( hsa_agent_t  ,
hsa_agent_info_t  ,
void *   
)
extern

Definition at line 12 of file roc_common.c.

◆ hsa_init_p

hsa_status_t(* hsa_init_p) (void) ( void  )
extern

Definition at line 8 of file roc_common.c.

◆ hsa_iterate_agents_p

hsa_status_t(* hsa_iterate_agents_p) (hsa_status_t(*)(hsa_agent_t, void *), void *) ( hsa_status_t(*)(hsa_agent_t, void *)  ,
void *   
)
extern

Definition at line 10 of file roc_common.c.

◆ hsa_queue_destroy_p

hsa_status_t(* hsa_queue_destroy_p) (hsa_queue_t *) ( hsa_queue_t *  )
extern

Definition at line 13 of file roc_common.c.

◆ hsa_shut_down_p

hsa_status_t(* hsa_shut_down_p) (void) ( void  )
extern

Definition at line 9 of file roc_common.c.

◆ hsa_status_string_p

hsa_status_t(* hsa_status_string_p) (hsa_status_t, const char **) ( hsa_status_t  ,
const char **   
)
extern

Definition at line 14 of file roc_common.c.

◆ hsa_system_get_info_p

hsa_status_t(* hsa_system_get_info_p) (hsa_system_info_t, void *) ( hsa_system_info_t  ,
void *   
)
extern

Definition at line 11 of file roc_common.c.