| Issue |
184271
|
| Summary |
CUDA code compile error: no matching function for call to 'max'
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
zhiweij1
|
```
void foo(int &num_blocks, int &num_threads, int world_size) {
num_blocks = 1;
num_threads = max(num_threads, world_size);
}
```
https://godbolt.org/z/Wa96z86q3
This code can be compiled by nvcc.
This function is defined in `crt/math_functions.hpp`:
```
1126 #if !defined(__CUDA_ARCH__)
1127 #if defined(_WIN32)
1128 #define __HELPER_FUNC_LINKAGE static inline __host__ __device__
1129 #pragma warning (push)
1130 #pragma warning (disable : 4211)
1131 #else /* !defined(_WIN32) */
1132 #define __HELPER_FUNC_LINKAGE inline __host__ __device__
1133 #endif /* defined(_WIN32) */
1134
1135 __HELPER_FUNC_LINKAGE int min(const int a, const int b)
1136 {
1137 return (a < b) ? a : b;
1138 }
1139
1140 __HELPER_FUNC_LINKAGE unsigned int umin(const unsigned int a, const unsigned int b)
1141 {
1142 return (a < b) ? a : b;
1143 }
1144
1145 __HELPER_FUNC_LINKAGE long long int llmin(const long long int a, const long long int b)
1146 {
1147 return (a < b) ? a : b;
1148 }
1149
1150 __HELPER_FUNC_LINKAGE unsigned long long int ullmin(const unsigned long long int a,
1151 const unsigned long long int b)
1152 {
1153 return (a < b) ? a : b;
1154 }
1155
1156 __HELPER_FUNC_LINKAGE int max(const int a, const int b)
1157 {
1158 return (a > b) ? a : b;
1159 }
1160
1161 __HELPER_FUNC_LINKAGE unsigned int umax(const unsigned int a, const unsigned int b)
1162 {
1163 return (a > b) ? a : b;
1164 }
```
and this file is included by https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/__clang_cuda_runtime_wrapper.h in 2 places.
But `__CUDA_ARCH__` is defined at both places, so the above definitions are not enabled.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs