Why can't MATLAB parse function declarations in CUDA C files containing the "restrict" keyword?
5 次查看(过去 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!
0 个评论
采纳的回答
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.:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GPU Computing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!