Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nvcc warnings #2118

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions include/alpaka/test/Extent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,29 @@ namespace alpaka::test
inline constexpr auto extentBuf = []
{
Vec<TDim, TVal> 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;
}();

template<typename TDim, typename TVal>
inline constexpr auto extentSubView = []
{
Vec<TDim, TVal> 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;
}();

template<typename TDim, typename TVal>
inline constexpr auto offset = []
{
Vec<TDim, TVal> 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
2 changes: 1 addition & 1 deletion include/alpaka/test/event/EventHostManualTrigger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ namespace alpaka::test
template<>
struct IsEventHostManualTriggerSupported<DevCudaRt>
{
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;
Expand Down
15 changes: 3 additions & 12 deletions include/alpaka/test/mem/view/ViewTest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned>(sizeof(decltype(*begin)));
for(auto it = begin; it != end; ++it)
{
auto const& elem = *it;
auto const pBytes = reinterpret_cast<std::uint8_t const*>(&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<unsigned long long>(i),
static_cast<unsigned short>(pBytes[i]),
static_cast<unsigned short>(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});
j-stephan marked this conversation as resolved.
Show resolved Hide resolved
*success = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions include/alpaka/vec/Vec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>{}, TVal(1));
return foldrAll(std::multiplies<TVal>{}, TVal{1});
}
#if BOOST_COMP_MSVC || defined(BOOST_COMP_MSVC_EMULATED)
# pragma warning(pop)
Expand All @@ -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>{}, TVal(0));
return foldrAll(std::plus<TVal>{}, TVal{0});
}

//! \return The min of all values.
Expand Down
6 changes: 3 additions & 3 deletions test/common/devCompileOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<$<COMPILE_LANGUAGE:CXX>:-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 $<$<COMPILE_LANGUAGE:CXX>:-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")
Expand Down Expand Up @@ -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 $<$<COMPILE_LANGUAGE:CXX>:-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.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/src/mathLambda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you switch from BOOST_COMP_MSVC to the native define?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because before this change, I got the warning that BOOST_COMP_MSVC was undefined and the compiler assumed 0. I could have included the Boost Predef headers instead, but since I know the MSVC macro, and we also use other vendor specific macros like __NVCC__, i just went with _MSC_VER.


# include "Functor.hpp"
# include "TestTemplate.hpp"
Expand Down
10 changes: 5 additions & 5 deletions test/unit/vec/src/VecTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TEST_CASE("basicVecTraits", "[vec]")
// alpaka::subVecBegin
{
using DimSubVecEnd = alpaka::DimInt<2u>;
static constexpr auto vecSubBegin(alpaka::subVecBegin<DimSubVecEnd>(vec));
[[maybe_unused]] static constexpr auto vecSubBegin(alpaka::subVecBegin<DimSubVecEnd>(vec));

foreach
<DimSubVecEnd::value>(
Expand All @@ -104,7 +104,7 @@ TEST_CASE("basicVecTraits", "[vec]")
// alpaka::subVecEnd
{
using DimSubVecEnd = alpaka::DimInt<2u>;
static constexpr auto vecSubEnd(alpaka::subVecEnd<DimSubVecEnd>(vec));
[[maybe_unused]] static constexpr auto vecSubEnd(alpaka::subVecEnd<DimSubVecEnd>(vec));

foreach
<DimSubVecEnd::value>(
Expand All @@ -118,7 +118,7 @@ TEST_CASE("basicVecTraits", "[vec]")
// alpaka::castVec
{
using SizeCast = std::uint16_t;
static constexpr auto vecCast(alpaka::castVec<SizeCast>(vec));
[[maybe_unused]] static constexpr auto vecCast(alpaka::castVec<SizeCast>(vec));

/*using VecCastConst = decltype(vecCast);
using VecCast = std::decay_t<VecCastConst>;
Expand All @@ -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
<Dim::value>(
Expand All @@ -155,7 +155,7 @@ TEST_CASE("basicVecTraits", "[vec]")
using Dim2 = alpaka::DimInt<2u>;
static constexpr alpaka::Vec<Dim2, Idx> vec2(static_cast<Idx>(47u), static_cast<Idx>(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::Dim<std::decay_t<decltype(vecConcat)>>, alpaka::DimInt<5u>>);

foreach
Expand Down