Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.
  • Loading branch information
svillemot committed Nov 27, 2022
commit 776a0223b0d52ec588f4a1f8b2cae0586ffa4330
10 changes: 5 additions & 5 deletions CBLAS/testing/c_c2chke.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "cblas.h"
#include "cblas_test.h"

int cblas_ok, cblas_lerr, cblas_info;
int link_xerbla=TRUE;
CBLAS_INT cblas_ok, cblas_lerr, cblas_info;
CBLAS_INT link_xerbla=TRUE;
char *cblas_rout;

#ifdef F77_Char
Expand All @@ -14,8 +14,8 @@ void F77_xerbla(char *srname, void *vinfo);
#endif

void chkxer(void) {
extern int cblas_ok, cblas_lerr, cblas_info;
extern int link_xerbla;
extern CBLAS_INT cblas_ok, cblas_lerr, cblas_info;
extern CBLAS_INT link_xerbla;
extern char *cblas_rout;
if (cblas_lerr == 1 ) {
printf("***** ILLEGAL VALUE OF PARAMETER NUMBER %d NOT DETECTED BY %s *****\n", cblas_info, cblas_rout);
Expand All @@ -32,7 +32,7 @@ void F77_c2chke(char *rout) {
ALPHA[2] = {0.0,0.0},
BETA[2] = {0.0,0.0},
RALPHA = 0.0;
extern int cblas_info, cblas_lerr, cblas_ok;
extern CBLAS_INT cblas_info, cblas_lerr, cblas_ok;
extern int RowMajorStrg;
extern char *cblas_rout;

Expand Down
10 changes: 5 additions & 5 deletions CBLAS/testing/c_c3chke.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "cblas.h"
#include "cblas_test.h"

int cblas_ok, cblas_lerr, cblas_info;
int link_xerbla=TRUE;
CBLAS_INT cblas_ok, cblas_lerr, cblas_info;
CBLAS_INT link_xerbla=TRUE;
char *cblas_rout;

#ifdef F77_Char
Expand All @@ -14,8 +14,8 @@ void F77_xerbla(char *srname, void *vinfo);
#endif

void chkxer(void) {
extern int cblas_ok, cblas_lerr, cblas_info;
extern int link_xerbla;
extern CBLAS_INT cblas_ok, cblas_lerr, cblas_info;
extern CBLAS_INT link_xerbla;
extern char *cblas_rout;
if (cblas_lerr == 1 ) {
printf("***** ILLEGAL VALUE OF PARAMETER NUMBER %d NOT DETECTED BY %s *****\n", cblas_info, cblas_rout);
Expand All @@ -32,7 +32,7 @@ void F77_c3chke(char * rout) {
ALPHA[2] = {0.0,0.0},
BETA[2] = {0.0,0.0},
RALPHA = 0.0, RBETA = 0.0;
extern int cblas_info, cblas_lerr, cblas_ok;
extern CBLAS_INT cblas_info, cblas_lerr, cblas_ok;
extern int RowMajorStrg;
extern char *cblas_rout;

Expand Down
34 changes: 17 additions & 17 deletions CBLAS/testing/c_cblas1.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,67 +8,67 @@
*/
#include "cblas_test.h"
#include "cblas.h"
void F77_caxpy(const int *N, const void *alpha, void *X,
const int *incX, void *Y, const int *incY)
void F77_caxpy(const CBLAS_INT *N, const void *alpha, void *X,
const CBLAS_INT *incX, void *Y, const CBLAS_INT *incY)
{
cblas_caxpy(*N, alpha, X, *incX, Y, *incY);
return;
}

void F77_ccopy(const int *N, void *X, const int *incX,
void *Y, const int *incY)
void F77_ccopy(const CBLAS_INT *N, void *X, const CBLAS_INT *incX,
void *Y, const CBLAS_INT *incY)
{
cblas_ccopy(*N, X, *incX, Y, *incY);
return;
}

void F77_cdotc(const int *N, void *X, const int *incX,
void *Y, const int *incY, void *dotc)
void F77_cdotc(const CBLAS_INT *N, void *X, const CBLAS_INT *incX,
void *Y, const CBLAS_INT *incY, void *dotc)
{
cblas_cdotc_sub(*N, X, *incX, Y, *incY, dotc);
return;
}

void F77_cdotu(const int *N, void *X, const int *incX,
void *Y, const int *incY,void *dotu)
void F77_cdotu(const CBLAS_INT *N, void *X, const CBLAS_INT *incX,
void *Y, const CBLAS_INT *incY,void *dotu)
{
cblas_cdotu_sub(*N, X, *incX, Y, *incY, dotu);
return;
}

void F77_cscal(const int *N, const void * *alpha, void *X,
const int *incX)
void F77_cscal(const CBLAS_INT *N, const void * *alpha, void *X,
const CBLAS_INT *incX)
{
cblas_cscal(*N, alpha, X, *incX);
return;
}

void F77_csscal(const int *N, const float *alpha, void *X,
const int *incX)
void F77_csscal(const CBLAS_INT *N, const float *alpha, void *X,
const CBLAS_INT *incX)
{
cblas_csscal(*N, *alpha, X, *incX);
return;
}

void F77_cswap( const int *N, void *X, const int *incX,
void *Y, const int *incY)
void F77_cswap( const CBLAS_INT *N, void *X, const CBLAS_INT *incX,
void *Y, const CBLAS_INT *incY)
{
cblas_cswap(*N,X,*incX,Y,*incY);
return;
}

int F77_icamax(const int *N, const void *X, const int *incX)
CBLAS_INT F77_icamax(const CBLAS_INT *N, const void *X, const CBLAS_INT *incX)
{
if (*N < 1 || *incX < 1) return(0);
return (cblas_icamax(*N, X, *incX)+1);
}

float F77_scnrm2(const int *N, const void *X, const int *incX)
float F77_scnrm2(const CBLAS_INT *N, const void *X, const CBLAS_INT *incX)
{
return cblas_scnrm2(*N, X, *incX);
}

float F77_scasum(const int *N, void *X, const int *incX)
float F77_scasum(const CBLAS_INT *N, void *X, const CBLAS_INT *incX)
{
return cblas_scasum(*N, X, *incX);
}
Loading