Skip to content

Commit

Permalink
change unsinged long and unsigned lont to size_t
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSiebert1 committed Dec 22, 2024
1 parent 95ccd8d commit 969e65c
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 109 deletions.
3 changes: 1 addition & 2 deletions ADOL-C/examples/additional_examples/sparse/jacpatexam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ void eval_small(short tag, double *xp, double *yp) {
}

/*--------------------------------------------------------------------------*/
const unsigned int NM =
961; // PQ_STRIPMINE_MAX * 8*sizeof(unsigned long int) + 1
const unsigned int NM = 961; // PQ_STRIPMINE_MAX * 8*sizeof(size_t) + 1

void eval_arrow_like_matrix(short tag, double *xp, double *yp) {
unsigned int i, j;
Expand Down
8 changes: 4 additions & 4 deletions ADOL-C/include/adolc/adalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ ADOLC_DLL_EXPORT void myfreeI2(int, double **);

ADOLC_DLL_EXPORT unsigned int *myalloc1_uint(int);

ADOLC_DLL_EXPORT unsigned long int *myalloc1_ulong(int);
ADOLC_DLL_EXPORT unsigned long int **myalloc2_ulong(int, int);
ADOLC_DLL_EXPORT size_t *myalloc1_ulong(int);
ADOLC_DLL_EXPORT size_t **myalloc2_ulong(int, int);

/****************************************************************************/
/* INTEGER VARIANT FOR BIT PATTERN PROPAGATION */

ADOLC_DLL_EXPORT void myfree1_uint(unsigned int *);

ADOLC_DLL_EXPORT void myfree1_ulong(unsigned long int *);
ADOLC_DLL_EXPORT void myfree2_ulong(unsigned long int **);
ADOLC_DLL_EXPORT void myfree1_ulong(size_t *);
ADOLC_DLL_EXPORT void myfree2_ulong(size_t **);

END_C_DECLS

Expand Down
18 changes: 7 additions & 11 deletions ADOL-C/include/adolc/interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,15 @@ ADOLC_DLL_EXPORT fint hov_wk_forward_(fint *, fint *, fint *, fint *, fint *,
/* INT_FOR, SAFE */
/* int_forward_safe(tag, m, n, p, X[n][p], Y[m][p]) */

ADOLC_DLL_EXPORT int int_forward_safe(short, int, int, int,
unsigned long int **,
unsigned long int **);
ADOLC_DLL_EXPORT int int_forward_safe(short, int, int, int, size_t **,
size_t **);

/*--------------------------------------------------------------------------*/
/* INT_FOR, TIGHT */
/* int_forward_tight(tag, m, n, p, x[n], X[n][p], y[m], Y[m][p]) */

ADOLC_DLL_EXPORT int int_forward_tight(short, int, int, int, const double *,
unsigned long int **, double *,
unsigned long int **);
size_t **, double *, size_t **);

/****************************************************************************/
/* INDEX DOMAIN UTILITIES */
Expand Down Expand Up @@ -429,17 +427,15 @@ ADOLC_DLL_EXPORT fint hov_ti_reverse_(fint *, fint *, fint *, fint *, fint *,
/* INT_REV, TIGHT */
/* int_reverse_tight(tag, m, n, q, U[q][m], Z[q][n]) */

ADOLC_DLL_EXPORT int int_reverse_tight(short, int, int, int,
unsigned long int **,
unsigned long int **);
ADOLC_DLL_EXPORT int int_reverse_tight(short, int, int, int, size_t **,
size_t **);

/*--------------------------------------------------------------------------*/
/* INT_REV, SAFE */
/* int_reverse_safe(tag, m, n, q, U[q][m], Z[q][n]) */

ADOLC_DLL_EXPORT int int_reverse_safe(short, int, int, int,
unsigned long int **,
unsigned long int **);
ADOLC_DLL_EXPORT int int_reverse_safe(short, int, int, int, size_t **,
size_t **);

/*--------------------------------------------------------------------------*/
ADOLC_DLL_EXPORT int get_num_switches(short);
Expand Down
17 changes: 8 additions & 9 deletions ADOL-C/include/adolc/sparse/sparse_fo_rev.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ package.
/* */
/* nBV = number of Boolean Vectors to be packed */
/* (see Chapter Dependence Analysis, ADOL-C Documentation) */
/* bits_per_long = 8*sizeof(unsigned long int) */
/* bits_per_long = 8*sizeof(size_t) */
/* p = nBV / bits_per_long + ( (nBV % bits_per_long) != 0 ) */
/* */
/* For the full Jacobian matrix set */
Expand All @@ -36,24 +36,23 @@ package.
/* */
/* forward(tag, m, n, p, x[n], X[n][p], y[m], Y[m][p], mode) : intfov */

ADOLC_DLL_EXPORT int forward(short, int, int, int, double *,
unsigned long int **, double *,
unsigned long int **, char = 0);
ADOLC_DLL_EXPORT int forward(short, int, int, int, double *, size_t **,
double *, size_t **, char = 0);

/*--------------------------------------------------------------------------*/
/* Bit pattern propagation call, d = 1, safe version (no x[] and y[]) */
/* */
/* forward(tag, m, n, p, X[n][p], Y[m][p], mode) : intfov */

ADOLC_DLL_EXPORT int forward(short, int, int, int, unsigned long int **,
unsigned long int **, char = 0);
ADOLC_DLL_EXPORT int forward(short, int, int, int, size_t **, size_t **,
char = 0);

/****************************************************************************/
/* REVERSE MODE, overloaded calls */
/* */
/* nBV = number of Boolean Vectors to be packed */
/* (see Chapter Dependence Analysis, ADOL-C Documentation) */
/* bits_per_long = 8*sizeof(unsigned long int) */
/* bits_per_long = 8*sizeof(size_t) */
/* q = nBV / bits_per_long + ( (nBV % bits_per_long) != 0 ) */
/* */
/* For the full Jacobian matrix set */
Expand All @@ -66,8 +65,8 @@ ADOLC_DLL_EXPORT int forward(short, int, int, int, unsigned long int **,
/* */
/* reverse(tag, m, n, q, U[q][m], Z[q][n], mode) : intfov */

ADOLC_DLL_EXPORT int reverse(short, int, int, int, unsigned long int **,
unsigned long int **, char = 0);
ADOLC_DLL_EXPORT int reverse(short, int, int, int, size_t **, size_t **,
char = 0);

#endif

Expand Down
2 changes: 1 addition & 1 deletion ADOL-C/include/adolc/sparse/sparsedrivers.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ADOLC_DLL_EXPORT void get_HP(short tag, /* tape identification */
/* Max. number of unsigned ints to store the seed / jacobian matrix strips.
Reduce this value to x if your system happens to run out of memory.
x < 10 makes no sense. x = 50 or 100 is better
x stays for ( x * sizeof(unsigned long int) * 8 )
x stays for ( x * sizeof(size_t) * 8 )
(block) variables at once */

#define PQ_STRIPMINE_MAX 30
Expand Down
23 changes: 10 additions & 13 deletions ADOL-C/src/adalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,38 +225,35 @@ unsigned int *myalloc1_uint(int m) {
}

/* ------------------------------------------------------------------------- */
unsigned long int *myalloc1_ulong(int m) {
unsigned long int *A =
(unsigned long int *)ADOLC_CALLOC(m, sizeof(unsigned long int));
size_t *myalloc1_ulong(int m) {
size_t *A = (size_t *)ADOLC_CALLOC(m, sizeof(size_t));
if (A == NULL) {
fprintf(DIAG_OUT,
"ADOL-C error, " __FILE__
":%i : \nmyalloc1_ulong cannot allocate %i bytes\n",
__LINE__, (int)(m * sizeof(unsigned long int)));
__LINE__, (int)(m * sizeof(size_t)));
adolc_exit(-1, "", __func__, __FILE__, __LINE__);
} /* endif */
return A;
}

/* ------------------------------------------------------------------------- */
unsigned long int **myalloc2_ulong(int m, int n) {
unsigned long int *Adum =
(unsigned long int *)ADOLC_CALLOC(m * n, sizeof(unsigned long int));
unsigned long int **A =
(unsigned long int **)ADOLC_CALLOC(m, sizeof(unsigned long int *));
size_t **myalloc2_ulong(int m, int n) {
size_t *Adum = (size_t *)ADOLC_CALLOC(m * n, sizeof(size_t));
size_t **A = (size_t **)ADOLC_CALLOC(m, sizeof(size_t *));
int i;
if (Adum == NULL) {
fprintf(DIAG_OUT,
"ADOL-C error, " __FILE__
":%i : \nmyalloc2_ulong cannot allocate %i bytes\n",
__LINE__, (int)(m * n * sizeof(unsigned long int)));
__LINE__, (int)(m * n * sizeof(size_t)));
adolc_exit(-1, "", __func__, __FILE__, __LINE__);
} /* endif */
if (A == NULL) {
fprintf(DIAG_OUT,
"ADOL-C error, " __FILE__
":%i : \nmyalloc2_ulong cannot allocate %i bytes\n",
__LINE__, (int)(m * sizeof(unsigned long int *)));
__LINE__, (int)(m * sizeof(size_t *)));
adolc_exit(-1, "", __func__, __FILE__, __LINE__);
} /* endif */
for (i = 0; i < m; i++) {
Expand All @@ -275,11 +272,11 @@ void myfree1_uint(unsigned int *A) { free((char *)A); }

/* ------------------------------------------------------------------------ */

void myfree1_ulong(unsigned long int *A) { free((char *)A); }
void myfree1_ulong(size_t *A) { free((char *)A); }

/* ------------------------------------------------------------------------ */

void myfree2_ulong(unsigned long int **A) {
void myfree2_ulong(size_t **A) {
free((char *)*A);
free((char *)A);
}
Expand Down
Loading

0 comments on commit 969e65c

Please sign in to comment.