fixed C-fortran index shift in cblas_idamax etc.
This commit is contained in:
parent
4cf7dbb8c7
commit
9bb4fc883b
16
mat.h
16
mat.h
@ -904,14 +904,14 @@ inline const double NRMat<double>::amax() const{
|
||||
if(location == cpu){
|
||||
#endif
|
||||
#ifdef MATPTR
|
||||
return v[0][cblas_idamax(nn*mm, v[0], 1) - 1];
|
||||
return v[0][cblas_idamax(nn*mm, v[0], 1) ];
|
||||
#else
|
||||
return v[cblas_idamax(nn*mm, v, 1) - 1];
|
||||
return v[cblas_idamax(nn*mm, v, 1) ];
|
||||
#endif
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
double ret(0.0);
|
||||
const size_t pozice = cublasIdamax((size_t)nn*mm, v, 1) - 1;
|
||||
const size_t pozice = cublasIdamax((size_t)nn*mm, v, 1);
|
||||
TEST_CUBLAS("cublasIdamax");
|
||||
gpuget(1, sizeof(double), v + pozice, &ret);
|
||||
return ret;
|
||||
@ -950,7 +950,7 @@ inline const double NRMat<double>::amin() const{
|
||||
#endif
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
const size_t pozice = cublasIdamin((size_t)nn*mm, v, 1) - 1;
|
||||
const size_t pozice = cublasIdamin((size_t)nn*mm, v, 1);
|
||||
TEST_CUBLAS("cublasIdamin");
|
||||
gpuget(1, sizeof(double), v + pozice, &ret);
|
||||
}
|
||||
@ -969,14 +969,14 @@ inline const std::complex<double> NRMat<std::complex<double> >::amax() const{
|
||||
if(location == cpu){
|
||||
#endif
|
||||
#ifdef MATPTR
|
||||
return v[0][cblas_izamax(nn*mm, v[0], 1) - 1];
|
||||
return v[0][cblas_izamax(nn*mm, v[0], 1) ];
|
||||
#else
|
||||
return v[cblas_izamax(nn*mm, v, 1) - 1];
|
||||
return v[cblas_izamax(nn*mm, v, 1) ];
|
||||
#endif
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
std::complex<double> ret(0.0, 0.0);
|
||||
const size_t pozice = cublasIzamax((size_t)nn*mm, (cuDoubleComplex*)v, 1) - 1;
|
||||
const size_t pozice = cublasIzamax((size_t)nn*mm, (cuDoubleComplex*)v, 1);
|
||||
TEST_CUBLAS("cublasIzamax");
|
||||
gpuget(1, sizeof(std::complex<double>), v + pozice, &ret);
|
||||
return ret;
|
||||
@ -1019,7 +1019,7 @@ inline const std::complex<double> NRMat<std::complex<double> >::amin() const{
|
||||
#endif
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
const size_t pozice = cublasIzamin((size_t)nn*mm, (cuDoubleComplex*)v, 1) - 1;
|
||||
const size_t pozice = cublasIzamin((size_t)nn*mm, (cuDoubleComplex*)v, 1);
|
||||
TEST_CUBLAS("cublasIzamin");
|
||||
gpuget(1, sizeof(std::complex<double>), v + pozice, &ret);
|
||||
}
|
||||
|
20
noncblas.cc
20
noncblas.cc
@ -582,9 +582,9 @@ CBLAS_INDEX cblas_idamax(const int N, const double *X, const int incX) {
|
||||
#ifdef FORINT
|
||||
const FINT ntmp=N;
|
||||
const FINT incxtmp=incX;
|
||||
return (CBLAS_INDEX)FORNAME(idamax)(&ntmp,X,&incxtmp);
|
||||
return (CBLAS_INDEX)FORNAME(idamax)(&ntmp,X,&incxtmp)-1;
|
||||
#else
|
||||
return (CBLAS_INDEX)FORNAME(idamax)(&N,X,&incX);
|
||||
return (CBLAS_INDEX)FORNAME(idamax)(&N,X,&incX)-1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -593,9 +593,9 @@ CBLAS_INDEX cblas_izamax(const int N, const void *X, const int incX) {
|
||||
#ifdef FORINT
|
||||
const FINT ntmp=N;
|
||||
const FINT incxtmp=incX;
|
||||
return (CBLAS_INDEX)FORNAME(izamax)(&ntmp, X, &incxtmp);
|
||||
return (CBLAS_INDEX)FORNAME(izamax)(&ntmp, X, &incxtmp)-1;
|
||||
#else
|
||||
return (CBLAS_INDEX)FORNAME(izamax)(&N, X, &incX);
|
||||
return (CBLAS_INDEX)FORNAME(izamax)(&N, X, &incX)-1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -604,9 +604,9 @@ CBLAS_INDEX cblas_isamax(const int N, const float *X, const int incX) {
|
||||
#ifdef FORINT
|
||||
const FINT ntmp=N;
|
||||
const FINT incxtmp=incX;
|
||||
return (CBLAS_INDEX)FORNAME(isamax)(&ntmp,X,&incxtmp);
|
||||
return (CBLAS_INDEX)FORNAME(isamax)(&ntmp,X,&incxtmp)-1;
|
||||
#else
|
||||
return (CBLAS_INDEX)FORNAME(isamax)(&N,X,&incX);
|
||||
return (CBLAS_INDEX)FORNAME(isamax)(&N,X,&incX)-1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -618,9 +618,9 @@ CBLAS_INDEX cblas_idamin(const int N, const double *X, const int incX) {
|
||||
#ifdef FORINT
|
||||
const FINT ntmp=N;
|
||||
const FINT incxtmp=incX;
|
||||
return (CBLAS_INDEX)FORNAME(idamin)(&ntmp,X,&incxtmp);
|
||||
return (CBLAS_INDEX)FORNAME(idamin)(&ntmp,X,&incxtmp)-1;
|
||||
#else
|
||||
return (CBLAS_INDEX)FORNAME(idamin)(&N,X,&incX);
|
||||
return (CBLAS_INDEX)FORNAME(idamin)(&N,X,&incX)-1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -630,9 +630,9 @@ CBLAS_INDEX cblas_izamin(const int N, const void *X, const int incX) {
|
||||
#ifdef FORINT
|
||||
const FINT ntmp=N;
|
||||
const FINT incxtmp=incX;
|
||||
return (CBLAS_INDEX)FORNAME(izamin)(&ntmp, X, &incxtmp);
|
||||
return (CBLAS_INDEX)FORNAME(izamin)(&ntmp, X, &incxtmp)-1;
|
||||
#else
|
||||
return (CBLAS_INDEX)FORNAME(izamin)(&N, X, &incX);
|
||||
return (CBLAS_INDEX)FORNAME(izamin)(&N, X, &incX)-1;
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
12
smat.h
12
smat.h
@ -799,10 +799,10 @@ inline const double NRSMat<double>::amax() const {
|
||||
#ifdef CUDALA
|
||||
if(location == cpu){
|
||||
#endif
|
||||
ret = v[cblas_idamax(NN2, v, 1) - 1];
|
||||
ret = v[cblas_idamax(NN2, v, 1)];
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
const int pozice = cublasIdamax(NN2, v, 1) - 1;
|
||||
const int pozice = cublasIdamax(NN2, v, 1) ;
|
||||
TEST_CUBLAS("cublasIdamax");//"double NRSMat<double>::amax()"
|
||||
|
||||
gpuget(1, sizeof(double), v + pozice, &ret);
|
||||
@ -833,7 +833,7 @@ inline const double NRSMat<double>::amin() const {
|
||||
ret = v[index];
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
const int pozice = cublasIdamin(nn, v, 1) - 1;
|
||||
const int pozice = cublasIdamin(nn, v, 1);
|
||||
TEST_CUBLAS("cublasIdamin");//"double NRSMat<double>::amin()"
|
||||
gpuget(1, sizeof(double), v + pozice, &ret);
|
||||
}
|
||||
@ -852,10 +852,10 @@ inline const std::complex<double> NRSMat< std::complex<double> >::amax() const{
|
||||
#ifdef CUDALA
|
||||
if(location == cpu){
|
||||
#endif
|
||||
ret = v[cblas_izamax(NN2, v, 1) - 1];
|
||||
ret = v[cblas_izamax(NN2, v, 1)];
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
const int pozice = cublasIzamax(NN2, (cuDoubleComplex*)v, 1) - 1;
|
||||
const int pozice = cublasIzamax(NN2, (cuDoubleComplex*)v, 1);
|
||||
TEST_CUBLAS("cublasIzamax");//"std::complex<double> NRSMat<std::complex<double> >::amax()"
|
||||
gpuget(1, sizeof(std::complex<double>), v + pozice, &ret);
|
||||
}
|
||||
@ -888,7 +888,7 @@ inline const std::complex<double> NRSMat<std::complex<double> >::amin() const{
|
||||
ret = v[index];
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
const int pozice = cublasIzamin(nn, (cuDoubleComplex*)v, 1) - 1;
|
||||
const int pozice = cublasIzamin(nn, (cuDoubleComplex*)v, 1);
|
||||
TEST_CUBLAS("cublasIzamin");//"std::complex<double> NRSMat<std::complex<double> >::amin()"
|
||||
gpuget(1, sizeof(std::complex<double>), v + pozice, &ret);
|
||||
}
|
||||
|
15
t.cc
15
t.cc
@ -3421,7 +3421,7 @@ Tensor<double> bb(b);
|
||||
cout << aa*bb;
|
||||
}
|
||||
|
||||
if(1)
|
||||
if(0)
|
||||
{
|
||||
int seed;
|
||||
int f=open("/dev/random",O_RDONLY);
|
||||
@ -3440,4 +3440,17 @@ cout <<b;
|
||||
cout <<c;
|
||||
}
|
||||
|
||||
if(1)
|
||||
{
|
||||
NRMat<double> m;
|
||||
cin >>m;
|
||||
NRVec<double> v(m);
|
||||
cout <<v;
|
||||
NRMat<double> mm(v,m.nrows(),m.ncols());
|
||||
cout <<mm;
|
||||
cout <<m.getcount()<<" "<<v.getcount()<<" "<<mm.getcount()<<endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
12
vec.h
12
vec.h
@ -1874,10 +1874,10 @@ inline const double NRVec<double>::amax() const {
|
||||
#ifdef CUDALA
|
||||
if(location == cpu){
|
||||
#endif
|
||||
ret = v[cblas_idamax(nn, v, 1) - 1];
|
||||
ret = v[cblas_idamax(nn, v, 1)];
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
const int pozice = cublasIdamax(nn, v, 1) - 1;
|
||||
const int pozice = cublasIdamax(nn, v, 1) ;
|
||||
TEST_CUBLAS("cublasIdamax");
|
||||
|
||||
gpuget(1, sizeof(double), v + pozice, &ret);
|
||||
@ -1906,7 +1906,7 @@ inline const double NRVec<double>::amin() const {
|
||||
ret = v[index];
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
const int pozice = cublasIdamin(nn, v, 1) - 1;
|
||||
const int pozice = cublasIdamin(nn, v, 1);
|
||||
TEST_CUBLAS("cublasIdamin");
|
||||
gpuget(1, sizeof(double), v + pozice, &ret);
|
||||
}
|
||||
@ -1925,10 +1925,10 @@ inline const std::complex<double> NRVec<std::complex<double> >::amax() const {
|
||||
#ifdef CUDALA
|
||||
if(location == cpu){
|
||||
#endif
|
||||
ret = v[cblas_izamax(nn, v, 1) - 1];
|
||||
ret = v[cblas_izamax(nn, v, 1) ];
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
const int pozice = cublasIzamax(nn, (cuDoubleComplex*)v, 1) - 1;
|
||||
const int pozice = cublasIzamax(nn, (cuDoubleComplex*)v, 1);
|
||||
TEST_CUBLAS("cublasIzamax");
|
||||
gpuget(1, sizeof(std::complex<double>), v + pozice, &ret);
|
||||
}
|
||||
@ -1960,7 +1960,7 @@ inline const std::complex<double> NRVec<std::complex<double> >::amin() const {
|
||||
ret = v[index];
|
||||
#ifdef CUDALA
|
||||
}else{
|
||||
const int pozice = cublasIzamin(nn, (cuDoubleComplex*)v, 1) - 1;
|
||||
const int pozice = cublasIzamin(nn, (cuDoubleComplex*)v, 1);
|
||||
TEST_CUBLAS("cublasIzamin");
|
||||
gpuget(1, sizeof(std::complex<double>), v + pozice, &ret);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user