Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/coretemp/linux-coretemp.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ insert_in_list(char *name, char *units,
/* Because this is a function, it is possible */
/* we are called with root!=NULL but no last */
/* so add this to keep coverity happy */
free(temp);
papi_free(temp);
PAPIERROR("This shouldn't be possible\n");

return PAPI_ECMP;
Expand Down
46 changes: 23 additions & 23 deletions src/components/cuda/cupti_profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ static int get_counter_availability(cuptip_gpu_state_t *gpu_ctl)

// Allocate the necessary memory for data
gpu_ctl->counterAvailabilityImage.size = getCounterAvailabilityParams.counterAvailabilityImageSize;
gpu_ctl->counterAvailabilityImage.data = (uint8_t *) papi_malloc(gpu_ctl->counterAvailabilityImage.size);
gpu_ctl->counterAvailabilityImage.data = (uint8_t *) malloc(gpu_ctl->counterAvailabilityImage.size);
if (gpu_ctl->counterAvailabilityImage.data == NULL) {
ERRDBG("Failed to allocate memory for counterAvailabilityImage.data.\n");
return PAPI_ENOMEM;
Expand All @@ -484,23 +484,23 @@ void free_and_reset_configuration_images(cuptip_gpu_state_t *gpu_ctl)
COMPDBG("Entering.\n");
// Note that you can find the memory allocation for the below variables
// in cuptip_ctx_start as of April 21st, 2025
papi_free(gpu_ctl->configImage.data);
free(gpu_ctl->configImage.data);
gpu_ctl->configImage.data = NULL;
gpu_ctl->configImage.size = 0;

papi_free(gpu_ctl->counterDataPrefixImage.data);
free(gpu_ctl->counterDataPrefixImage.data);
gpu_ctl->counterDataPrefixImage.data = NULL;
gpu_ctl->counterDataPrefixImage.size = 0;

papi_free(gpu_ctl->counterDataScratchBuffer.data);
free(gpu_ctl->counterDataScratchBuffer.data);
gpu_ctl->counterDataScratchBuffer.data = NULL;
gpu_ctl->counterDataScratchBuffer.size = 0;

papi_free(gpu_ctl->counterDataImage.data);
free(gpu_ctl->counterDataImage.data);
gpu_ctl->counterDataImage.data = NULL;
gpu_ctl->counterDataImage.size = 0;

papi_free(gpu_ctl->counterAvailabilityImage.data);
free(gpu_ctl->counterAvailabilityImage.data);
gpu_ctl->counterAvailabilityImage.data = NULL;
gpu_ctl->counterAvailabilityImage.size = 0;
}
Expand Down Expand Up @@ -534,7 +534,7 @@ static int init_main_htable(void)
val *= base;
}

cuptiu_table_p = (cuptiu_event_table_t *) papi_malloc(sizeof(cuptiu_event_table_t));
cuptiu_table_p = (cuptiu_event_table_t *) malloc(sizeof(cuptiu_event_table_t));
if (cuptiu_table_p == NULL) {
ERRDBG("Failed to allocate memory for cuptiu_table_p.\n");
return PAPI_ENOMEM;
Expand All @@ -543,19 +543,19 @@ static int init_main_htable(void)
cuptiu_table_p->count = 0;
cuptiu_table_p->event_stats_count = 0;

cuptiu_table_p->events = (cuptiu_event_t *) papi_calloc(val, sizeof(cuptiu_event_t));
cuptiu_table_p->events = (cuptiu_event_t *) calloc(val, sizeof(cuptiu_event_t));
if (cuptiu_table_p->events == NULL) {
ERRDBG("Failed to allocate memory for cuptiu_table_p->events.\n");
return PAPI_ENOMEM;
}

cuptiu_table_p->event_stats = (StringVector *) papi_calloc(val, sizeof(StringVector));
cuptiu_table_p->event_stats = (StringVector *) calloc(val, sizeof(StringVector));
if (cuptiu_table_p->event_stats == NULL) {
ERRDBG("Failed to allocate memory for cuptiu_table_p->event_stats.\n");
return PAPI_ENOMEM;
}

cuptiu_table_p->avail_gpu_info = (gpu_record_t *) papi_calloc(numDevicesOnMachine, sizeof(gpu_record_t));
cuptiu_table_p->avail_gpu_info = (gpu_record_t *) calloc(numDevicesOnMachine, sizeof(gpu_record_t));
if (cuptiu_table_p->avail_gpu_info == NULL) {
ERRDBG("Failed to allocate memory for cuptiu_table_p->avail_gpu_info.\n");
return PAPI_ENOMEM;
Expand Down Expand Up @@ -732,19 +732,19 @@ int cuptip_ctx_create(cuptic_info_t thr_info, cuptip_control_t *pstate, uint32_t
{
COMPDBG("Entering.\n");

cuptip_control_t state = (cuptip_control_t) papi_calloc (1, sizeof(struct cuptip_control_s));
cuptip_control_t state = (cuptip_control_t) calloc (1, sizeof(struct cuptip_control_s));
if (state == NULL) {
SUBDBG("Failed to allocate memory for state.\n");
return PAPI_ENOMEM;
}

state->gpu_ctl = (cuptip_gpu_state_t *) papi_calloc(numDevicesOnMachine, sizeof(cuptip_gpu_state_t));
state->gpu_ctl = (cuptip_gpu_state_t *) calloc(numDevicesOnMachine, sizeof(cuptip_gpu_state_t));
if (state->gpu_ctl == NULL) {
SUBDBG("Failed to allocate memory for state->gpu_ctl.\n");
return PAPI_ENOMEM;
}

long long *counters = (long long *) papi_malloc(num_events * sizeof(*counters));
long long *counters = (long long *) malloc(num_events * sizeof(*counters));
if (counters == NULL) {
SUBDBG("Failed to allocate memory for counters.\n");
return PAPI_ENOMEM;
Expand Down Expand Up @@ -1034,7 +1034,7 @@ int cuptip_ctx_read(cuptip_control_t state, long long **counters)
}
}
}
papi_free(metricValues);
free(metricValues);
*counters = counter_vals;

papi_errno = begin_pass();
Expand Down Expand Up @@ -1165,15 +1165,15 @@ int cuptip_ctx_destroy(cuptip_control_t *pstate)
// Free the created rawMetricRequests from cuptip_ctx_start
int j;
for (j = 0; j < state->gpu_ctl[i].numberOfRawMetricRequests; j++) {
papi_free((void *) state->gpu_ctl[i].rawMetricRequests[j].pMetricName);
free((void *) state->gpu_ctl[i].rawMetricRequests[j].pMetricName);
}
papi_free(state->gpu_ctl[i].rawMetricRequests);
free(state->gpu_ctl[i].rawMetricRequests);
}

// Free the allocated memory from cuptip_ctx_create
papi_free(state->counters);
papi_free(state->gpu_ctl);
papi_free(state);
free(state->counters);
free(state->gpu_ctl);
free(state);
*pstate = NULL;

return PAPI_OK;
Expand Down Expand Up @@ -1522,13 +1522,13 @@ static void shutdown_event_table(void)
{
cuptiu_table_p->count = 0;

papi_free(cuptiu_table_p->avail_gpu_info);
free(cuptiu_table_p->avail_gpu_info);
cuptiu_table_p->avail_gpu_info = NULL;

papi_free(cuptiu_table_p->events);
free(cuptiu_table_p->events);
cuptiu_table_p->events = NULL;

papi_free(cuptiu_table_p);
free(cuptiu_table_p);
cuptiu_table_p = NULL;
}

Expand All @@ -1545,7 +1545,7 @@ static void shutdown_event_stats_table(void)

cuptiu_table_p->event_stats_count = 0;

papi_free(cuptiu_table_p->event_stats);
free(cuptiu_table_p->event_stats);
}

/** @class cuptip_evt_enum
Expand Down
6 changes: 3 additions & 3 deletions src/components/cuda/cupti_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

int cuptiu_event_table_create_init_capacity(int capacity, int sizeof_rec, cuptiu_event_table_t **pevt_table)
{
cuptiu_event_table_t *evt_table = (cuptiu_event_table_t *) papi_malloc(sizeof(cuptiu_event_table_t));
cuptiu_event_table_t *evt_table = (cuptiu_event_table_t *) malloc(sizeof(cuptiu_event_table_t));
if (evt_table == NULL) {
goto fn_fail;
}
Expand Down Expand Up @@ -48,7 +48,7 @@ void cuptiu_event_table_destroy(cuptiu_event_table_t **pevt_table)
evt_table->htable = NULL;
}

papi_free(evt_table);
free(evt_table);
*pevt_table = NULL;
}

Expand Down Expand Up @@ -133,4 +133,4 @@ void free_vector(StringVector *vec) {
}
free(vec->arrayMetricStatistics);
vec->arrayMetricStatistics = NULL;
}
}
18 changes: 9 additions & 9 deletions src/components/cuda/htable.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ htable_insert(void *handle, const char *key, void *in)
return htable_errno;
fn_fail:
if (entry) {
papi_free(entry);
free(entry);
}
goto fn_exit;
}
Expand Down Expand Up @@ -196,13 +196,13 @@ create_table(uint64_t size, struct hash_table **table)
{
int htable_errno = HTABLE_SUCCESS;

*table = papi_calloc(1, sizeof(**table));
*table = calloc(1, sizeof(**table));
if (table == NULL) {
htable_errno = HTABLE_ENOMEM;
goto fn_exit;
}

(*table)->buckets = papi_calloc(size, sizeof(*(*table)->buckets));
(*table)->buckets = calloc(size, sizeof(*(*table)->buckets));
if ((*table)->buckets == NULL) {
htable_errno = HTABLE_ENOMEM;
goto fn_exit;
Expand All @@ -220,11 +220,11 @@ destroy_table(struct hash_table *table)
int htable_errno = HTABLE_SUCCESS;

if (table && table->buckets) {
papi_free(table->buckets);
free(table->buckets);
}

if (table) {
papi_free(table);
free(table);
}

return htable_errno;
Expand Down Expand Up @@ -258,7 +258,7 @@ move_table(struct hash_table *new_table, struct hash_table *old_table)
old_table->size = new_table->size;
old_table->buckets = new_table->buckets;
new_table->buckets = NULL;
papi_free(old_buckets);
free(old_buckets);

return htable_errno;
}
Expand Down Expand Up @@ -322,7 +322,7 @@ create_table_entry(const char *key, void *val, struct hash_table_entry **entry)
{
int htable_errno = HTABLE_SUCCESS;

*entry = papi_calloc(1, sizeof(**entry));
*entry = calloc(1, sizeof(**entry));
if (*entry == NULL) {
return HTABLE_ENOMEM;
}
Expand All @@ -337,8 +337,8 @@ int
destroy_table_entry(struct hash_table_entry *entry)
{
int htable_errno = HTABLE_SUCCESS;
papi_free(entry->key);
papi_free(entry);
free(entry->key);
free(entry);
return htable_errno;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/cuda/linux-cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ int update_native_events(cuda_control_t *ctl, NativeInfo_t *ntv_info,
struct event_map_item sorted_events[PAPI_CUDA_MAX_COUNTERS];

if (ntv_count != ctl->num_events) {
ctl->events_id = papi_realloc(ctl->events_id,
ctl->events_id = realloc(ctl->events_id,
ntv_count * sizeof(*ctl->events_id));
if (ctl->events_id == NULL) {
papi_errno = PAPI_ENOMEM;
Expand Down Expand Up @@ -642,7 +642,7 @@ static int cuda_cleanup_eventset(hwd_control_state_t *ctl)
}

/* free int array of event id's and reset number of events */
papi_free(cuda_ctl->events_id);
free(cuda_ctl->events_id);
cuda_ctl->events_id = NULL;
cuda_ctl->num_events = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/components/cuda/papi_cupti_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ int cuptic_ctxarr_create(cuptic_info_t *pinfo)
}

/* allocate memory */
*pinfo = (cuptic_info_t) papi_calloc (total_gpus, sizeof(*pinfo));
*pinfo = (cuptic_info_t) calloc (total_gpus, sizeof(*pinfo));
if (*pinfo == NULL) {
return PAPI_ENOMEM;
}
Expand Down Expand Up @@ -837,7 +837,7 @@ int cuptic_ctxarr_get_ctx(cuptic_info_t info, int gpu_idx, CUcontext *ctx)

int cuptic_ctxarr_destroy(cuptic_info_t *pinfo)
{
papi_free(*pinfo);
free(*pinfo);
*pinfo = NULL;
return PAPI_OK;
}
Expand Down
13 changes: 7 additions & 6 deletions src/components/infiniband/linux-infiniband.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,12 @@ add_ib_device(const char* name, int port)
return (0);
}

new_dev->dev_name = strdup(name);
new_dev->dev_name = papi_strdup(name);
new_dev->dev_port = port;
if (new_dev->dev_name==0)
{
PAPIERROR("cannot allocate memory for device internal fields");
papi_free(new_dev->dev_name);
papi_free(new_dev);
return (0);
}
Expand All @@ -328,8 +329,8 @@ add_ib_counter(const char* name, const char* file_name, int extended, ib_device_
return (0);
}

new_cnt->ev_name = strdup(name);
new_cnt->ev_file_name = strdup(file_name);
new_cnt->ev_name = papi_strdup(name);
new_cnt->ev_file_name = papi_strdup(file_name);
new_cnt->extended = extended;
new_cnt->ev_device = device;
if (new_cnt->ev_name==0 || new_cnt->ev_file_name==0)
Expand Down Expand Up @@ -599,9 +600,9 @@ deallocate_infiniband_resources()
{
for (i=0 ; i<num_events ; ++i) {
if (infiniband_native_events[i].name)
free(infiniband_native_events[i].name);
papi_free(infiniband_native_events[i].name);
if (infiniband_native_events[i].file_name)
free(infiniband_native_events[i].file_name);
papi_free(infiniband_native_events[i].file_name);
if (infiniband_native_events[i].description)
papi_free(infiniband_native_events[i].description);
}
Expand All @@ -612,7 +613,7 @@ deallocate_infiniband_resources()
while (iter != 0)
{
if (iter->dev_name)
free(iter->dev_name);
papi_free(iter->dev_name);

ib_device_t *tmp = iter;
iter = iter->next;
Expand Down
2 changes: 1 addition & 1 deletion src/components/net/linux-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ generateNetEventList( void )
} else if (last) {
last->next = temp;
} else {
free(temp);
papi_free(temp);
fclose(fin);
PAPIERROR("This shouldn't be possible\n");
snprintf(_net_vector.cmp_info.disabled_reason, PAPI_MAX_STR_LEN-2,
Expand Down
2 changes: 1 addition & 1 deletion src/components/rocm/htable.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ create_table_entry(const char *key, void *val, struct hash_table_entry **entry)
if (*entry == NULL) {
return HTABLE_ENOMEM;
}
(*entry)->key = strdup(key);
(*entry)->key = papi_strdup(key);
(*entry)->val = val;
(*entry)->next = NULL;

Expand Down
2 changes: 1 addition & 1 deletion src/components/rocm_smi/htable.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ create_table_entry(const char *key, void *val, struct hash_table_entry **entry)
if (*entry == NULL) {
return HTABLE_ENOMEM;
}
(*entry)->key = strdup(key);
(*entry)->key = papi_strdup(key);
(*entry)->val = val;
(*entry)->next = NULL;

Expand Down
Loading