39 papisde_control_t *gctl;
45 SDE_ERROR(
"sde_ti_read_counter(): Attempt to read from unintialized SDE structures.\n");
50 if( counter_id >= gctl->num_reg_events ){
51 SDE_ERROR(
"sde_ti_read_counter(): SDE with id %d does not correspond to a registered event.\n",counter_id);
56 sde_counter_t *counter =
ht_lookup_by_id(gctl->all_reg_counters, counter_id);
57 if( NULL == counter ){
58 SDE_ERROR(
"sde_ti_read_counter(): SDE with id %d is clobbered.\n",counter_id);
63 SDEDBG(
"sde_ti_read_counter(): Reading counter: '%s'.\n",counter->name);
65 switch( counter->cntr_class ){
70 SDE_ERROR(
"sde_ti_read_counter(): Error occured when reading counter group: '%s'.\n",counter->name);
78 SDEDBG(
"sde_ti_read_counter(): Attempted read on a placeholder: '%s'.\n",counter->name);
87 long long used_entries;
92 if( NULL == counter->u.cntr_recorder.data->ptr_array[0] ){
93 SDE_ERROR(
"No space has been allocated for recorder %s\n",counter->name);
98 used_entries = counter->u.cntr_recorder.data->used_entries;
99 typesize = counter->u.cntr_recorder.data->typesize;
102 out_buffer = malloc( used_entries*typesize );
104 *rslt_ptr = (
long long)out_buffer;
110 cset_list_object_t *list_head;
112 *rslt_ptr = (
long long)list_head;
122 SDE_ERROR(
"sde_ti_read_counter(): Error occured when reading counter: '%s'.\n",counter->name);
137 papisde_control_t *gctl;
142 SDE_ERROR(
"sde_ti_write_counter(): Attempt to write in unintialized SDE structures.\n");
146 if( counter_id >= gctl->num_reg_events ){
147 SDE_ERROR(
"sde_ti_write_counter(): SDE with id %d does not correspond to a registered event.\n",counter_id);
151 sde_counter_t *counter =
ht_lookup_by_id(gctl->all_reg_counters, counter_id);
153 SDE_ERROR(
"sde_ti_write_counter(): SDE with id %d is clobbered, or a type which does not support writing.\n",counter_id);
159 SDE_ERROR(
"sde_ti_write_counter(): Error occured when writing counter: '%s'.\n",counter->name);
171 papisde_control_t *gctl;
175 SDE_ERROR(
"sde_ti_reset_counter(): Attempt to modify unintialized SDE structures.\n");
179 if( counter_id >= gctl->num_reg_events ){
180 SDE_ERROR(
"sde_ti_reset_counter(): SDE with id %d does not correspond to a registered event.\n",counter_id);
184 sde_counter_t *counter =
ht_lookup_by_id(gctl->all_reg_counters, counter_id);
186 SDEDBG(
"sde_ti_reset_counter(): SDE with id %d is clobbered, or a type which does not support resetting.\n",counter_id);
194 SDE_ERROR(
"sde_ti_reset_counter(): Error occured when resetting counter: %s.\n",counter->name);
206 papisde_library_desc_t *lib_handle;
207 char *pos, *tmp_lib_name;
208 sde_counter_t *tmp_item = NULL;
209 papisde_control_t *gctl;
220 pos = strstr(tmp_lib_name,
"::");
229 if(NULL == lib_handle){
230 SDE_ERROR(
"sde_ti_name_to_code(): Initialized SDE but unable to register new library: %s\n", tmp_lib_name);
235 int is_library_present = 0;
237 lib_handle = gctl->lib_list_head;
238 while(NULL != lib_handle){
239 if( !strcmp(lib_handle->libraryName, tmp_lib_name) ){
241 is_library_present = 1;
246 lib_handle = lib_handle->next;
249 if( !is_library_present ){
253 if(NULL == lib_handle){
254 SDE_ERROR(
"sde_ti_name_to_code(): Unable to register new library: %s\n", tmp_lib_name);
262 if( NULL != tmp_item ){
263 SDEDBG(
"Found matching counter with global uniq id: %d in library: %s\n", tmp_item->glb_uniq_id, lib_handle->libraryName );
264 *event_code = tmp_item->glb_uniq_id;
269 SDEDBG(
"Did not find event %s in library %s. Registering a placeholder.\n",
event_name, lib_handle->libraryName );
272 uint32_t counter_uniq_id = gctl->num_reg_events++;
273 gctl->num_live_events++;
278 if(NULL == tmp_item) {
279 SDEDBG(
"Event %s does not exist in library %s and placeholder could not be inserted.\n",
event_name, lib_handle->libraryName);
283 *event_code = tmp_item->glb_uniq_id;
299 lib_handle = gctl->lib_list_head;
300 while(NULL != lib_handle){
303 if( NULL != tmp_item ){
304 *event_code = tmp_item->glb_uniq_id;
305 SDEDBG(
"Found matching counter with global uniq id: %d in library: %s\n", tmp_item->glb_uniq_id, lib_handle->libraryName );
309 SDEDBG(
"Failed to find event %s in library %s. Looking in other libraries.\n",
event_name, lib_handle->libraryName );
312 lib_handle = lib_handle->next;
331 sde_counter_t *counter =
ht_lookup_by_id(gctl->all_reg_counters, counter_id);
349 sde_counter_t *counter =
ht_lookup_by_id(gctl->all_reg_counters, counter_id);
350 if( (NULL == counter) || !counter->overflow ||
IS_CNTR_CREATED(counter) )
366 sde_counter_t *counter =
ht_lookup_by_id(gctl->all_reg_counters, counter_id);
379 SDEDBG(
"Event is a placeholder (it has not been registered by a library yet), so we cannot start overflow, but we can remember it.\n");
380 counter->overflow = 1;
385 counter->overflow = 0;
405 sde_counter_t *counter =
ht_lookup_by_id(gctl->all_reg_counters, event_id);
406 if( NULL == counter )
409 return counter->name;
422 sde_counter_t *counter =
ht_lookup_by_id(gctl->all_reg_counters, event_id);
423 if( NULL == counter )
426 return counter->description;
439 return gctl->num_reg_events;
char event_name[2][PAPI_MAX_STR_LEN]
unsigned long AO_t __attribute__((__aligned__(4)))
papisde_control_t * _papisde_global_control
#define PAPI_SDE_long_long
static void SDE_ERROR(const char *format,...)
#define SDEDBG(format, args...)
void exp_container_to_contiguous(recorder_data_t *exp_container, void *cont_buffer)
sde_counter_t * ht_lookup_by_name(papisde_list_entry_t *hash_table, const char *name)
sde_counter_t * ht_lookup_by_id(papisde_list_entry_t *hash_table, uint32_t uniq_id)
#define IS_CNTR_CSET(_CNT)
int sde_ti_read_counter(uint32_t, long long int *)
#define IS_CNTR_BASIC(_CNT)
int sdei_read_and_update_data_value(sde_counter_t *counter, long long int previous_value, long long int *rslt_ptr)
#define IS_CNTR_RECORDER(_CNT)
#define IS_CNTR_PLACEHOLDER(_CNT)
void sdei_counting_set_to_list(void *cset_handle, cset_list_object_t **list_head)
papi_handle_t do_sde_init(const char *name_of_library, papisde_control_t *gctl)
sde_counter_t * allocate_and_insert(papisde_control_t *gctl, papisde_library_desc_t *lib_handle, const char *name, uint32_t uniq_id, int cntr_mode, int cntr_type, enum CNTR_CLASS cntr_class, cntr_class_specific_t cntr_union)
#define IS_CNTR_REGISTERED(_CNT)
int sdei_read_counter_group(sde_counter_t *counter, long long int *rslt_ptr)
#define IS_CNTR_CREATED(_CNT)
int sdei_hardware_write(sde_counter_t *counter, long long int new_value)
#define IS_CNTR_CALLBACK(_CNT)
papisde_control_t * sdei_get_global_struct(void)
char * sde_ti_get_event_description(int event_id)
int sde_ti_name_to_code(const char *event_name, uint32_t *event_code)
int sde_ti_reset_counter(uint32_t counter_id)
int sde_ti_is_simple_counter(uint32_t counter_id)
int sde_ti_get_num_reg_events(void)
int sde_ti_set_counter_overflow(uint32_t counter_id, int threshold)
int sde_ti_shutdown(void)
int sde_ti_write_counter(uint32_t counter_id, long long value)
char * sde_ti_get_event_name(int event_id)
int sde_ti_is_counter_set_to_overflow(uint32_t counter_id)