Open codecircuit opened 3 years ago
And does it compile ok with CUDA 11 but C++14? C++11?
With C++14 it works fine.
Which version of CUDA are you using?
When using CUDA 11.0.3, I get compilation errors with C++11 (or 14) as well, see:
https://stackoverflow.com/questions/64968200/constexpr-note-invalid-arithmetic-on-non-array-pointer
Can you describe what you're seeing more specifically, with relevant version numbers and error messages?
... well, I've started working on C++17 compatibility with CUDA 11.1. Definitely a bunch of issues - but all minor so far.
CMakeLists.txt
:
cmake_minimum_required(VERSION 3.18)
project(foobarbaz LANGUAGES CXX CUDA)
find_package(cuda-kat REQUIRED)
add_executable(foobarbaz "foobarbaz.cu")
target_link_libraries(
foobarbaz
PRIVATE
cuda-kat::cuda-kat
)
target_compile_features(foobarbaz PUBLIC cuda_std_17)
My source code file foobarbaz.cu
:
#include <kat/containers/array.hpp>
__global__ void kernel(kat::array<kat::array<int*, 5>, 4> arr) {
*arr[threadIdx.x][threadIdx.x] = threadIdx.x;
}
int main() {}
I use CMake 3.18.4, CUDA 11.1.105, and GCC 8.32 and built the project with the Release build. The compile error I get:
/home/wolf/repositories/cuda-kat/src/kat/common.hpp(49): error: constant "B" is not a type name
/home/wolf/repositories/cuda-kat/src/kat/detail/range_access.hpp(283): error: "empty" has already been declared in the current scope
/home/wolf/repositories/cuda-kat/src/kat/detail/range_access.hpp(283): error: identifier "initializer_list" is undefined
/home/wolf/repositories/cuda-kat/src/kat/detail/range_access.hpp(283): error: type name is not allowed
/home/wolf/repositories/cuda-kat/src/kat/detail/range_access.hpp(283): error: identifier "init_list" is undefined
/home/wolf/repositories/cuda-kat/src/kat/detail/range_access.hpp(283): error: expected a ";"
/usr/include/wchar.h(284): error: identifier "wint_t" is undefined
/usr/include/wchar.h(288): error: identifier "wint_t" is undefined
/usr/include/wchar.h(316): error: identifier "wint_t" is undefined
/usr/include/wchar.h(318): error: expected a ";"
/usr/include/wchar.h(324): error: declaration is incompatible with "int kat::wctob(<error-type>) throw()"
(288): here
...
To compile it again I applied this hack:
diff --git a/src/kat/common.hpp b/src/kat/common.hpp
index 0c6c6e2..0d6c770 100644
--- a/src/kat/common.hpp
+++ b/src/kat/common.hpp
@@ -25,8 +25,8 @@ namespace kat {
*/
using size_t = std::size_t;
-#if __cplusplus < 201703L
-
+//#if __cplusplus < 201703L
+#if 1
// Some C++17 type traits definable in C++11
template<typename ... > struct conjunction : std::true_type {};
diff --git a/src/kat/detail/range_access.hpp b/src/kat/detail/range_access.hpp
index b2b9aa9..54a0d6f 100644
--- a/src/kat/detail/range_access.hpp
+++ b/src/kat/detail/range_access.hpp
@@ -278,10 +278,10 @@ namespace kat {
* @brief Return whether an initializer_list is empty.
* @param init_list Initializer list.
*/
- template <typename T>
- [[nodiscard]] constexpr bool
- empty(initializer_list<T> init_list) noexcept
- { return init_list.size() == 0;}
+ // template <typename T>
+ // [[nodiscard]] constexpr bool
+ // empty(initializer_list<T> init_list) noexcept
+ // { return init_list.size() == 0;}
/**
* @brief Return the data pointer of a container.
@@ -316,10 +316,10 @@ namespace kat {
* @brief Return the data pointer of an initializer list.
* @param init_list Initializer list.
*/
- template <typename T>
- constexpr const T*
- data(initializer_list<T> init_list) noexcept
- { return init_list.begin(); }
+ // template <typename T>
+ // constexpr const T*
+ // data(initializer_list<T> init_list) noexcept
+ // { return init_list.begin(); }
#endif // C++17
Try it now.
It works now. Thanks!
I tried to use
cuda-kat
with c++17, which fails to compile. The reproduction should be easy, because already the include of the header causes compilation issues.