2
votes

I'm trying to parallelize an existing application, I have most of the application parallelized and running on the GPU, I'm having issues migrating one function to the GPU

The function uses a function dtrsv which part of the blas library,see below.

void dtrsv_call_N(double* B, double* A, int* n, int* lda, int* incx) {
  F77_CALL(dtrsv)("L","T","N", n, B, lda, A, incx);
}

I've been able to call the equivalent cuda/cublas function as per below,and the results produced are equivalent to the fortran dtrsv sub routine.

status = cublasDtrsv(handle,CUBLAS_FILL_MODE_LOWER,CUBLAS_OP_T,CUBLAS_DIAG_NON_UNIT, x, dev_m1, x, dev_m2, c);

if (status != CUBLAS_STATUS_SUCCESS) {
        printf ( "!!!! kernel execution error.\n");
        return EXIT_FAILURE;
    }

My problem is that I need to be able to call cublasDtrsv from a device or global function, like below,

__global__ void Dtrsv__cm2(cublasHandle_t handle,cublasFillMode_t uplo,cublasOperation_t trans, cublasDiagType_t diag,int n, const double *A, int lda, double *x, int incx){
    cublasDtrsv(handle,uplo,trans,diag, n, A, lda, x, incx);
}

In cuda 4.0 if I try to compile the below I get the below error, does anyone know if there is a means by which cublas functions can be called from a __device__ or __global__ function?

error: calling a host function("cublasDtrsv_v2") from a __device__/__global__ function("Dtrsv__dev") is not allowed

1
no this isn't not possible. Cublas is a host api and library. - talonmies
Thanks very much for the quick answer, Does anyone know if there is an equivalent which can be called from a device function or a global function ? - C oneil

1 Answers

5
votes

CUDA Toolkit 5.0 introduced a device linker that can link device object files compiled separately. I believe, CUBLAS functions from CUDA Toolkit 5.0 can now be called from device functions (but I only reviewed the headers, I have no experience using CUBLAS).