Hi everyone,
I dont think this is what cublasDswap is supposed to be doing but the results I got are:
incx:
5
incy:
5
n:
5
BEFORE SWAP
x:
5.273349 6.470129 2.858855 7.915439 3.345689 3.961285 1.663136 5.445393 4.439047 2.728696
6.448988 5.443586 4.717779 5.275986 5.837818 3.880827 1.318698 4.946274 6.899205 7.922868
7.609217
y:
0.000000 5.273349 6.470129 2.858855 7.915439 3.345689 3.961285 1.663136 5.445393 4.439047
2.728696 6.448988 5.443586 4.717779 5.275986 5.837818 3.880827 1.318698 4.946274 6.899205
7.922868
AFTER SWAP
x:
0.000000 6.470129 2.858855 7.915439 3.961285 3.345689 1.663136 5.445393 4.439047 6.448988
2.728696 5.443586 4.717779 5.275986 3.880827 5.837818 1.318698 4.946274 6.899205 7.609217
7.922868
y:
5.273349 0.000000 6.470129 2.858855 7.915439 3.961285 3.345689 1.663136 5.445393 4.439047
6.448988 2.728696 5.443586 4.717779 5.275986 3.880827 5.837818 1.318698 4.946274 6.899205
7.609217
the colour green shows the values that are swapped correctly. the ones in the red however seems to be the ones that are out of place. Rather not meant to be there at all. seems to be pushin the old vector by one to the right and inserting the incorrect value. please ask me if this isnt clear enough.
[codebox]print_vector((void *)incx, INT, 1);
print_vector((void *)incy, INT, 1);
print_vector((void *)n, INT, 1);
print_vector((void *)x, DOUBLE, xelem);
print_vector((void *)y, DOUBLE, yelem);
cublasAlloc (*n * abs(*incx), sizeof(x[0]), (void**)&devPtrx);
cublasAlloc (*n * abs(*incy), sizeof(y[0]), (void**)&devPtry);
cublasSetVector (*n, sizeof(x[0]), x, abs(*incx), devPtrx, abs(*incx));
cublasSetVector (*n, sizeof(y[0]), y, abs(*incy), devPtry, abs(*incy));
cublasDswap (*n, devPtrx, *incx, devPtry, *incy);
cublasGetVector (*n, sizeof(x[0]), devPtrx, abs(*incx), x, abs(*incx));
cublasGetVector (*n, sizeof(y[0]), devPtry, abs(*incy), y, abs(*incy));
print_vector((void *)x, DOUBLE, xelem);
print_vector((void *)y, DOUBLE, yelem);
cublasFree (devPtrx);
cublasFree (devPtry);[/codebox]
Any thoughts? is it me whos not expecting it to do the wrong thing? the defenition of cublasDswap is:
void
cublasDswap (int n, double *x, int incx, double *y,
int incy)
interchanges doubleâ€precision vector x with doubleâ€precision vector y.
For i = 0 to n-1, it interchanges
x[lx + i * incx] with y[ly+i* incy]