Reputation: 109
I'm trying to solve an equation with cublasStbsv
function in my CUDA kernel. The kernel code is as follows:
__global__ void invokeDeviceCublasSgemm(cublasStatus_t *returnValue,
int n,
const float *d_alpha,
const float *d_A,
const float *d_B,
const float *d_beta,
float *d_C)
{
cublasHandle_t cnpHandle;
cublasStatus_t status = cublasCreate(&cnpHandle);
if (status != CUBLAS_STATUS_SUCCESS)
{
*returnValue = status;
return;
}
// /* Perform operation using cublas */
// status =
// cublasSgemm(cnpHandle,
// CUBLAS_OP_N, CUBLAS_OP_N,
// n, n, n,
// d_alpha,
// d_A, n,
// d_B, n,
// d_beta,
// d_C, n);
float d_AA[5*5];
float d_BB[5];
// float d_X[5];
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
if(i==j)
{
d_AA[i*5+j] = i;
}else
{
d_AA[i*5+j] = 0;
}
}
d_BB[i] = i*i;
}
status = cublasStbsv(cnpHandle,
CUBLAS_FILL_MODE_UPPER,
CUBLAS_OP_N,
CUBLAS_DIAG_NON_UNIT,
n,n,
d_AA,
5,
d_BB,
1);
for(int i=0;i<5;i++)
{
printf("B i %d %f \n",i,d_BB[i]);
}
cublasDestroy(cnpHandle);
*returnValue = status;
}
I don't understand why am I get the following error:
Starting /home/xavier/Bureau/Developpement/Cuda/build-Cuda_CUBLAS-Qt_5_6_0_gcc_64-Release/Cuda_CUBLAS...
simpleDevLibCUBLAS test running...
GPU Device 0: "GeForce GTX 750 Ti" with compute capability 5.0Host and device APIs will be tested.
** On entry to SBSV parameter number 7 had an illegal value
B i 0 0.000000
B i 1 1.000000
B i 2 4.000000
B i 3 9.000000
B i 4 16.000000
!!!! CUBLAS Device API call failed with code 7
I don't understand which function am I supposed to use to solve my linear equation - cublasStpsv
or cublasStrs
. Can someone help me?
Upvotes: 0
Views: 509
Reputation: 9781
tbsp()
expects a triangular banded matrix; tpsv()
expects a triangular matrix stored in packed format; and trsv()
expects a dense matrix and only the upper/lower part will be used.
According to your code, I think you need trsv()
.
Upvotes: 1