diff --git a/src/arch/helperrvv.h b/src/arch/helperrvv.h index f304434a..28e82c81 100644 --- a/src/arch/helperrvv.h +++ b/src/arch/helperrvv.h @@ -163,7 +163,7 @@ typedef vfloat64m1x4_t tdi_t; // The configuration didn't provide a constant vector length, meaning it'll // have to be determined at run-time. RVV offers per-data-width operations for // this so the result doesn't need to be adjusted and that operation is likely -// to fold into the surrounding code for free. +// to fold into the surrounding code for Sleef_free. // #define VECTLENSP (__riscv_vsetvlmax_e32m1()) #define VECTLENDP SLEEF_RVV_DP_RUNTIME_VL() @@ -273,7 +273,7 @@ typedef vfloat64m2x4_t tdi_t; // The configuration didn't provide a constant vector length, meaning it'll // have to be determined at run-time. RVV offers per-data-width operations for // this so the result doesn't need to be adjusted and that operation is likely -// to fold into the surrounding code for free. +// to fold into the surrounding code for Sleef_free. // #define VECTLENSP (__riscv_vsetvlmax_e32m2()) #define VECTLENDP SLEEF_RVV_DP_RUNTIME_VL() diff --git a/src/common/arraymap.c b/src/common/arraymap.c index 78b26c6c..b227da47 100644 --- a/src/common/arraymap.c +++ b/src/common/arraymap.c @@ -85,7 +85,7 @@ ArrayMap *initArrayMap() { for(int i=0;icapacity[i] = 8; - thiz->array[i] = (ArrayMapNode *)malloc(thiz->capacity[i] * sizeof(ArrayMapNode)); + thiz->array[i] = (ArrayMapNode *)Sleef_malloc(thiz->capacity[i] * sizeof(ArrayMapNode)); thiz->size[i] = 0; } @@ -101,11 +101,11 @@ void ArrayMap_dispose(ArrayMap *thiz) { assert(thiz->array[j][i].magic == MAGIC_ARRAYMAPNODE); thiz->array[j][i].magic = 0; } - free(thiz->array[j]); + Sleef_free(thiz->array[j]); } thiz->magic = 0; - free(thiz); + Sleef_free(thiz); } int ArrayMap_size(ArrayMap *thiz) { @@ -115,7 +115,7 @@ int ArrayMap_size(ArrayMap *thiz) { uint64_t *ArrayMap_keyArray(ArrayMap *thiz) { assert(thiz != NULL && thiz->magic == MAGIC_ARRAYMAP); - uint64_t *a = (uint64_t *)malloc(sizeof(uint64_t) * thiz->totalSize); + uint64_t *a = (uint64_t *)Sleef_malloc(sizeof(uint64_t) * thiz->totalSize); int p = 0; for(int j=0;jsize[j];i++) { @@ -128,7 +128,7 @@ uint64_t *ArrayMap_keyArray(ArrayMap *thiz) { void **ArrayMap_valueArray(ArrayMap *thiz) { assert(thiz != NULL && thiz->magic == MAGIC_ARRAYMAP); - void **a = (void **)malloc(sizeof(void *) * thiz->totalSize); + void **a = (void **)Sleef_malloc(sizeof(void *) * thiz->totalSize); int p = 0; for(int j=0;jsize[j];i++) { @@ -218,7 +218,7 @@ ArrayMap *ArrayMap_load(const char *fn, const char *prefix, const char *idstr, i ArrayMap *thiz = initArrayMap(); - char *prefix2 = malloc(prefixLen+10); + char *prefix2 = Sleef_malloc(prefixLen+10); strcpy(prefix2, prefix); String_trim(prefix2); for(char *p = prefix2;*p != '\0';p++) { @@ -228,15 +228,15 @@ ArrayMap *ArrayMap_load(const char *fn, const char *prefix, const char *idstr, i strcat(prefix2, " : "); prefixLen = (int)strlen(prefix2); - char *line = malloc(sizeof(char) * (LINELEN+10)); + char *line = Sleef_malloc(sizeof(char) * (LINELEN+10)); line[idstrlen] = '\0'; if (fread(line, sizeof(char), idstrlen, fp) != idstrlen || strcmp(idstr, line) != 0) { if (doLock) FUNLOCK(fp); fclose(fp); - free(prefix2); - free(line); + Sleef_free(prefix2); + Sleef_free(line); return NULL; } @@ -246,20 +246,20 @@ ArrayMap *ArrayMap_load(const char *fn, const char *prefix, const char *idstr, i if (strncmp(line, prefix2, prefixLen) != 0) continue; uint64_t key; - char *value = malloc(sizeof(char) * LINELEN); + char *value = Sleef_malloc(sizeof(char) * LINELEN); if (sscanf(line + prefixLen, "%" SCNx64 " : %s\n", &key, value) == 2) { ArrayMap_put(thiz, (uint64_t)key, (void *)value); } else { - free(value); + Sleef_free(value); } } if (doLock) FUNLOCK(fp); fclose(fp); - free(prefix2); - free(line); + Sleef_free(prefix2); + Sleef_free(line); return thiz; } @@ -274,7 +274,7 @@ int ArrayMap_save(ArrayMap *thiz, const char *fn, const char *prefix, const char // Generate prefix2 - char *prefix2 = malloc(prefixLen+10); + char *prefix2 = Sleef_malloc(prefixLen+10); strcpy(prefix2, prefix); String_trim(prefix2); for(char *p = prefix2;*p != '\0';p++) { @@ -301,7 +301,7 @@ int ArrayMap_save(ArrayMap *thiz, const char *fn, const char *prefix, const char return -1; } - char *line = malloc(sizeof(char) * (LINELEN+10)); + char *line = Sleef_malloc(sizeof(char) * (LINELEN+10)); line[idstrlen] = '\0'; if (fread(line, sizeof(char), idstrlen, fp) == idstrlen && strcmp(idstr, line) == 0) { @@ -323,7 +323,7 @@ int ArrayMap_save(ArrayMap *thiz, const char *fn, const char *prefix, const char fprintf(tmpfp, "%s %" PRIx64 " : %s\n", prefix2, keys[i], value); } - free(keys); + Sleef_free(keys); fseek(fp, 0, SEEK_SET); FTRUNCATE(fp, 0); @@ -341,7 +341,7 @@ int ArrayMap_save(ArrayMap *thiz, const char *fn, const char *prefix, const char fclose(fp); CLOSETMPFILE(tmpfp); - free(prefix2); - free(line); + Sleef_free(prefix2); + Sleef_free(line); return 0; } diff --git a/src/common/common.c b/src/common/common.c index fb84d950..a82887d9 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -25,7 +25,7 @@ EXPORT uint64_t Sleef_currentTimeMicros() { #include EXPORT void *Sleef_malloc(size_t z) { void *ptr = NULL; posix_memalign(&ptr, 256, z); return ptr; } -EXPORT void Sleef_free(void *ptr) { free(ptr); } +EXPORT void Sleef_free(void *ptr) { Sleef_free(ptr); } EXPORT uint64_t Sleef_currentTimeMicros() { struct timeval time; @@ -42,7 +42,7 @@ EXPORT uint64_t Sleef_currentTimeMicros() { #endif EXPORT void *Sleef_malloc(size_t z) { void *ptr = NULL; posix_memalign(&ptr, 4096, z); return ptr; } -EXPORT void Sleef_free(void *ptr) { free(ptr); } +EXPORT void Sleef_free(void *ptr) { Sleef_free(ptr); } EXPORT uint64_t Sleef_currentTimeMicros() { struct timespec tp; @@ -91,9 +91,9 @@ EXPORT void Sleef_free(void *ptr) #if defined(__MINGW32__) || defined(__MINGW64__) || defined(_MSC_VER) _aligned_free(ptr); #elif defined(__APPLE__) - free(ptr); + Sleef_free(ptr); #else // #if defined(__MINGW32__) || defined(__MINGW64__) || defined(_MSC_VER) - free(ptr); + Sleef_free(ptr); #endif } diff --git a/src/dft-tester/naivetest.c b/src/dft-tester/naivetest.c index 39c2d1e7..234400e6 100644 --- a/src/dft-tester/naivetest.c +++ b/src/dft-tester/naivetest.c @@ -99,8 +99,8 @@ int check_cf(int n) { real *sx = (real *)Sleef_malloc(n*2 * sizeof(real)); real *sy = (real *)Sleef_malloc(n*2 * sizeof(real)); - cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); - cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *ts = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); // @@ -144,8 +144,8 @@ int check_cf(int n) { // - free(fs); - free(ts); + Sleef_free(fs); + Sleef_free(ts); Sleef_free(sx); Sleef_free(sy); @@ -163,8 +163,8 @@ int check_cb(int n) { real *sx = (real *)Sleef_malloc(sizeof(real)*n*2); real *sy = (real *)Sleef_malloc(sizeof(real)*n*2); - cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); - cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *ts = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); // @@ -198,8 +198,8 @@ int check_cb(int n) { // - free(fs); - free(ts); + Sleef_free(fs); + Sleef_free(ts); Sleef_free(sx); Sleef_free(sy); @@ -217,8 +217,8 @@ int check_rf(int n) { real *sx = (real *)Sleef_malloc(n * sizeof(real)); real *sy = (real *)Sleef_malloc((n/2+1)*sizeof(real)*2); - cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); - cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *ts = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); // @@ -251,8 +251,8 @@ int check_rf(int n) { // - free(fs); - free(ts); + Sleef_free(fs); + Sleef_free(ts); Sleef_free(sx); Sleef_free(sy); @@ -267,8 +267,8 @@ int check_rf(int n) { int check_rb(int n) { int i; - cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); - cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *ts = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); // @@ -319,8 +319,8 @@ int check_rb(int n) { // - free(fs); - free(ts); + Sleef_free(fs); + Sleef_free(ts); Sleef_free(sx); Sleef_free(sy); @@ -337,8 +337,8 @@ int check_arf(int n) { real *sx = (real *)Sleef_malloc(n * sizeof(real)); real *sy = (real *)Sleef_malloc(n * sizeof(real)); - cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); - cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *ts = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); // @@ -391,8 +391,8 @@ int check_arb(int n) { real *sx = (real *)Sleef_malloc(n * sizeof(real)); real *sy = (real *)Sleef_malloc(n * sizeof(real)); - cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); - cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *ts = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); // @@ -445,8 +445,8 @@ int check_arb(int n) { // - free(fs); - free(ts); + Sleef_free(fs); + Sleef_free(ts); Sleef_free(sx); Sleef_free(sy); diff --git a/src/dft-tester/tutorial.c b/src/dft-tester/tutorial.c index e699e6af..a0da67ce 100644 --- a/src/dft-tester/tutorial.c +++ b/src/dft-tester/tutorial.c @@ -44,8 +44,8 @@ int main(int argc, char **argv) { exit(-1); } - cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); - cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *ts = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)Sleef_malloc(sizeof(cmpl)*n); for(int i=0;iheapCost); - free(q->heapLen); - free(q->heap); - free(q); + Sleef_free(q->heapCost); + Sleef_free(q->heapLen); + Sleef_free(q->heap); + Sleef_free(q); } // returns the number of paths in the heap @@ -1158,7 +1158,7 @@ EXPORT SleefDFT *INIT(uint32_t n, const real *in, real *out, uint64_t mode) { if (p->isa == -1) { if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf("ISA not available\n"); p->magic = 0; - free(p); + Sleef_free(p); return NULL; } @@ -1169,8 +1169,8 @@ EXPORT SleefDFT *INIT(uint32_t n, const real *in, real *out, uint64_t mode) { p->perm[level] = (uint32_t *)Sleef_malloc(sizeof(uint32_t) * ((1 << p->log2len) + 8)); } - p->x0 = malloc(sizeof(real *) * p->nThread); - p->x1 = malloc(sizeof(real *) * p->nThread); + p->x0 = Sleef_malloc(sizeof(real *) * p->nThread); + p->x1 = Sleef_malloc(sizeof(real *) * p->nThread); for(int i=0;inThread;i++) { p->x0[i] = (real *)Sleef_malloc(sizeof(real) * 2 * n); diff --git a/src/dft/dftcommon.c b/src/dft/dftcommon.c index 8972b1e4..c8573fad 100644 --- a/src/dft/dftcommon.c +++ b/src/dft/dftcommon.c @@ -106,7 +106,7 @@ void freeTables(SleefDFT *p) { for(uint32_t level=N;level<=p->log2len;level++) { Sleef_free(p->tbl[N][level]); } - free(p->tbl[N]); + Sleef_free(p->tbl[N]); p->tbl[N] = NULL; } } @@ -118,7 +118,7 @@ EXPORT void SleefDFT_dispose(SleefDFT *p) { if (p->hlen != p->vlen) SleefDFT_dispose(p->instV); p->magic = 0; - free(p); + Sleef_free(p); return; } @@ -126,7 +126,7 @@ EXPORT void SleefDFT_dispose(SleefDFT *p) { if (p->log2len <= 1) { p->magic = 0; - free(p); + Sleef_free(p); return; } @@ -139,13 +139,13 @@ EXPORT void SleefDFT_dispose(SleefDFT *p) { for(int level = p->log2len;level >= 1;level--) { Sleef_free(p->perm[level]); } - free(p->perm); + Sleef_free(p->perm); p->perm = NULL; freeTables(p); p->magic = 0; - free(p); + Sleef_free(p); } uint32_t ilog2(uint32_t q) { @@ -200,17 +200,17 @@ EXPORT void SleefDFT_setPlanFilePath(const char *path, const char *arch, uint64_ planFilePathSet = 0; } - if (dftPlanFilePath != NULL) free(dftPlanFilePath); + if (dftPlanFilePath != NULL) Sleef_free(dftPlanFilePath); if (path != NULL) { - dftPlanFilePath = malloc(strlen(path)+10); + dftPlanFilePath = Sleef_malloc(strlen(path)+10); strcpy(dftPlanFilePath, path); } else { dftPlanFilePath = NULL; } - if (archID != NULL) free(archID); + if (archID != NULL) Sleef_free(archID); if (arch == NULL) arch = Sleef_getCpuIdString(); - archID = malloc(strlen(arch)+10); + archID = Sleef_malloc(strlen(arch)+10); strcpy(archID, arch); planMode = mode; @@ -311,10 +311,10 @@ static uint64_t planMap_getU64(uint64_t key) { } static void planMap_putU64(uint64_t key, uint64_t value) { - char *s = malloc(100); + char *s = Sleef_malloc(100); sprintf(s, "%" PRIx64, value); s = ArrayMap_put(planMap, key, s); - if (s != NULL) free(s); + if (s != NULL) Sleef_free(s); } int PlanManager_loadMeasurementResultsP(SleefDFT *p, int pathCat) { diff --git a/src/gencoef/gencoef.c b/src/gencoef/gencoef.c index 87ea348e..2764ae17 100644 --- a/src/gencoef/gencoef.c +++ b/src/gencoef/gencoef.c @@ -45,7 +45,7 @@ char *mpfrToStr(mpfr_t m) { mpfr_exp_t e; char *s = mpfr_get_str(NULL, &e, 10, 0, fra, GMP_RNDN); - char *ret = malloc(strlen(s) + 20); + char *ret = Sleef_malloc(strlen(s) + 20); if (mpfr_sgn(m) == -1) ret[0] = '-'; else ret[0] = '+'; ret[1] = '0'; @@ -228,7 +228,7 @@ int main(int argc, char **argv) char *s; printf("%s, \n", s = mpfrToStr(fra)); - free(s); + Sleef_free(s); } printf("\n"); @@ -367,7 +367,7 @@ int main(int argc, char **argv) char *s; printf("%s, \n", s = mpfrToStr(fra)); - free(s); + Sleef_free(s); } printf("\nPhase 2 : max error = %g ULP at %g\n", best, bestworstx); diff --git a/src/gencoef/simplexfr.c b/src/gencoef/simplexfr.c index 0200b92f..5b0de0ea 100644 --- a/src/gencoef/simplexfr.c +++ b/src/gencoef/simplexfr.c @@ -54,28 +54,28 @@ static void init(int n0, int m0) { mpfr_init(large); mpfr_set_d(large, 1.0 / EPS, GMP_RNDN); - a = malloc(sizeof(mpfr_t *) * (m + 1)); + a = Sleef_malloc(sizeof(mpfr_t *) * (m + 1)); for(i=0;i < m+1;i++) { - a[i] = malloc(sizeof(mpfr_t) * (n + 1)); + a[i] = Sleef_malloc(sizeof(mpfr_t) * (n + 1)); for(j=0;j < (n+1);j++) { mpfr_zinit(a[i][j]); } } - q = malloc(sizeof(mpfr_t *) * (m + 1)); + q = Sleef_malloc(sizeof(mpfr_t *) * (m + 1)); for(i=0;i < m+1;i++) { - q[i] = malloc(sizeof(mpfr_t) * (m + 1)); + q[i] = Sleef_malloc(sizeof(mpfr_t) * (m + 1)); for(j=0;j < m+1;j++) { mpfr_zinit(q[i][j]); } } - c = malloc(sizeof(mpfr_t) * (n + 1)); + c = Sleef_malloc(sizeof(mpfr_t) * (n + 1)); for(j=0;j < (n+1);j++) { mpfr_zinit(c[j]); } - pivotcolumn = malloc(sizeof(mpfr_t) * (m + 1)); + pivotcolumn = Sleef_malloc(sizeof(mpfr_t) * (m + 1)); for(j=0;j < (m+1);j++) { mpfr_zinit(pivotcolumn[j]); } @@ -95,32 +95,32 @@ static void dispose() { for(j=0;j < m+1;j++) { mpfr_clear(q[i][j]); } - free(q[i]); + Sleef_free(q[i]); } - free(q); + Sleef_free(q); for(i=0;i < m+1;i++) { for(j=0;j < n+1;j++) { mpfr_clear(a[i][j]); } - free(a[i]); + Sleef_free(a[i]); } - free(a); + Sleef_free(a); for(j=0;j < n+1;j++) { mpfr_clear(c[j]); } - free(c); + Sleef_free(c); for(j=0;j < m+1;j++) { mpfr_clear(pivotcolumn[j]); } - free(pivotcolumn); + Sleef_free(pivotcolumn); - free(col); - free(row); - free(nonzero_row); - free(inequality); + Sleef_free(col); + Sleef_free(row); + Sleef_free(nonzero_row); + Sleef_free(inequality); } static void prepare() { @@ -159,8 +159,8 @@ static void tableau(mpfr_t ret, int i, int j) { mpfr_zinit(s); mpfr_set_d(s, 0, GMP_RNDN); - mpfr_t *tab = malloc(sizeof(mpfr_t) * (m + 1)); - mpfr_ptr *ptab = malloc(sizeof(mpfr_ptr) * (m + 1)); + mpfr_t *tab = Sleef_malloc(sizeof(mpfr_t) * (m + 1)); + mpfr_ptr *ptab = Sleef_malloc(sizeof(mpfr_ptr) * (m + 1)); for (k = 0; k <= m; k++) { mpfr_zinit(tab[k]); ptab[k] = (mpfr_ptr)&tab[k]; @@ -170,8 +170,8 @@ static void tableau(mpfr_t ret, int i, int j) { for (k = 0; k <= m; k++) { mpfr_clear(tab[k]); } - free(ptab); - free(tab); + Sleef_free(ptab); + Sleef_free(tab); mpfr_set(ret, s, GMP_RNDN); mpfr_clear(s); @@ -384,7 +384,7 @@ int solve_fr(mpfr_t *result, int n0, int m0, mpfr_t **a0, int *ineq0, mpfr_t *c0 mpfr_clear(cs); for(j=0;jspec) == 'a') { @@ -4110,7 +4110,7 @@ static int printf_output(FILE *fp, const struct printf_info *info, const void *c size_t wlen = fwrite(xbuf, len, 1, fp); - free(xbuf); + Sleef_free(xbuf); return (int)wlen; }