From 2830f3645be9d11ec69cf02e53ebbc2a1e234f17 Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Thu, 31 Aug 2023 21:20:39 +0200 Subject: [PATCH] Fix nvcc warnings --- include/alpaka/test/Extent.hpp | 15 +++++++++------ .../alpaka/test/event/EventHostManualTrigger.hpp | 2 +- include/alpaka/test/mem/view/ViewTest.hpp | 15 +++------------ include/alpaka/vec/Vec.hpp | 4 ++-- test/common/devCompileOptions.cmake | 6 +++--- test/unit/math/src/mathLambda.cpp | 2 +- test/unit/vec/src/VecTest.cpp | 10 +++++----- 7 files changed, 24 insertions(+), 30 deletions(-) diff --git a/include/alpaka/test/Extent.hpp b/include/alpaka/test/Extent.hpp index e8368beca3f9..56ccfafb9367 100644 --- a/include/alpaka/test/Extent.hpp +++ b/include/alpaka/test/Extent.hpp @@ -14,8 +14,9 @@ namespace alpaka::test inline constexpr auto extentBuf = [] { Vec v; - for(TVal i = 0; i < TVal{TDim::value}; i++) - v[i] = 11 - i; + if constexpr(TDim::value > 0) + for(TVal i = 0; i < TVal{TDim::value}; i++) + v[i] = 11 - i; return v; }(); @@ -23,8 +24,9 @@ namespace alpaka::test inline constexpr auto extentSubView = [] { Vec v; - for(TVal i = 0; i < TVal{TDim::value}; i++) - v[i] = 8 - i * 2; + if constexpr(TDim::value > 0) + for(TVal i = 0; i < TVal{TDim::value}; i++) + v[i] = 8 - i * 2; return v; }(); @@ -32,8 +34,9 @@ namespace alpaka::test inline constexpr auto offset = [] { Vec v; - for(TVal i = 0; i < TVal{TDim::value}; i++) - v[i] = 2 + i; + if constexpr(TDim::value > 0) + for(TVal i = 0; i < TVal{TDim::value}; i++) + v[i] = 2 + i; return v; }(); } // namespace alpaka::test diff --git a/include/alpaka/test/event/EventHostManualTrigger.hpp b/include/alpaka/test/event/EventHostManualTrigger.hpp index f012c3f5beff..3c4cf51406ae 100644 --- a/include/alpaka/test/event/EventHostManualTrigger.hpp +++ b/include/alpaka/test/event/EventHostManualTrigger.hpp @@ -340,7 +340,7 @@ namespace alpaka::test template<> struct IsEventHostManualTriggerSupported { - ALPAKA_FN_HOST static auto isSupported(DevCudaRt const& dev) -> bool + ALPAKA_FN_HOST static auto isSupported([[maybe_unused]] DevCudaRt const& dev) -> bool { # if CUDA_VERSION < 11070 int result = 0; diff --git a/include/alpaka/test/mem/view/ViewTest.hpp b/include/alpaka/test/mem/view/ViewTest.hpp index 82ab915f66cf..eef3b5a14247 100644 --- a/include/alpaka/test/mem/view/ViewTest.hpp +++ b/include/alpaka/test/mem/view/ViewTest.hpp @@ -112,25 +112,16 @@ namespace alpaka::test TIter const& end, std::uint8_t const& byte) const { - constexpr auto elemSizeInByte = sizeof(decltype(*begin)); + constexpr auto elemSizeInByte = static_cast(sizeof(decltype(*begin))); for(auto it = begin; it != end; ++it) { auto const& elem = *it; auto const pBytes = reinterpret_cast(&elem); - for(std::size_t i = 0u; i < elemSizeInByte; ++i) + for(unsigned i = 0; i < elemSizeInByte; ++i) { if(pBytes[i] != byte) { -#if BOOST_COMP_NVCC - // nvcc doesn't support %zu and %hhu so we have to improvise - printf( - "Byte at offset %ull is different: %hu != %hu\n", - static_cast(i), - static_cast(pBytes[i]), - static_cast(byte)); -#else - printf("Byte at offset %zu is different: %hhu != %hhu\n", i, pBytes[i], byte); -#endif + printf("Byte at offset %u is different: %u != %u\n", i, unsigned{pBytes[i]}, unsigned{byte}); *success = false; } } diff --git a/include/alpaka/vec/Vec.hpp b/include/alpaka/vec/Vec.hpp index 79f103119066..ad13596d4aab 100644 --- a/include/alpaka/vec/Vec.hpp +++ b/include/alpaka/vec/Vec.hpp @@ -236,7 +236,7 @@ namespace alpaka ALPAKA_NO_HOST_ACC_WARNING [[nodiscard]] ALPAKA_FN_HOST_ACC constexpr auto prod() const -> TVal { - return foldrAll(std::multiplies{}, TVal(1)); + return foldrAll(std::multiplies{}, TVal{1}); } #if BOOST_COMP_MSVC || defined(BOOST_COMP_MSVC_EMULATED) # pragma warning(pop) @@ -245,7 +245,7 @@ namespace alpaka ALPAKA_NO_HOST_ACC_WARNING [[nodiscard]] ALPAKA_FN_HOST_ACC constexpr auto sum() const -> TVal { - return foldrAll(std::plus{}, TVal(0)); + return foldrAll(std::plus{}, TVal{0}); } //! \return The min of all values. diff --git a/test/common/devCompileOptions.cmake b/test/common/devCompileOptions.cmake index d00bdd758360..765d3f12d5d7 100644 --- a/test/common/devCompileOptions.cmake +++ b/test/common/devCompileOptions.cmake @@ -61,9 +61,9 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") #list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wconversion") list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wsign-conversion") list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wvector-operation-performance") - list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wzero-as-null-pointer-constant") + list(APPEND alpaka_DEV_COMPILE_OPTIONS $<$:-Wzero-as-null-pointer-constant>) # occurs in nvcc generated code list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wdate-time") - list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wuseless-cast") + list(APPEND alpaka_DEV_COMPILE_OPTIONS $<$:-Wuseless-cast>) # occurs in nvcc generated code list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wlogical-op") list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wno-aggressive-loop-optimizations") list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wmissing-declarations") @@ -91,7 +91,7 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wsign-promo") list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wconditionally-supported") list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wnoexcept") - list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wold-style-cast") + list(APPEND alpaka_DEV_COMPILE_OPTIONS $<$:-Wold-style-cast>) # occurs in nvcc generated code list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wsuggest-final-types") list(APPEND alpaka_DEV_COMPILE_OPTIONS "-Wsuggest-final-methods") # This does not work correctly as it suggests override to methods that are already marked with final. diff --git a/test/unit/math/src/mathLambda.cpp b/test/unit/math/src/mathLambda.cpp index fe375f239d39..e18bf9009e0d 100644 --- a/test/unit/math/src/mathLambda.cpp +++ b/test/unit/math/src/mathLambda.cpp @@ -7,7 +7,7 @@ // "On Windows, the enclosing parent function ("C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_...") for an extended // __host__ // __device__ lambda cannot have internal or no linkage" -#if(!defined(__NVCC__) || (defined(__NVCC__) && defined(__CUDACC_EXTENDED_LAMBDA__) && !BOOST_COMP_MSVC)) +#if(!defined(__NVCC__) || (defined(__NVCC__) && defined(__CUDACC_EXTENDED_LAMBDA__) && !defined(_MSC_VER))) # include "Functor.hpp" # include "TestTemplate.hpp" diff --git a/test/unit/vec/src/VecTest.cpp b/test/unit/vec/src/VecTest.cpp index 7580303e0893..171ec013187f 100644 --- a/test/unit/vec/src/VecTest.cpp +++ b/test/unit/vec/src/VecTest.cpp @@ -90,7 +90,7 @@ TEST_CASE("basicVecTraits", "[vec]") // alpaka::subVecBegin { using DimSubVecEnd = alpaka::DimInt<2u>; - static constexpr auto vecSubBegin(alpaka::subVecBegin(vec)); + [[maybe_unused]] static constexpr auto vecSubBegin(alpaka::subVecBegin(vec)); foreach ( @@ -104,7 +104,7 @@ TEST_CASE("basicVecTraits", "[vec]") // alpaka::subVecEnd { using DimSubVecEnd = alpaka::DimInt<2u>; - static constexpr auto vecSubEnd(alpaka::subVecEnd(vec)); + [[maybe_unused]] static constexpr auto vecSubEnd(alpaka::subVecEnd(vec)); foreach ( @@ -118,7 +118,7 @@ TEST_CASE("basicVecTraits", "[vec]") // alpaka::castVec { using SizeCast = std::uint16_t; - static constexpr auto vecCast(alpaka::castVec(vec)); + [[maybe_unused]] static constexpr auto vecCast(alpaka::castVec(vec)); /*using VecCastConst = decltype(vecCast); using VecCast = std::decay_t; @@ -139,7 +139,7 @@ TEST_CASE("basicVecTraits", "[vec]") // alpaka::reverseVec { - static constexpr auto vecReverse(alpaka::reverseVec(vec)); + [[maybe_unused]] static constexpr auto vecReverse(alpaka::reverseVec(vec)); foreach ( @@ -155,7 +155,7 @@ TEST_CASE("basicVecTraits", "[vec]") using Dim2 = alpaka::DimInt<2u>; static constexpr alpaka::Vec vec2(static_cast(47u), static_cast(11u)); - static constexpr auto vecConcat(alpaka::concatVec(vec, vec2)); + [[maybe_unused]] static constexpr auto vecConcat(alpaka::concatVec(vec, vec2)); STATIC_REQUIRE(std::is_same_v>, alpaka::DimInt<5u>>); foreach