Skip to content

Commit 776a022

Browse files
committed
Fix CBLAS tests with 64-bit indexing
This patch replaces all instances of “int” by “CBLAS_INT” in CBLAS/testing/*.c (except for RowMajorStrg which has must remain an “int”, since it is declared as such in CBLAS main code). Interestingly, the bug would not manifest on low endian architectures, because interpreting an int64_t pointer as an int32_t pointer works there (as long as the integers fits in 31 bits, which is the case here). But on big endian architectures, this of course fails badly.
1 parent 77fac7e commit 776a022

21 files changed

+477
-477
lines changed

CBLAS/testing/c_c2chke.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include "cblas.h"
44
#include "cblas_test.h"
55

6-
int cblas_ok, cblas_lerr, cblas_info;
7-
int link_xerbla=TRUE;
6+
CBLAS_INT cblas_ok, cblas_lerr, cblas_info;
7+
CBLAS_INT link_xerbla=TRUE;
88
char *cblas_rout;
99

1010
#ifdef F77_Char
@@ -14,8 +14,8 @@ void F77_xerbla(char *srname, void *vinfo);
1414
#endif
1515

1616
void chkxer(void) {
17-
extern int cblas_ok, cblas_lerr, cblas_info;
18-
extern int link_xerbla;
17+
extern CBLAS_INT cblas_ok, cblas_lerr, cblas_info;
18+
extern CBLAS_INT link_xerbla;
1919
extern char *cblas_rout;
2020
if (cblas_lerr == 1 ) {
2121
printf("***** ILLEGAL VALUE OF PARAMETER NUMBER %d NOT DETECTED BY %s *****\n", cblas_info, cblas_rout);
@@ -32,7 +32,7 @@ void F77_c2chke(char *rout) {
3232
ALPHA[2] = {0.0,0.0},
3333
BETA[2] = {0.0,0.0},
3434
RALPHA = 0.0;
35-
extern int cblas_info, cblas_lerr, cblas_ok;
35+
extern CBLAS_INT cblas_info, cblas_lerr, cblas_ok;
3636
extern int RowMajorStrg;
3737
extern char *cblas_rout;
3838

CBLAS/testing/c_c3chke.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include "cblas.h"
44
#include "cblas_test.h"
55

6-
int cblas_ok, cblas_lerr, cblas_info;
7-
int link_xerbla=TRUE;
6+
CBLAS_INT cblas_ok, cblas_lerr, cblas_info;
7+
CBLAS_INT link_xerbla=TRUE;
88
char *cblas_rout;
99

1010
#ifdef F77_Char
@@ -14,8 +14,8 @@ void F77_xerbla(char *srname, void *vinfo);
1414
#endif
1515

1616
void chkxer(void) {
17-
extern int cblas_ok, cblas_lerr, cblas_info;
18-
extern int link_xerbla;
17+
extern CBLAS_INT cblas_ok, cblas_lerr, cblas_info;
18+
extern CBLAS_INT link_xerbla;
1919
extern char *cblas_rout;
2020
if (cblas_lerr == 1 ) {
2121
printf("***** ILLEGAL VALUE OF PARAMETER NUMBER %d NOT DETECTED BY %s *****\n", cblas_info, cblas_rout);
@@ -32,7 +32,7 @@ void F77_c3chke(char * rout) {
3232
ALPHA[2] = {0.0,0.0},
3333
BETA[2] = {0.0,0.0},
3434
RALPHA = 0.0, RBETA = 0.0;
35-
extern int cblas_info, cblas_lerr, cblas_ok;
35+
extern CBLAS_INT cblas_info, cblas_lerr, cblas_ok;
3636
extern int RowMajorStrg;
3737
extern char *cblas_rout;
3838

CBLAS/testing/c_cblas1.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,67 +8,67 @@
88
*/
99
#include "cblas_test.h"
1010
#include "cblas.h"
11-
void F77_caxpy(const int *N, const void *alpha, void *X,
12-
const int *incX, void *Y, const int *incY)
11+
void F77_caxpy(const CBLAS_INT *N, const void *alpha, void *X,
12+
const CBLAS_INT *incX, void *Y, const CBLAS_INT *incY)
1313
{
1414
cblas_caxpy(*N, alpha, X, *incX, Y, *incY);
1515
return;
1616
}
1717

18-
void F77_ccopy(const int *N, void *X, const int *incX,
19-
void *Y, const int *incY)
18+
void F77_ccopy(const CBLAS_INT *N, void *X, const CBLAS_INT *incX,
19+
void *Y, const CBLAS_INT *incY)
2020
{
2121
cblas_ccopy(*N, X, *incX, Y, *incY);
2222
return;
2323
}
2424

25-
void F77_cdotc(const int *N, void *X, const int *incX,
26-
void *Y, const int *incY, void *dotc)
25+
void F77_cdotc(const CBLAS_INT *N, void *X, const CBLAS_INT *incX,
26+
void *Y, const CBLAS_INT *incY, void *dotc)
2727
{
2828
cblas_cdotc_sub(*N, X, *incX, Y, *incY, dotc);
2929
return;
3030
}
3131

32-
void F77_cdotu(const int *N, void *X, const int *incX,
33-
void *Y, const int *incY,void *dotu)
32+
void F77_cdotu(const CBLAS_INT *N, void *X, const CBLAS_INT *incX,
33+
void *Y, const CBLAS_INT *incY,void *dotu)
3434
{
3535
cblas_cdotu_sub(*N, X, *incX, Y, *incY, dotu);
3636
return;
3737
}
3838

39-
void F77_cscal(const int *N, const void * *alpha, void *X,
40-
const int *incX)
39+
void F77_cscal(const CBLAS_INT *N, const void * *alpha, void *X,
40+
const CBLAS_INT *incX)
4141
{
4242
cblas_cscal(*N, alpha, X, *incX);
4343
return;
4444
}
4545

46-
void F77_csscal(const int *N, const float *alpha, void *X,
47-
const int *incX)
46+
void F77_csscal(const CBLAS_INT *N, const float *alpha, void *X,
47+
const CBLAS_INT *incX)
4848
{
4949
cblas_csscal(*N, *alpha, X, *incX);
5050
return;
5151
}
5252

53-
void F77_cswap( const int *N, void *X, const int *incX,
54-
void *Y, const int *incY)
53+
void F77_cswap( const CBLAS_INT *N, void *X, const CBLAS_INT *incX,
54+
void *Y, const CBLAS_INT *incY)
5555
{
5656
cblas_cswap(*N,X,*incX,Y,*incY);
5757
return;
5858
}
5959

60-
int F77_icamax(const int *N, const void *X, const int *incX)
60+
CBLAS_INT F77_icamax(const CBLAS_INT *N, const void *X, const CBLAS_INT *incX)
6161
{
6262
if (*N < 1 || *incX < 1) return(0);
6363
return (cblas_icamax(*N, X, *incX)+1);
6464
}
6565

66-
float F77_scnrm2(const int *N, const void *X, const int *incX)
66+
float F77_scnrm2(const CBLAS_INT *N, const void *X, const CBLAS_INT *incX)
6767
{
6868
return cblas_scnrm2(*N, X, *incX);
6969
}
7070

71-
float F77_scasum(const int *N, void *X, const int *incX)
71+
float F77_scasum(const CBLAS_INT *N, void *X, const CBLAS_INT *incX)
7272
{
7373
return cblas_scasum(*N, X, *incX);
7474
}

0 commit comments

Comments
 (0)