Why can't MATLAB parse function declarations in CUDA C files containing the "restrict" keyword?

조회 수: 1 (최근 30일)
Hi all,
I'm offloading computation to a GPU using the "CUDAKernel" object from Parallel Computing Toolbox (PCT). This involves compiling CUDA C (".cu" files) as PTX code, and passing both files to the "feval" function.
When I use the "restrict" keyword in my CUDA C program, it compiles fine as PTX. But then when I try to create the CUDAKernel object, I get the following error:
kernel = parallel.gpu.CUDAKernel('CUDAKernel_test.ptx','CUDAKernel_test.cu','CUDAKernel_test');
Error using parallel.internal.gpu.handleKernelArgs>iParseToken (line 329)
Unable to parse declaration: const double * __restrict weights
My function declaration looks like:
__global__ void CUDAKernel_test(double* arg1, const double* __restrict arg2)
The restrict keyword is a message to the compiler that the associated pointer is not aliased. This allows the compiler to make certain optimizations it otherwise couldn't.
If anyone knows why this wouldn't be supported, please let me know.
Thanks!

채택된 답변

Ben Tordoff
Ben Tordoff 2014년 2월 6일
Although
__restrict
is supported by Visual C++, the NVIDIA CUDA programming guide specifies the use of
__restrict__
(as used by GCC and others). This form should work fine using MATLAB R2012b or later. See e.g.:
  댓글 수: 1
Edward
Edward 2014년 2월 6일
Thank you, Ben. So you know I'm not crazy, my reference for "__restrict" was slide 23 of the presentation at this link.
I'm now using "__restrict__" and it it's compiling fine, and MATLAB is creating the CUDAKernel object, but then there's an error using "feval"
An unexpected error occurred during CUDA execution. The CUDA error was:
unspecified launch failure
Have you heard of any problems using "__restrict__"? Perhaps I need to alter some of the arguments I'm passing the kernel?
Thanks again!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with GPU Coder에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by