在Windows上使用clang编译CUDA时的重新定义
Redefinitions when compiling CUDA with clang on Windows
尽管已经提出了一个几乎相同的问题,但答案是针对OSX的,并且不再成立(无论如何,这真的很糟糕(。
问题是在Windows上使用叮当编译cuda时,math_functions.hpp
中有大量的重新定义。
经过一些调查,显然 cuda 决定将其 math_functions.hpp
和 math_functions.h
函数放在 namespace std
中(这甚至合法吗?(,并与 cmath
中的所有 libstdc++ 函数发生冲突,以及 clang 自己的标头来编译 cuda。
我该如何处理?最好不要使用上一个问题中显示的黑客方式?
旁注
根据 clang 的文档,clang 可以根据 __global__
/__device__
限定符重载,代码不应该只是编译吗?
详
版本:
Clang 4.0.0(像这样构建(
libstdc++ 来自 gcc 7.1.0
库达 8.0
视窗 10
全错误输出
clang++ hellocuda.cu --cuda-path=E:cudadevelopment --cuda-gpu-arch=sm_20 -LE:cudadevelopmentlibx64 -lcudart_static -ldl -lrt -std=c++1y -O2 -pedantic -Wall -Wextra -fms-extensions -o program.exe
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:191:
E:cudadevelopment/includemath_functions.hpp:1684:14: error: redefinition of
'__isnan'
__func__(int __isnan(double a))
^
E:TDM-GCCmingw64 7.1.0mingw64x86_64-w64-mingw32includemath.h:525:28: note:
previous definition is here
__CRT_INLINE int __cdecl __isnan (double _x)
^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:191:
E:cudadevelopment/includemath_functions.hpp:1764:14: error: redefinition of
'__signbit'
__func__(int __signbit(double a))
^
E:TDM-GCCmingw64 7.1.0mingw64x86_64-w64-mingw32includemath.h:611:28: note:
previous definition is here
__CRT_INLINE int __cdecl __signbit (double x) {
^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:191:
E:cudadevelopment/includemath_functions.hpp:1776:17: error: redefinition of
'copysign'
__func__(double copysign(double a, double b))
^
E:TDM-GCCmingw64 7.1.0mingw64x86_64-w64-mingw32includemath.h:1069:31: note:
previous definition is here
__CRT_INLINE double __cdecl copysign (double x, double y)
^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:191:
E:cudadevelopment/includemath_functions.hpp:3161:14: error: redefinition of
'__signbitl'
__func__(int __signbitl(long double a))
^
E:TDM-GCCmingw64 7.1.0mingw64x86_64-w64-mingw32includemath.h:636:28: note:
previous definition is here
__CRT_INLINE int __cdecl __signbitl (long double x) {
^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:191:
E:cudadevelopment/includemath_functions.hpp:3166:14: error: redefinition of
'__signbitf'
__func__(int __signbitf(float a))
^
E:TDM-GCCmingw64 7.1.0mingw64x86_64-w64-mingw32includemath.h:624:28: note:
previous definition is here
__CRT_INLINE int __cdecl __signbitf (float x) {
^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:191:
E:cudadevelopment/includemath_functions.hpp:3191:14: error: redefinition of
'__isnanl'
__func__(int __isnanl(long double a))
^
E:TDM-GCCmingw64 7.1.0mingw64x86_64-w64-mingw32includemath.h:565:28: note:
previous definition is here
__CRT_INLINE int __cdecl __isnanl (long double _x)
^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:191:
E:cudadevelopment/includemath_functions.hpp:3196:14: error: redefinition of
'__isnanf'
__func__(int __isnanf(float a))
^
E:TDM-GCCmingw64 7.1.0mingw64x86_64-w64-mingw32includemath.h:546:28: note:
previous definition is here
__CRT_INLINE int __cdecl __isnanf (float _x)
^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:191:
E:cudadevelopment/includemath_functions.hpp:3360:16: error: redefinition of
'copysignf'
__func__(float copysignf(float a, float b))
^
E:TDM-GCCmingw64 7.1.0mingw64x86_64-w64-mingw32includemath.h:1076:30: note:
previous definition is here
__CRT_INLINE float __cdecl copysignf (float x, float y)
^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:250:
E:cudadevelopment/includemath_functions.hpp:365:43: error: functions that differ
only in their return type cannot be overloaded
static __inline__ __host__ __device__ int isinf(double a)
~~~ ^
E:LLVMbin..libclang4.0.0include__clang_cuda_math_forward_declares.h:107:17: note:
previous declaration is here
__DEVICE__ bool isinf(double);
~~~~ ^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:250:
E:cudadevelopment/includemath_functions.hpp:381:43: error: functions that differ
only in their return type cannot be overloaded
static __inline__ __host__ __device__ int isinf(float a)
~~~ ^
E:LLVMbin..libclang4.0.0include__clang_cuda_math_forward_declares.h:108:17: note:
previous declaration is here
__DEVICE__ bool isinf(float);
~~~~ ^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:250:
E:cudadevelopment/includemath_functions.hpp:413:43: error: functions that differ
only in their return type cannot be overloaded
static __inline__ __host__ __device__ int isnan(double a)
~~~ ^
E:LLVMbin..libclang4.0.0include__clang_cuda_math_forward_declares.h:115:17: note:
previous declaration is here
__DEVICE__ bool isnan(double);
~~~~ ^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:250:
E:cudadevelopment/includemath_functions.hpp:429:43: error: functions that differ
only in their return type cannot be overloaded
static __inline__ __host__ __device__ int isnan(float a)
~~~ ^
E:LLVMbin..libclang4.0.0include__clang_cuda_math_forward_declares.h:116:17: note:
previous declaration is here
__DEVICE__ bool isnan(float);
~~~~ ^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:250:
E:cudadevelopment/includemath_functions.hpp:461:43: error: functions that differ
only in their return type cannot be overloaded
static __inline__ __host__ __device__ int isfinite(double a)
~~~ ^
E:LLVMbin..libclang4.0.0include__clang_cuda_math_forward_declares.h:101:17: note:
previous declaration is here
__DEVICE__ bool isfinite(double);
~~~~ ^
In file included from <built-in>:1:
In file included from E:LLVMbin..libclang4.0.0include__clang_cuda_runtime_wrapper.h:250:
E:cudadevelopment/includemath_functions.hpp:477:43: error: functions that differ
only in their return type cannot be overloaded
static __inline__ __host__ __device__ int isfinite(float a)
~~~ ^
E:LLVMbin..libclang4.0.0include__clang_cuda_math_forward_declares.h:102:17: note:
previous declaration is here
__DEVICE__ bool isfinite(float);
~~~~ ^
14 errors generated.
makefile:15: recipe for target 'all' failed
mingw32-make: *** [all] Error 1
我尝试了很多东西。他们失败了。最后,我深入研究了标题,并从字面上宏化了任何有冲突的内容,这些冲突位于
- 库达的math_functions.hpp 叮
- 叮当当的__clang_cuda_math_forward_declares.H
- 叮叮当当的__clang_cuda_cmath.H
clang 使用 _MSC_VER
来检测 Windows,只有在使用 -fms-compatibility 标志时才定义 Windows,但由于未知原因,这会导致其他地方出现大量其他错误。
CUDA 使用_WIN32
和_MSC_VER
的混合来检测 Windows。据我所知,只是宏化所有重新定义的内容只是最简单的方法。
这似乎正在工作,因为没有弹出其他标头错误。
相关文章:
- 定义C++新的环境变量并在 bat 文件中使用它
- 是否可以使用单个定义定义函数的常量和常规版本?(使用模板,自动,decltype等)
- 从使用概念定义的函数返回新对象
- 如何在C++中为 if 和 else 语句定义新行为
- 如何从 C++ 中的现有模板函数定义新函数
- 自定义分配器,包括放置新案例
- 正在通过const-ref未定义的行为捕获新构造的对象
- 如何在CPropertySheet中定义新颜色
- 谁定义新操作员
- 未定义的符号'fixed_address_empty_string':带有protobuf的新张量流运算
- 新的C ,未定义的参考
- boost :: fibonacci_heap:带有比较器重新定义圆形定义错误的嵌套定义
- 宏,用于定义带有添加前缀的新宏
- 取消脱壳:使用模板在多行类型定义中添加一个尖括号后的新行
- C 通过Typedef定义新类型
- 通过在此指针上放置新位置重新初始化对象时未定义的行为
- 在 ss.clear() 之后使用 ss.str( " ") 用于新定义的字符串流
- Eclipse CDT将方法定义定义到标头文件
- 是标头文件中使用“新”定义的成员指针泄漏
- LEX 程序中的未定义定义