I have to implement a function that I already have in CUDA-C using the OpenACC directives (I have to do a comparison). In the original code there's cubasSgemv call, there is some way to use cublas library under openacc?
Asked
Active
Viewed 683 times
1 Answers
2
Yes, you can use the host_data
construct to do this. Here's an example of how to call cublasSaxpy from OpenACC:
#pragma acc data create(x[0:n]) copyout(y[0:n])
{
#pragma acc kernels
{
for( i = 0; i < n; i++)
{
x[i] = 1.0f;
y[i] = 0.0f;
}
}
#pragma acc host_data use_device(x,y)
{
cublasSaxpy(n, 2.0, x, 1, y, 1);
}
}
I have other examples in an an article I wrote about OpenACC interoperability a few months ago. You can find it at http://www.pgroup.com/lit/articles/insider/v5n2a2.htm .

jefflarkin
- 1,279
- 6
- 14
-
Thank you very much! I write the code this way, but the compiler tells: "call to cuEventSynchronize returned error 700: Launch failed". So I tried to launch the program with cuda-memcheck and I found that for two thread in every block there is an error "Invalid __global__ read of size 4 (...) address xxx is out of bounds". Can this depend on the first argument of cublasSgemv that is a cublasHandle_t type? I use cublasStatus_t status; cublasHandle_t handle; status=cublasCreate(&handle); to make it function, but I don't know how this interact with OpenACC... please help – Angantyr Feb 05 '14 at 11:10
-
of course! here the code https://www.dropbox.com/s/dh5jhgz2uva78cp/kernel_matrix_calculation.c . I don't know if this is the right way to post it, I hope that it'll work. thank very very much for your help. Do you need the original CUDA-C code too? – Angantyr Feb 05 '14 at 17:22
-
there is something wrong with the link? I'm sorry to annoy you but I really don't know how to proceed, some tips will be useful – Angantyr Feb 07 '14 at 11:43