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

Several warnings in cuda builds #6991

Open
ndellingwood opened this issue May 6, 2024 · 7 comments · May be fixed by #7021
Open

Several warnings in cuda builds #6991

ndellingwood opened this issue May 6, 2024 · 7 comments · May be fixed by #7021

Comments

@ndellingwood
Copy link
Contributor

ndellingwood commented May 6, 2024

Describe the bug

Several warnings are present in cuda builds, below are for:

cuda/11.8 + gcc/11.3.0 on Hopper arch (Blake H100 queue):

TestArray.cpp

01:16:44 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/unit_test/TestArray.cpp(54): warning #20013-D: calling a constexpr __host__ function("size") from a __host__ __device__ function("is_equal") is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this.
01:16:44           detected during instantiation of "__nv_bool <unnamed>::is_equal(const L &, const R &) [with L=Kokkos::Array<int, 5UL>, R=Kokkos::Array<int, 5UL>]" 
01:16:44 (70): here
01:16:44 
01:16:44 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/unit_test/TestArray.cpp(56): warning #20013-D: calling a constexpr __host__ function("size") from a __host__ __device__ function("is_equal") is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this.
01:16:44           detected during instantiation of "__nv_bool <unnamed>::is_equal(const L &, const R &) [with L=Kokkos::Array<int, 5UL>, R=Kokkos::Array<int, 5UL>]" 
01:16:44 (70): here
01:16:44 
01:16:44 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/src/Kokkos_Array.hpp(143): warning #20013-D: calling a constexpr __host__ function("kokkos_swap") from a __host__ __device__ function("kokkos_swap") is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this.
01:16:44           detected during instantiation of "std::enable_if_t<Kokkos::Impl::is_swappable<U>::value, void> Kokkos::kokkos_swap(Kokkos::Array<<unnamed>::MyInt, 2UL> &, Kokkos::Array<<unnamed>::MyInt, 2UL> &) [with U=<unnamed>::MyInt]" 

TestLegionInitialization.cpp

01:16:50 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/unit_test/TestLegionInitialization.cpp(30): warning #177-D: member "<unnamed>::initialization_legion_initialization_Test::test_info_" was declared but never referenced

TestCuda_InterOp_StreamsMultiGPU.cpp

01:17:03 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/unit_test/cuda/TestCuda_InterOp_StreamsMultiGPU.cpp(60): warning #177-D: member "<unnamed>::cuda_multi_gpu_managed_views_Test::test_info_" was declared but never referenced

TestCuda_InterOp_StreamsMultiGPU.cpp

01:17:03 
01:17:03 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/unit_test/cuda/TestCuda_InterOp_StreamsMultiGPU.cpp(99): warning #177-D: member "<unnamed>::cuda_multi_gpu_scratch_space_Test::test_info_" was declared but never referenced

TestParseCmdLineArgsAndEnvVars.cpp

01:17:04 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/unit_test/TestParseCmdLineArgsAndEnvVars.cpp(143): warning #177-D: member "<unnamed>::defaultdevicetype_cmd_line_args_num_threads_Test::test_info_" was declared but never referenced
01:17:04 
01:17:04 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/unit_test/TestParseCmdLineArgsAndEnvVars.cpp(156): warning #177-D: member "<unnamed>::defaultdevicetype_cmd_line_args_device_id_Test::test_info_" was declared but never referenced
...

TestScopedRegion.cpp

01:18:02 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/unit_test/tools/TestScopedRegion.cpp(34): warning #177-D: member "<unnamed>::defaultdevicetype_scoped_profile_region_Test::test_info_" was declared but never referenced

Kokkos_Complex.hpp

01:19:50 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/src/Kokkos_Complex.hpp(110): warning #20208-D: 'long double' is treated as 'double' in device code
01:19:50 
01:19:50 Warning #20208-D: 'long double' is treated as 'double' in device code

*TestNumericTraits.hpp

01:23:30 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/unit_test/TestNumericTraits.hpp(46): warning #20208-D: 'long double' is treated as 'double' in device code
01:23:30 
01:23:30 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/unit_test/TestNumericTraits.hpp(104): warning #20208-D: 'long double' is treated as 'double' in device code
01:23:30 
01:23:30 /home/jenkins/blake-new/workspace/Kokkos_develop_blake_cuda_1180_gcc_1130_HOPPER90/kokkos/core/unit_test/TestNumericTraits.hpp(105): warning #20208-D: 'long double' is treated as 'double' in device code
...
# lots more

Please include the following for a minimal reproducer

Reproducer (blake H100 queue):

source /projects/x86-64-icelake-rocky8/spack-config/blake-setup-user-module-env.sh
module purge
module load cmake gcc/11.3.0 cuda/11.8.0 git

$KOKKOS_PATH/generate_makefile.bash --with-cuda --arch=HOPPER90 --compiler=$KOKKOS_PATH/bin/nvcc_wrapper

make -j16
@ndellingwood
Copy link
Contributor Author

Should any of these be suppressed using -diag-suppress <warning-number>?

@ndellingwood
Copy link
Contributor Author

ndellingwood commented May 6, 2024

cuda/11.2.2 + gcc/8.3.0 for Volta70 + Power9 (Weaver rhel8 queue):

TestViewRank.cpp

07:16:00 /home/jenkins/weaver/workspace/Kokkos_develop_weaver_cuda_serial_cuda1122_gcc830_volta/kokkos/core/unit_test/TestViewRank.cpp(31): warning: variable "rank" was set but never used
07:16:00           detected during instantiation of "__nv_bool <unnamed>::test_view_rank_and_dynamic_rank<View,Rank,RankDynamic>() [with View=Kokkos::View<long long>, Rank=0UL, RankDynamic=0UL]" 
07:16:00 (42): here

TestMathematicalFunctions.hpp

07:19:38 /home/jenkins/weaver/workspace/Kokkos_develop_weaver_cuda_serial_cuda1122_gcc830_volta/kokkos/core/unit_test/TestMathematicalFunctions.hpp(403): warning: missing return statement at end of non-void function "MathUnaryFunction_sin::eval_std(T) [with T=__nv_bool]"
07:19:38           detected during:
07:19:38             instantiation of "auto MathUnaryFunction_sin::eval_std(T) [with T=__nv_bool]" 
07:19:38 (561): here
07:19:38             instantiation of function "lambda [](auto)->auto [with <auto-1>=__nv_bool]" 
07:19:38 /usr/include/c++/8/bits/stl_algo.h(4304): here
07:19:38             instantiation of "_OIter std::transform(_IIter, _IIter, _OIter, _UnaryOperation) [with _IIter=const __nv_bool *, _OIter=math_unary_function_return_type_t<__nv_bool> *, _UnaryOperation=lambda [](auto)->auto]" 
07:19:38 (561): here
07:19:38             instantiation of "TestMathUnaryFunction<Space, Func, Arg, N, Ret>::TestMathUnaryFunction(const Arg (&)[N]) [with Space=Kokkos::Cuda, Func=MathUnaryFunction_sin, Arg=__nv_bool, N=2UL, Ret=math_unary_function_return_type_t<__nv_bool>]" 
07:19:38 (585): here
07:19:38             instantiation of "void do_test_math_unary_function<Space,Func...,Arg,N>(const Arg (&)[N]) [with Space=Kokkos::Cuda, Func=<MathUnaryFunction_sin>, Arg=__nv_bool, N=2UL]" 
07:19:38 (696): here
...

TestStdAlgorithmsCommon.hpp

07:26:12 /home/jenkins/weaver/workspace/Kokkos_develop_weaver_cuda_serial_cuda1122_gcc830_volta/kokkos/algorithms/unit_tests/TestStdAlgorithmsCommon.hpp(206): warning: missing return statement at end of non-void function "Test::stdalgos::create_deep_copyable_compatible_view_with_same_extent(ViewType) [with ViewType=Kokkos::View<double **, Kokkos::Cuda::memory_space>]"
07:26:12           detected during:
07:26:12             instantiation of "auto Test::stdalgos::create_deep_copyable_compatible_view_with_same_extent(ViewType) [with ViewType=Kokkos::View<double **, Kokkos::Cuda::memory_space>]" 
07:26:12 (503): here
07:26:12             instantiation of "auto Test::stdalgos::create_random_view_and_host_clone(LayoutTagType, std::size_t, std::size_t, Kokkos::pair<ValueType, ValueType>, const std::__cxx11::string &, std::size_t) [with LayoutTagType=Test::stdalgos::DynamicTag, ValueType=double]" 
07:26:12 /home/jenkins/weaver/workspace/Kokkos_develop_weaver_cuda_serial_cuda1122_gcc830_volta/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamCountIf.cpp(106): here
07:26:12             instantiation of "void Test::stdalgos::TeamCountIf::test_A<LayoutTag,ValueType>(std::size_t, std::size_t, int) [with LayoutTag=Test::stdalgos::DynamicTag, ValueType=double]" 
07:26:12 /home/jenkins/weaver/workspace/Kokkos_develop_weaver_cuda_serial_cuda1122_gcc830_volta/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamCountIf.cpp(148): here
07:26:12             instantiation of "void Test::stdalgos::TeamCountIf::run_all_scenarios<LayoutTag,ValueType>() [with LayoutTag=Test::stdalgos::DynamicTag, ValueType=double]" 
07:26:12 /home/jenkins/weaver/workspace/Kokkos_develop_weaver_cuda_serial_cuda1122_gcc830_volta/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamCountIf.cpp(155): here
...

Reproducer (Weaver rhel8 queue):

# Interactive Weaver session
bsub -Is -n 1 -q rhel8 -gpu "num=1" bash

# Environment
source /etc/profile.d/modules.sh
source /projects/ppc64le-pwr9-rhel8/legacy-env.sh
cuda/11.2.2/gcc/8.3.1 cmake/3.23.1

# Configure
${KOKKOS_PATH}/generate_makefile.bash --with-cuda --with-serial --compiler=${KOKKOS_PATH}/bin/nvcc_wrapper --arch=Volta70,Power9 --with-cuda-options=enable_lambda --kokkos-path=${KOKKOS_PATH} --cxxstandard=17

# Build, observe warnings
make -j16

@ndellingwood
Copy link
Contributor Author

ndellingwood commented May 14, 2024

List of warnings needing assignment:

  • TestArray.cpp : (multiple, e.g.) TestArray.cpp(54): warning #20013-D: calling a constexpr __host__ function("size") from a __host__ __device__ function("is_equal") is not allowed.
  • TestLegionInitialization.cpp : TestLegionInitialization.cpp(30): warning #177-D: member "<unnamed>::initialization_legion_initialization_Test::test_info_" was declared but never referenced
  • TestCuda_InterOp_StreamsMultiGPU.cpp : (multiple e.g.) TestCuda_InterOp_StreamsMultiGPU.cpp(60): warning #177-D: member "<unnamed>::cuda_multi_gpu_managed_views_Test::test_info_" was declared but never referenced
  • TestParseCmdLineArgsAndEnvVars.cpp : (multiple, e.g.) TestParseCmdLineArgsAndEnvVars.cpp(143): warning #177-D: member "<unnamed>::defaultdevicetype_cmd_line_args_num_threads_Test::test_info_" was declared but never referenced
  • TestScopedRegion.cpp : TestScopedRegion.cpp(34): warning #177-D: member "<unnamed>::defaultdevicetype_scoped_profile_region_Test::test_info_" was declared but never referenced
  • Kokkos_Complex.hpp : Kokkos_Complex.hpp(110): warning #20208-D: 'long double' is treated as 'double' in device code
  • TestNumericTraits.hpp : (multiple, e.g.) TestNumericTraits.hpp(46): warning #20208-D: 'long double' is treated as 'double' in device code
  • TestViewRank.cpp : (multiple, e.g.) TestViewRank.cpp(31): warning: variable "rank" was set but never used
  • TestMathematicalFunctions.hpp : (multiple, e.g.) TestMathematicalFunctions.hpp(403): warning: missing return statement at end of non-void function
  • TestStdAlgorithmsCommon.hpp : TestStdAlgorithmsCommon.hpp(206): warning: missing return statement at end of non-void function

@ndellingwood
Copy link
Contributor Author

ndellingwood commented May 14, 2024

Some of the warning: missing return statement at end of non-void function issues might be resolvable with similar solution as #6456 (guarded for nvcc compiler), though this would only work presumably for cuda version >= 11.3 when __builtin_unreachable was added link?

@masterleinad
Copy link
Contributor

diff --git a/core/unit_test/TestArray.cpp b/core/unit_test/TestArray.cpp
index 11b28bed9..c2c8510d8 100644
--- a/core/unit_test/TestArray.cpp
+++ b/core/unit_test/TestArray.cpp
@@ -132,7 +132,7 @@ struct MyInt {
   int i;
 
  private:
-  friend constexpr void kokkos_swap(MyInt& lhs, MyInt& rhs) noexcept {
+  friend constexpr KOKKOS_FUNCTION void kokkos_swap(MyInt& lhs, MyInt& rhs) noexcept {
     lhs.i = 255;
     rhs.i = 127;
   }

should fix the warning regarding kokkos_swap.

diff --git a/core/unit_test/TestArray.cpp b/core/unit_test/TestArray.cpp
index d20d355b7..11b28bed9 100644
--- a/core/unit_test/TestArray.cpp
+++ b/core/unit_test/TestArray.cpp
@@ -51,9 +51,9 @@ static_assert(test_array_structured_binding_support());
 
 template <typename L, typename R>
 KOKKOS_FUNCTION constexpr bool is_equal(L const& l, R const& r) {
-  if (std::size(l) != std::size(r)) return false;
+  if (l.size() != r.size()) return false;
 
-  for (size_t i = 0; i != std::size(l); ++i) {
+  for (size_t i = 0; i != l.size(); ++i) {
     if (l[i] != r[i]) return false;
   }

should fix

 TestArray.cpp : (multiple, e.g.) TestArray.cpp(54): warning #20013-D: calling a constexpr __host__ function("size") from a __host__ __device__ function("is_equal") is not allowed.

@masterleinad
Copy link
Contributor

diff --git a/tpls/gtest/gtest/gtest.h b/tpls/gtest/gtest/gtest.h
index c17c9ab3f..2b34f3a60 100644
--- a/tpls/gtest/gtest/gtest.h
+++ b/tpls/gtest/gtest/gtest.h
@@ -4910,7 +4910,7 @@ class NeverThrown {
   class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)                    \
       : public parent_class {                                                 \
    public:                                                                    \
-    GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() = default;           \
+    GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() { (void)test_info_; }\
     ~GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() override = default; \
     GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name,   \
                                                            test_name));       \

fixes the gtest related errors.

@masterleinad masterleinad linked a pull request May 21, 2024 that will close this issue
@ajpowelsnl
Copy link
Contributor

@ndellingwood -- I'll see if I can reproduce and fix TestStdAlgorithmsCommon.hpp;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants