From 86d37075ed844a13c1aad8d32808124e62e11b16 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Mon, 8 Aug 2022 16:41:04 +0200 Subject: [PATCH 1/5] Fixed CBLAS integer formats for 64bit build. --- CBLAS/examples/cblas_example1.c | 2 +- CBLAS/include/cblas.h | 12 ++++++++++++ CBLAS/src/cblas_xerbla.c | 2 +- CBLAS/testing/c_xerbla.c | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CBLAS/examples/cblas_example1.c b/CBLAS/examples/cblas_example1.c index 65731ba15c..0571770ba5 100644 --- a/CBLAS/examples/cblas_example1.c +++ b/CBLAS/examples/cblas_example1.c @@ -61,7 +61,7 @@ int main ( ) y, incy ); /* Print y */ for( i = 0; i < n; i++ ) - printf(" y%d = %f\n", i, y[i]); + printf(" y%" CBLAS_IFMT " = %f\n", i, y[i]); free(a); free(x); free(y); diff --git a/CBLAS/include/cblas.h b/CBLAS/include/cblas.h index 98ae526cd6..8dd1c5506a 100644 --- a/CBLAS/include/cblas.h +++ b/CBLAS/include/cblas.h @@ -2,6 +2,7 @@ #define CBLAS_H #include #include +#include #ifdef __cplusplus @@ -24,6 +25,17 @@ extern "C" { /* Assume C declarations for C++ */ #endif #endif +/* + * Integer format string + */ +#ifndef CBLAS_IFMT +#ifdef WeirdNEC + #define CBLAS_IFMT PRId64 +#else + #define CBLAS_IFMT PRId32 +#endif +#endif + typedef enum CBLAS_LAYOUT {CblasRowMajor=101, CblasColMajor=102} CBLAS_LAYOUT; typedef enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113} CBLAS_TRANSPOSE; typedef enum CBLAS_UPLO {CblasUpper=121, CblasLower=122} CBLAS_UPLO; diff --git a/CBLAS/src/cblas_xerbla.c b/CBLAS/src/cblas_xerbla.c index 6a24d2f77b..3643618ef5 100644 --- a/CBLAS/src/cblas_xerbla.c +++ b/CBLAS/src/cblas_xerbla.c @@ -63,7 +63,7 @@ cblas_xerbla(CBLAS_INT info, const char *rout, const char *form, ...) } } if (info) - fprintf(stderr, "Parameter %d to routine %s was incorrect\n", info, rout); + fprintf(stderr, "Parameter %" CBLAS_IFMT " to routine %s was incorrect\n", info, rout); vfprintf(stderr, form, argptr); va_end(argptr); if (info && !info) diff --git a/CBLAS/testing/c_xerbla.c b/CBLAS/testing/c_xerbla.c index 8c6674e11b..c3f14c364a 100644 --- a/CBLAS/testing/c_xerbla.c +++ b/CBLAS/testing/c_xerbla.c @@ -78,7 +78,7 @@ void cblas_xerbla(CBLAS_INT info, const char *rout, const char *form, ...) } if (info != cblas_info){ - printf("***** XERBLA WAS CALLED WITH INFO = %d INSTEAD OF %d in %s *******\n",info, cblas_info, rout); + printf("***** XERBLA WAS CALLED WITH INFO = %" CBLAS_IFMT " INSTEAD OF %d in %s *******\n",info, cblas_info, rout); cblas_lerr = PASSED; cblas_ok = FALSE; } else cblas_lerr = FAILED; From 6030bc410a45bb222c87de7be6c3f4d58f8a01b7 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Mon, 8 Aug 2022 16:41:30 +0200 Subject: [PATCH 2/5] Fixed LAPACKE integer formats for 64bit build. --- LAPACKE/example/example_DGESV_colmajor.c | 2 +- LAPACKE/example/example_DGESV_rowmajor.c | 2 +- LAPACKE/example/lapacke_example_aux.c | 2 +- LAPACKE/include/lapacke_config.h | 12 ++++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/LAPACKE/example/example_DGESV_colmajor.c b/LAPACKE/example/example_DGESV_colmajor.c index 3487873798..44a470d477 100644 --- a/LAPACKE/example/example_DGESV_colmajor.c +++ b/LAPACKE/example/example_DGESV_colmajor.c @@ -92,7 +92,7 @@ int main(int argc, char **argv) { /* Check for the exact singularity */ if( info > 0 ) { printf( "The diagonal element of the triangular factor of A,\n" ); - printf( "U(%i,%i) is zero, so that A is singular;\n", info, info ); + printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info ); printf( "the solution could not be computed.\n" ); exit( 1 ); } diff --git a/LAPACKE/example/example_DGESV_rowmajor.c b/LAPACKE/example/example_DGESV_rowmajor.c index d745367001..5411ef0490 100644 --- a/LAPACKE/example/example_DGESV_rowmajor.c +++ b/LAPACKE/example/example_DGESV_rowmajor.c @@ -89,7 +89,7 @@ int main(int argc, char **argv) { /* Check for the exact singularity */ if( info > 0 ) { printf( "The diagonal element of the triangular factor of A,\n" ); - printf( "U(%i,%i) is zero, so that A is singular;\n", info, info ); + printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info ); printf( "the solution could not be computed.\n" ); exit( 1 ); } diff --git a/LAPACKE/example/lapacke_example_aux.c b/LAPACKE/example/lapacke_example_aux.c index 9b72eb6209..19fff79055 100644 --- a/LAPACKE/example/lapacke_example_aux.c +++ b/LAPACKE/example/lapacke_example_aux.c @@ -28,6 +28,6 @@ void print_matrix_colmajor( char* desc, lapack_int m, lapack_int n, double* mat, void print_vector( char* desc, lapack_int n, lapack_int* vec ) { lapack_int j; printf( "\n %s\n", desc ); - for( j = 0; j < n; j++ ) printf( " %6i", vec[j] ); + for( j = 0; j < n; j++ ) printf( " %6" LAPACK_IFMT, vec[j] ); printf( "\n" ); } diff --git a/LAPACKE/include/lapacke_config.h b/LAPACKE/include/lapacke_config.h index 4a7d15760c..48cb39fd60 100644 --- a/LAPACKE/include/lapacke_config.h +++ b/LAPACKE/include/lapacke_config.h @@ -42,6 +42,7 @@ extern "C" { #include #include +#include #ifndef lapack_int #if defined(LAPACK_ILP64) @@ -51,6 +52,17 @@ extern "C" { #endif #endif +/* + * Integer format string + */ +#ifndef LAPACK_IFMT +#if defined(LAPACK_ILP64) + #define LAPACK_IFMT PRId64 +#else + #define LAPACK_IFMT PRId32 +#endif +#endif + #ifndef lapack_logical #define lapack_logical lapack_int #endif From 82014d93966b218dc4d1f9b8849aff599367cdf2 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Tue, 9 Aug 2022 07:28:01 +0100 Subject: [PATCH 3/5] Added LAPACK_IFMT in lapack.h for 32-bit integer builds. Replaced int with int32_t as default type. --- LAPACKE/include/lapack.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/LAPACKE/include/lapack.h b/LAPACKE/include/lapack.h index e4c39e1eea..3d806d966c 100644 --- a/LAPACKE/include/lapack.h +++ b/LAPACKE/include/lapack.h @@ -12,6 +12,7 @@ #include #include +#include /* It seems all current Fortran compilers put strlen at end. * Some historical compilers put strlen after the str argument @@ -80,9 +81,11 @@ extern "C" { /*----------------------------------------------------------------------------*/ #ifndef lapack_int -#define lapack_int int +#define lapack_int int32_t #endif +#define LAPACK_IFMT PRId32 + #ifndef lapack_logical #define lapack_logical lapack_int #endif From 57259965ea62a875e8e23649f6e3353288db02a6 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Tue, 9 Aug 2022 07:30:02 +0100 Subject: [PATCH 4/5] Added guard around LAPACK_IFMT define. --- LAPACKE/include/lapack.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LAPACKE/include/lapack.h b/LAPACKE/include/lapack.h index 3d806d966c..59d800e7c5 100644 --- a/LAPACKE/include/lapack.h +++ b/LAPACKE/include/lapack.h @@ -84,7 +84,9 @@ extern "C" { #define lapack_int int32_t #endif +#ifndef LAPACK_IFMT #define LAPACK_IFMT PRId32 +#endif #ifndef lapack_logical #define lapack_logical lapack_int From 0b5b0fa47847ff227d18e52f7b0ef710576e2e58 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 10 Aug 2022 16:27:32 +0200 Subject: [PATCH 5/5] Added 64-bit integer switch to lapack.h header --- LAPACKE/include/lapack.h | 17 ++++++++++++++--- LAPACKE/include/lapacke_config.h | 10 +++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/LAPACKE/include/lapack.h b/LAPACKE/include/lapack.h index 59d800e7c5..06a530dc3a 100644 --- a/LAPACKE/include/lapack.h +++ b/LAPACKE/include/lapack.h @@ -81,15 +81,26 @@ extern "C" { /*----------------------------------------------------------------------------*/ #ifndef lapack_int -#define lapack_int int32_t +#if defined(LAPACK_ILP64) +#define lapack_int int64_t +#else +#define lapack_int int32_t +#endif #endif +/* + * Integer format string + */ #ifndef LAPACK_IFMT -#define LAPACK_IFMT PRId32 +#if defined(LAPACK_ILP64) +#define LAPACK_IFMT PRId64 +#else +#define LAPACK_IFMT PRId32 +#endif #endif #ifndef lapack_logical -#define lapack_logical lapack_int +#define lapack_logical lapack_int #endif /* f2c, hence clapack and MacOS Accelerate, returns double instead of float diff --git a/LAPACKE/include/lapacke_config.h b/LAPACKE/include/lapacke_config.h index 48cb39fd60..c64fc4416a 100644 --- a/LAPACKE/include/lapacke_config.h +++ b/LAPACKE/include/lapacke_config.h @@ -46,9 +46,9 @@ extern "C" { #ifndef lapack_int #if defined(LAPACK_ILP64) -#define lapack_int int64_t +#define lapack_int int64_t #else -#define lapack_int int32_t +#define lapack_int int32_t #endif #endif @@ -57,14 +57,14 @@ extern "C" { */ #ifndef LAPACK_IFMT #if defined(LAPACK_ILP64) - #define LAPACK_IFMT PRId64 +#define LAPACK_IFMT PRId64 #else - #define LAPACK_IFMT PRId32 +#define LAPACK_IFMT PRId32 #endif #endif #ifndef lapack_logical -#define lapack_logical lapack_int +#define lapack_logical lapack_int #endif #ifndef LAPACK_COMPLEX_CUSTOM