Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a0e0855
checkpoint
TheAssembler1 May 18, 2025
b83b0b0
checkpoint
TheAssembler1 May 18, 2025
37150df
replace free with PDC_free and calloc with PDC_calloc
TheAssembler1 May 19, 2025
1d83878
Committing clang-format changes
github-actions[bot] May 19, 2025
61d55d8
fix more mallocs to PDC_malloc
TheAssembler1 May 19, 2025
fc6bb36
more PDC_free fixes
TheAssembler1 May 19, 2025
f2f657d
Committing clang-format changes
github-actions[bot] May 19, 2025
984950b
Update ubuntu-cache.yml
TheAssembler1 May 19, 2025
ca38e10
remove eno1
TheAssembler1 May 19, 2025
6623032
Merge branch 'pdc_malloc_free_calloc' of https://github.com/TheAssemb…
TheAssembler1 May 19, 2025
4379610
fix realloc
TheAssembler1 May 19, 2025
7f457ca
Committing clang-format changes
github-actions[bot] May 19, 2025
62d864a
Update ubuntu-no-cache.yaml
TheAssembler1 May 19, 2025
2c7f77f
Fix several bugs with error checking with object dim allocation
TheAssembler1 May 19, 2025
e808bac
Merge branch 'pdc_malloc_free_calloc' of https://github.com/TheAssemb…
TheAssembler1 May 19, 2025
3f60338
Committing clang-format changes
github-actions[bot] May 19, 2025
fe517b9
fix bug
TheAssembler1 May 19, 2025
fe1eb91
Committing clang-format changes
github-actions[bot] May 19, 2025
e8c70f1
Update ubuntu-no-cache.yaml
TheAssembler1 May 19, 2025
f4d4932
Update ubuntu-cache.yml
TheAssembler1 May 19, 2025
0382d60
Merge branch 'develop' into pdc_malloc_free_calloc
jeanbez May 20, 2025
3f837bc
Set default value of ndim to 1 in PDCprop_create when using PDC_OBJ_C…
TheAssembler1 May 21, 2025
453f45a
Committing clang-format changes
github-actions[bot] May 21, 2025
444a811
Malloc when defaulting to ndim size 1.
TheAssembler1 May 21, 2025
8815dd1
Merge branch 'pdc_malloc_free_calloc' of https://github.com/TheAssemb…
TheAssembler1 May 21, 2025
2dbdd01
Committing clang-format changes
github-actions[bot] May 21, 2025
0d08ad2
Update README.md
jeanbez May 22, 2025
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Proactive Data Containers (PDC) software provides an object-focused data managem

Full documentation of PDC with installation instructions, code examples for using PDC API, and research publications are available at [pdc.readthedocs.io](https://pdc.readthedocs.io)

More information and publications on PDC is available at https://sdm.lbl.gov/pdc
More information and publications on PDC are available at https://sdm.lbl.gov/pdc

If you use PDC in your research, please use the following citations:

Expand Down
4 changes: 2 additions & 2 deletions src/api/pdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ PDC_class__close(struct _pdc_class *p)
PDC_timing_finalize();
#endif

free(p->name);
p = (struct _pdc_class *)(intptr_t)PDC_free(p);
p->name = (char *)PDC_free(p->name);
p = (struct _pdc_class *)(intptr_t)PDC_free(p);

FUNC_LEAVE(ret_value);
}
Expand Down
19 changes: 10 additions & 9 deletions src/api/pdc_analysis/pdc_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ iterator_init(pdcid_t objectId, pdcid_t reg_id, int blocks, struct _pdc_iterator
}
}
iter->totalElements = 1;
if ((iter->srcDims = (size_t *)calloc(obj_prop_ptr->obj_prop_pub->ndim, sizeof(size_t))) != NULL) {
if ((iter->srcDims = (size_t *)PDC_calloc(obj_prop_ptr->obj_prop_pub->ndim, sizeof(size_t))) !=
NULL) {
iter->ndim = obj_prop_ptr->obj_prop_pub->ndim;
for (i = 0; i < iter->ndim; i++) {
iter->srcDims[i] = (size_t)obj_prop_ptr->obj_prop_pub->dims[i];
Expand Down Expand Up @@ -336,13 +337,13 @@ PDC_get_argv0_()
procpath = strdup(fullPath);
shellcmd = fopen(procpath, "r");
if (shellcmd == NULL) {
free(procpath);
procpath = (char *)PDC_free(procpath);
PGOTO_ERROR(NULL, "fopen failed!");
}
else {
cmdLength = fread(fullPath, 1, sizeof(fullPath), shellcmd);
if (procpath)
free(procpath);
procpath = (char *)PDC_free(procpath);
if (cmdLength > 0) {
_argv0 = strdup(fullPath);
/* truncate the cmdline if any whitespace (space or tab) */
Expand All @@ -366,7 +367,7 @@ PDC_get_argv0_()
/* Get rid of the copy (strdup) of fullPath now in _argv0.
* and replace it with the next (modified/fully_qualified?) version.
*/
free(_argv0);
_argv0 = (char *)PDC_free(_argv0);
_argv0 = next;
}
}
Expand Down Expand Up @@ -460,7 +461,7 @@ PDCobj_analysis_register(char *func, pdcid_t iterIn, pdcid_t iterOut)
thisFtn->ftnPtr = (int (*)())ftnPtr;
thisFtn->n_args = 2;
/* Allocate for iterator ids and region ids */
if ((thisFtn->object_id = (pdcid_t *)calloc(4, sizeof(pdcid_t))) != NULL) {
if ((thisFtn->object_id = (pdcid_t *)PDC_calloc(4, sizeof(pdcid_t))) != NULL) {
thisFtn->object_id[0] = iterIn;
thisFtn->object_id[1] = iterOut;
}
Expand Down Expand Up @@ -497,11 +498,11 @@ PDCobj_analysis_register(char *func, pdcid_t iterIn, pdcid_t iterOut)

done:
if (applicationDir)
free(applicationDir);
applicationDir = (char *)PDC_free(applicationDir);
if (userdefinedftn)
free(userdefinedftn);
userdefinedftn = (char *)PDC_free(userdefinedftn);
if (loadpath)
free(loadpath);
loadpath = (char *)PDC_free(loadpath);

fflush(stdout);
FUNC_LEAVE(ret_value);
Expand Down Expand Up @@ -556,7 +557,7 @@ PDCobj_data_getNextBlock(pdcid_t iter, void **nextBlock, size_t *dims)
if (thisIter->srcStart == NULL) {
if (execution_locus == SERVER_MEMORY) {
if ((thisIter->srcNext = PDC_Server_get_region_data_ptr(thisIter->objectId)) == NULL)
thisIter->srcNext = malloc(thisIter->totalElements * thisIter->element_size);
thisIter->srcNext = PDC_malloc(thisIter->totalElements * thisIter->element_size);
if ((thisIter->srcStart = thisIter->srcNext) == NULL)
PGOTO_ERROR(0, "==PDC_ANALYSIS_SERVER: Unable to allocate iterator storage");

Expand Down
12 changes: 6 additions & 6 deletions src/api/pdc_analysis/pdc_analysis_and_transforms_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ PDC_Client_send_iter_recv_id(pdcid_t iter_id, pdcid_t *meta_id)
hg_atomic_init32(atomic_work_todo_g, 0);
}

my_rpc_state_p = (struct _pdc_my_rpc_state *)calloc(1, sizeof(struct _pdc_my_rpc_state));
my_rpc_state_p = (struct _pdc_my_rpc_state *)PDC_calloc(1, sizeof(struct _pdc_my_rpc_state));
if (my_rpc_state_p == NULL)
PGOTO_ERROR(FAIL, "PDC_Client_send_iter_recv_id(): Could not allocate my_rpc_state");

Expand Down Expand Up @@ -130,7 +130,7 @@ PDC_Client_send_iter_recv_id(pdcid_t iter_id, pdcid_t *meta_id)
done:
fflush(stdout);
HG_Destroy(my_rpc_state_p->handle);
free(my_rpc_state_p);
my_rpc_state_p = (struct _pdc_my_rpc_state *)PDC_free(my_rpc_state_p);

FUNC_LEAVE(ret_value);
}
Expand Down Expand Up @@ -183,7 +183,7 @@ PDC_Client_register_obj_analysis(struct _pdc_region_analysis_ftn_info *thisFtn,
hg_atomic_init32(atomic_work_todo_g, 0);
}

my_rpc_state_p = (struct _pdc_my_rpc_state *)calloc(1, sizeof(struct _pdc_my_rpc_state));
my_rpc_state_p = (struct _pdc_my_rpc_state *)PDC_calloc(1, sizeof(struct _pdc_my_rpc_state));
if (my_rpc_state_p == NULL)
PGOTO_ERROR(FAIL, "PDC_Client_register_obj_analysis(): Could not allocate my_rpc_state");

Expand Down Expand Up @@ -250,7 +250,7 @@ PDC_Client_register_obj_analysis(struct _pdc_region_analysis_ftn_info *thisFtn,
done:
fflush(stdout);
HG_Destroy(my_rpc_state_p->handle);
free(my_rpc_state_p);
my_rpc_state_p = (struct _pdc_my_rpc_state *)PDC_free(my_rpc_state_p);

FUNC_LEAVE(ret_value);
}
Expand Down Expand Up @@ -301,7 +301,7 @@ PDC_Client_register_region_transform(const char *func, const char *loadpath,
hg_atomic_init32(atomic_work_todo_g, 0);
}

my_rpc_state_p = (struct _pdc_my_rpc_state *)calloc(1, sizeof(struct _pdc_my_rpc_state));
my_rpc_state_p = (struct _pdc_my_rpc_state *)PDC_calloc(1, sizeof(struct _pdc_my_rpc_state));
if (my_rpc_state_p == NULL)
PGOTO_ERROR(FAIL, "Could not allocate my_rpc_state");

Expand Down Expand Up @@ -345,7 +345,7 @@ PDC_Client_register_region_transform(const char *func, const char *loadpath,
if (object_info)
PDC_free_obj_info(object_info);
HG_Destroy(my_rpc_state_p->handle);
free(my_rpc_state_p);
my_rpc_state_p = (struct _pdc_my_rpc_state *)PDC_free(my_rpc_state_p);

FUNC_LEAVE(ret_value);
}
Expand Down
59 changes: 32 additions & 27 deletions src/api/pdc_analysis/pdc_analysis_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "pdc_analysis_and_transforms_common.h"
#include "pdc_client_server_common.h"
#include "pdc_analysis_pkg.h"
#include "pdc_malloc.h"
#include "pdc_region.h"
#include "pdc_server_analysis.h"
#include "pdc_logger.h"
Expand Down Expand Up @@ -90,7 +91,7 @@ pdc_analysis_registry_init_(size_t newSize)
FUNC_ENTER(NULL);

if (pdc_region_analysis_registry == NULL) {
new_registry = (struct _pdc_region_analysis_ftn_info **)calloc(sizeof(void *), newSize);
new_registry = (struct _pdc_region_analysis_ftn_info **)PDC_calloc(sizeof(void *), newSize);
if (new_registry) {
hg_atomic_init32(&registered_analysis_ftn_count_g, 0);
pdc_region_analysis_registry = new_registry;
Expand All @@ -99,11 +100,12 @@ pdc_analysis_registry_init_(size_t newSize)
}
}
else if (newSize > analysis_registry_size) {
new_registry = (struct _pdc_region_analysis_ftn_info **)calloc(sizeof(void *), newSize);
new_registry = (struct _pdc_region_analysis_ftn_info **)PDC_calloc(sizeof(void *), newSize);
if (new_registry) {
size_t copysize = analysis_registry_size * sizeof(void *);
memcpy(new_registry, pdc_region_analysis_registry, copysize);
free(pdc_region_analysis_registry);
pdc_region_analysis_registry =
(struct _pdc_region_analysis_ftn_info **)PDC_free(pdc_region_analysis_registry);
pdc_region_analysis_registry = new_registry;
analysis_registry_size = newSize;
PGOTO_DONE(newSize);
Expand All @@ -125,7 +127,7 @@ pdc_transform_registry_init_(size_t newSize)
FUNC_ENTER(NULL);

if (pdc_region_transform_registry == NULL) {
new_registry = (struct _pdc_region_transform_ftn_info **)calloc(sizeof(void *), newSize);
new_registry = (struct _pdc_region_transform_ftn_info **)PDC_calloc(sizeof(void *), newSize);
if (new_registry) {
hg_atomic_init32(&registered_transform_ftn_count_g, 0);
pdc_region_transform_registry = new_registry;
Expand All @@ -134,11 +136,12 @@ pdc_transform_registry_init_(size_t newSize)
}
}
else if (newSize > transform_registry_size) {
new_registry = (struct _pdc_region_transform_ftn_info **)calloc(sizeof(void *), newSize);
new_registry = (struct _pdc_region_transform_ftn_info **)PDC_calloc(sizeof(void *), newSize);
if (new_registry) {
copysize = transform_registry_size * sizeof(void *);
memcpy(new_registry, pdc_region_transform_registry, copysize);
free(pdc_region_transform_registry);
pdc_region_transform_registry =
(struct _pdc_region_transform_ftn_info **)PDC_free(pdc_region_transform_registry);
pdc_region_transform_registry = new_registry;
transform_registry_size = newSize;
PGOTO_DONE(newSize);
Expand All @@ -161,11 +164,12 @@ pdc_analysis_registry_finalize_()
if ((pdc_region_analysis_registry != NULL) && (analysis_registry_size > 0)) {
while (hg_atomic_get32(&i) > 0) {
if (pdc_region_analysis_registry[i - 1])
free(pdc_region_analysis_registry[i - 1]);
pdc_region_analysis_registry[i - 1] = NULL;
pdc_region_analysis_registry[i - 1] =
(struct _pdc_region_analysis_ftn_info *)PDC_free(pdc_region_analysis_registry[i - 1]);
hg_atomic_decr32(&i);
}
free(pdc_region_analysis_registry);
pdc_region_analysis_registry =
(struct _pdc_region_analysis_ftn_info **)PDC_free(pdc_region_analysis_registry);
analysis_registry_size = 0;
hg_atomic_init32(&registered_analysis_ftn_count_g, 0);
}
Expand Down Expand Up @@ -250,12 +254,12 @@ PDCiter_get_nextId(void)
FUNC_ENTER(NULL);

if (PDC_Block_iterator_cache == NULL) {
PDC_Block_iterator_cache =
(struct _pdc_iterator_info *)calloc(iterator_cache_entries, sizeof(struct _pdc_iterator_info));
PDC_Block_iterator_cache = (struct _pdc_iterator_info *)PDC_calloc(iterator_cache_entries,
sizeof(struct _pdc_iterator_info));
if (PDC_Block_iterator_cache == NULL)
PGOTO_ERROR(-1, "calloc failed");

i_cache_freed = (int *)calloc(iterator_cache_entries, sizeof(int));
i_cache_freed = (int *)PDC_calloc(iterator_cache_entries, sizeof(int));
/* Index 0 is NOT-USED other than to indicate an empty iterator */
hg_atomic_init32(&i_cache_index, 1);
hg_atomic_init32(&i_free_index, 0);
Expand All @@ -274,15 +278,15 @@ PDCiter_get_nextId(void)
/* Realloc the cache and free list */
previous_i_cache_freed = i_cache_freed;
previous_state = PDC_Block_iterator_cache;
PDC_Block_iterator_cache = (struct _pdc_iterator_info *)calloc(iterator_cache_entries * 2,
sizeof(struct _pdc_iterator_info));
PDC_Block_iterator_cache = (struct _pdc_iterator_info *)PDC_calloc(iterator_cache_entries * 2,
sizeof(struct _pdc_iterator_info));
memcpy(PDC_Block_iterator_cache, previous_state,
iterator_cache_entries * sizeof(struct _pdc_iterator_info));
i_cache_freed = (int *)calloc(iterator_cache_entries * 2, sizeof(int));
i_cache_freed = (int *)PDC_calloc(iterator_cache_entries * 2, sizeof(int));
memcpy(i_cache_freed, previous_i_cache_freed, iterator_cache_entries * sizeof(int));
iterator_cache_entries *= 2;
free(previous_i_cache_freed);
free(previous_state);
previous_i_cache_freed = (int *)PDC_free(previous_i_cache_freed);
previous_state = (struct _pdc_iterator_info *)PDC_free(previous_state);
}

ret_value = nextId;
Expand Down Expand Up @@ -492,11 +496,11 @@ HG_TEST_RPC_CB(analysis_ftn, handle)
* Otherwise, go ahead and register...
*/
if (nulliter_count < 2) {
if ((thisFtn = (struct _pdc_region_analysis_ftn_info *)calloc(
if ((thisFtn = (struct _pdc_region_analysis_ftn_info *)PDC_calloc(
sizeof(struct _pdc_region_analysis_ftn_info), 1)) != NULL) {
thisFtn->ftnPtr = (int (*)())ftnPtr;
thisFtn->n_args = 2;
thisFtn->object_id = (pdcid_t *)calloc(2, sizeof(pdcid_t));
thisFtn->object_id = (pdcid_t *)PDC_calloc(2, sizeof(pdcid_t));
registrationId = PDC_add_analysis_ptr_to_registry_(thisFtn);
out.remote_ftn_id = registrationId;
}
Expand Down Expand Up @@ -601,10 +605,11 @@ PDC_free_analysis_registry()

if (pdc_region_analysis_registry && (registered_analysis_ftn_count_g > 0)) {
for (index = 0; index < registered_analysis_ftn_count_g; index++) {
free(pdc_region_analysis_registry[index]);
pdc_region_analysis_registry[index] =
(struct _pdc_region_analysis_ftn_info *)PDC_free(pdc_region_analysis_registry[index]);
}
free(pdc_region_analysis_registry);
pdc_region_analysis_registry = NULL;
pdc_region_analysis_registry =
(struct _pdc_region_analysis_ftn_info **)PDC_free(pdc_region_analysis_registry);
}

FUNC_LEAVE_VOID;
Expand All @@ -619,10 +624,11 @@ PDC_free_transform_registry()

if (pdc_region_transform_registry && (registered_transform_ftn_count_g > 0)) {
for (index = 0; index < registered_transform_ftn_count_g; index++) {
free(pdc_region_transform_registry[index]);
pdc_region_transform_registry[index] =
(struct _pdc_region_transform_ftn_info *)PDC_free(pdc_region_transform_registry[index]);
}
free(pdc_region_transform_registry);
pdc_region_transform_registry = NULL;
pdc_region_transform_registry =
(struct _pdc_region_transform_ftn_info **)PDC_free(pdc_region_transform_registry);
}

FUNC_LEAVE_VOID;
Expand All @@ -635,8 +641,7 @@ PDC_free_iterator_cache()
FUNC_ENTER(NULL);

if (PDC_Block_iterator_cache != NULL)
free(PDC_Block_iterator_cache);
PDC_Block_iterator_cache = NULL;
PDC_Block_iterator_cache = (struct _pdc_iterator_info *)PDC_free(PDC_Block_iterator_cache);

FUNC_LEAVE_VOID;
}
23 changes: 12 additions & 11 deletions src/api/pdc_analysis/pdc_hist_pkg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "pdc_logger.h"
#include "pdc_malloc.h"

#define MACRO_SAMPLE_MIN_MAX(TYPE, n, data, sample_pct, min, max) \
({ \
Expand Down Expand Up @@ -123,11 +124,11 @@ PDC_create_hist(pdc_var_type_t dtype, int nbin, double min, double max)
bin_incr = floor_power_of_2((max - min) / (nbin - 2)); // Excluding first and last bin (open ended)
nbin = ceil((max - min) / bin_incr);

hist = (pdc_histogram_t *)malloc(sizeof(pdc_histogram_t));
hist = (pdc_histogram_t *)PDC_malloc(sizeof(pdc_histogram_t));
hist->incr = bin_incr;
hist->dtype = dtype;
hist->range = (double *)calloc(sizeof(double), nbin * 2);
hist->bin = (uint64_t *)calloc(sizeof(uint64_t), nbin);
hist->range = (double *)PDC_calloc(sizeof(double), nbin * 2);
hist->bin = (uint64_t *)PDC_calloc(sizeof(uint64_t), nbin);
hist->nbin = nbin;

min_bin = floor(min);
Expand Down Expand Up @@ -292,9 +293,9 @@ PDC_free_hist(pdc_histogram_t *hist)
if (NULL == hist)
PGOTO_DONE_VOID;

free(hist->range);
free(hist->bin);
free(hist);
hist->range = (double *)PDC_free(hist->range);
hist->bin = (uint64_t *)PDC_free(hist->bin);
hist = (pdc_histogram_t *)PDC_free(hist);

done:
fflush(stdout);
Expand Down Expand Up @@ -337,11 +338,11 @@ PDC_dup_hist(pdc_histogram_t *hist)
PGOTO_DONE(NULL);

nbin = hist->nbin;
res = (pdc_histogram_t *)malloc(sizeof(pdc_histogram_t));
res = (pdc_histogram_t *)PDC_malloc(sizeof(pdc_histogram_t));
res->dtype = hist->dtype;
res->nbin = nbin;
res->range = (double *)calloc(sizeof(double), nbin * 2);
res->bin = (uint64_t *)calloc(sizeof(uint64_t), nbin);
res->range = (double *)PDC_calloc(sizeof(double), nbin * 2);
res->bin = (uint64_t *)PDC_calloc(sizeof(uint64_t), nbin);
res->incr = hist->incr;

memcpy(res->range, hist->range, sizeof(double) * nbin * 2);
Expand Down Expand Up @@ -434,10 +435,10 @@ PDC_copy_hist(pdc_histogram_t *to, pdc_histogram_t *from)
to->incr = from->incr;
to->dtype = from->dtype;
if (NULL == to->range)
to->range = (double *)calloc(sizeof(double), nbin * 2);
to->range = (double *)PDC_calloc(sizeof(double), nbin * 2);
memcpy(to->range, from->range, sizeof(double) * nbin * 2);
if (NULL == to->bin)
to->bin = (uint64_t *)calloc(sizeof(uint64_t), nbin);
to->bin = (uint64_t *)PDC_calloc(sizeof(uint64_t), nbin);
memcpy(to->bin, from->bin, sizeof(uint64_t) * nbin);
to->nbin = from->nbin;

Expand Down
Loading
Loading