gpt4 book ai didi

c++ - CUDA 和 Eclipse : How can I tell eclipse that <<< (or >>>) is part of the syntax?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:24:24 28 4
gpt4 key购买 nike

到目前为止,我发现如果定义了 __CDT_PARSER__,可以通过定义它们来防止 Eclipse 提示专有 CUDA 关键字。以下代码可防止 Eclipse 提示大多数 CUDA 关键字。

// Prevent eclipse from bitching about unknown keywords
#ifdef __CDT_PARSER__
#define __global__
#define __device__
#define __host__
#define __shared__
#endif

然而,这不适用于用于配置内核启动的括号,因为我的内核通常有很长的参数列表,这很烦人。有什么想法吗?

最佳答案

这是一个适用于 Eclipse CDT、Visual Studio 或 Qt Creator 的解决方案这是我的解决方案:

#if (defined __CDT_PARSER__) || (defined __INTELLISENSE__) || (defined Q_CREATOR_RUN)
#define __global__
#define __device__
#define __host__
#define __shared__
#define CUDA_KERNEL_DIM(...)

#else
#define CUDA_KERNEL_DIM(...) <<< __VA_ARGS__ >>>

#endif

然后调用内核:

myKernel CUDA_KERNEL_DIM(gridDim, blockDim) (foo, bar);

关于c++ - CUDA 和 Eclipse : How can I tell eclipse that <<< (or >>>) is part of the syntax?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6150368/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com