From 541ae8b2b6d4c9478ceab3e65f59457b7f9c01ab Mon Sep 17 00:00:00 2001 From: Terry Cojean Date: Thu, 15 Oct 2020 19:09:42 +0200 Subject: [PATCH] Fix the gtest issue with MSVC. `using T = x;` is banned inside any gtest class used in a `TYPED_TEST` fashion because gtest also defines a `T` of its own and somehow `MSVC` confuses the two. --- core/test/utils.hpp | 3 +++ include/ginkgo/core/base/executor.hpp | 2 +- include/ginkgo/core/base/lin_op.hpp | 16 ++++++++-------- include/ginkgo/core/matrix/csr.hpp | 16 ++++++++-------- include/ginkgo/core/stop/criterion.hpp | 4 ++-- reference/test/matrix/ell_kernels.cpp | 9 ++++----- reference/test/matrix/hybrid_kernels.cpp | 9 ++++----- third_party/gtest/CMakeLists.txt | 4 ++-- 8 files changed, 32 insertions(+), 31 deletions(-) diff --git a/core/test/utils.hpp b/core/test/utils.hpp index 89b135a01f3..d6ae92bb951 100644 --- a/core/test/utils.hpp +++ b/core/test/utils.hpp @@ -39,6 +39,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include + + #include #include diff --git a/include/ginkgo/core/base/executor.hpp b/include/ginkgo/core/base/executor.hpp index df19b235178..005050e8250 100644 --- a/include/ginkgo/core/base/executor.hpp +++ b/include/ginkgo/core/base/executor.hpp @@ -569,7 +569,7 @@ class Executor : public log::EnableLogging { try { this->raw_copy_from(src_exec, num_elems * sizeof(T), src_ptr, dest_ptr); - } catch (NotSupported &err) { + } catch (NotSupported &) { // Unoptimized copy. Try to go through the masters. auto src_master = src_exec->get_master().get(); if (num_elems > 0 && src_master != src_exec) { diff --git a/include/ginkgo/core/base/lin_op.hpp b/include/ginkgo/core/base/lin_op.hpp index 6c873198b6e..d566d054aaa 100644 --- a/include/ginkgo/core/base/lin_op.hpp +++ b/include/ginkgo/core/base/lin_op.hpp @@ -810,12 +810,12 @@ using EnableDefaultLinOpFactory = * * @ingroup LinOp */ -#define GKO_CREATE_FACTORY_PARAMETERS(_parameters_name, _factory_name) \ -public: \ - class _factory_name; \ - struct _parameters_name##_type \ - : ::gko::enable_parameters_type<_parameters_name##_type, \ - _factory_name> +#define GKO_CREATE_FACTORY_PARAMETERS(_parameters_name, _factory_name) \ +public: \ + class _factory_name; \ + struct _parameters_name##_type \ + : public ::gko::enable_parameters_type<_parameters_name##_type, \ + _factory_name> /** @@ -905,8 +905,8 @@ public: \ _parameters_name##_type> { \ friend class ::gko::EnablePolymorphicObject<_factory_name, \ ::gko::LinOpFactory>; \ - friend class ::gko::enable_parameters_type<_parameters_name##_type, \ - _factory_name>; \ + friend struct ::gko::enable_parameters_type<_parameters_name##_type, \ + _factory_name>; \ explicit _factory_name(std::shared_ptr exec) \ : ::gko::EnableDefaultLinOpFactory<_factory_name, _lin_op, \ _parameters_name##_type>( \ diff --git a/include/ginkgo/core/matrix/csr.hpp b/include/ginkgo/core/matrix/csr.hpp index a30f6f856e3..426a4daace9 100644 --- a/include/ginkgo/core/matrix/csr.hpp +++ b/include/ginkgo/core/matrix/csr.hpp @@ -437,22 +437,22 @@ class Csr : public EnableLinOp>, { if (warp_size_ > 0) { int multiple = 8; - if (nnz >= 2e8) { + if (nnz >= static_cast(2e8)) { multiple = 2048; - } else if (nnz >= 2e7) { + } else if (nnz >= static_cast(2e7)) { multiple = 512; - } else if (nnz >= 2e6) { + } else if (nnz >= static_cast(2e6)) { multiple = 128; - } else if (nnz >= 2e5) { + } else if (nnz >= static_cast(2e5)) { multiple = 32; } #if GINKGO_HIP_PLATFORM_HCC if (!cuda_strategy_) { multiple = 8; - if (nnz >= 1e7) { + if (nnz >= static_cast(1e7)) { multiple = 64; - } else if (nnz >= 1e6) { + } else if (nnz >= static_cast(1e6)) { multiple = 16; } } @@ -484,13 +484,13 @@ class Csr : public EnableLinOp>, const index_type nvidia_row_len_limit = 1024; /* Use imbalance strategy when the matrix has more more than 1e6 on * NVIDIA hardware */ - const index_type nvidia_nnz_limit = 1e6; + const index_type nvidia_nnz_limit{static_cast(1e6)}; /* Use imbalance strategy when the maximum number of nonzero per row is * more than 768 on AMD hardware */ const index_type amd_row_len_limit = 768; /* Use imbalance strategy when the matrix has more more than 1e8 on AMD * hardware */ - const index_type amd_nnz_limit = 1e8; + const index_type amd_nnz_limit{static_cast(1e8)}; /** * Creates an automatical strategy. diff --git a/include/ginkgo/core/stop/criterion.hpp b/include/ginkgo/core/stop/criterion.hpp index 35c28aefdd9..41d48b2d9ae 100644 --- a/include/ginkgo/core/stop/criterion.hpp +++ b/include/ginkgo/core/stop/criterion.hpp @@ -297,8 +297,8 @@ public: \ _factory_name, _criterion, _parameters_name##_type> { \ friend class ::gko::EnablePolymorphicObject< \ _factory_name, ::gko::stop::CriterionFactory>; \ - friend class ::gko::enable_parameters_type<_parameters_name##_type, \ - _factory_name>; \ + friend struct ::gko::enable_parameters_type<_parameters_name##_type, \ + _factory_name>; \ explicit _factory_name(std::shared_ptr exec) \ : ::gko::stop::EnableDefaultCriterionFactory< \ _factory_name, _criterion, _parameters_name##_type>( \ diff --git a/reference/test/matrix/ell_kernels.cpp b/reference/test/matrix/ell_kernels.cpp index 60de3d37551..d8250025237 100644 --- a/reference/test/matrix/ell_kernels.cpp +++ b/reference/test/matrix/ell_kernels.cpp @@ -60,7 +60,6 @@ class Ell : public ::testing::Test { typename std::tuple_element<0, decltype(ValueIndexType())>::type; using index_type = typename std::tuple_element<1, decltype(ValueIndexType())>::type; - using T = value_type; using Mtx = gko::matrix::Ell; using Csr = gko::matrix::Csr; using Vec = gko::matrix::Dense; @@ -94,10 +93,10 @@ class Ell : public ::testing::Test { EXPECT_EQ(c[1], 1); EXPECT_EQ(c[2], 2); EXPECT_EQ(c[3], 1); - EXPECT_EQ(v[0], T{1.0}); - EXPECT_EQ(v[1], T{3.0}); - EXPECT_EQ(v[2], T{2.0}); - EXPECT_EQ(v[3], T{5.0}); + EXPECT_EQ(v[0], value_type{1.0}); + EXPECT_EQ(v[1], value_type{3.0}); + EXPECT_EQ(v[2], value_type{2.0}); + EXPECT_EQ(v[3], value_type{5.0}); } std::shared_ptr exec; diff --git a/reference/test/matrix/hybrid_kernels.cpp b/reference/test/matrix/hybrid_kernels.cpp index 0ce2693fe37..3d57b5e3114 100644 --- a/reference/test/matrix/hybrid_kernels.cpp +++ b/reference/test/matrix/hybrid_kernels.cpp @@ -61,7 +61,6 @@ class Hybrid : public ::testing::Test { typename std::tuple_element<0, decltype(ValueIndexType())>::type; using index_type = typename std::tuple_element<1, decltype(ValueIndexType())>::type; - using T = value_type; using Mtx = gko::matrix::Hybrid; using Vec = gko::matrix::Dense; using Csr = gko::matrix::Csr; @@ -119,10 +118,10 @@ class Hybrid : public ::testing::Test { EXPECT_EQ(c[1], 1); EXPECT_EQ(c[2], 2); EXPECT_EQ(c[3], 1); - EXPECT_EQ(v[0], T{1.0}); - EXPECT_EQ(v[1], T{3.0}); - EXPECT_EQ(v[2], T{2.0}); - EXPECT_EQ(v[3], T{5.0}); + EXPECT_EQ(v[0], value_type{1.0}); + EXPECT_EQ(v[1], value_type{3.0}); + EXPECT_EQ(v[2], value_type{2.0}); + EXPECT_EQ(v[3], value_type{5.0}); } std::shared_ptr exec; diff --git a/third_party/gtest/CMakeLists.txt b/third_party/gtest/CMakeLists.txt index f68db6d2060..9d13c970cc7 100644 --- a/third_party/gtest/CMakeLists.txt +++ b/third_party/gtest/CMakeLists.txt @@ -2,13 +2,13 @@ if(MSVC) # Force using shared runtime library when MSVC builds shared libraries ginkgo_load_git_package(gtest_external "https://github.com/google/googletest.git" - "ee3aa831172090fd5442820f215cb04ab6062756" + "6a7ed316a5cdc07b6d26362c90770787513822d4" # Work around the linking errors when compiling gtest with CUDA "-Dgtest_disable_pthreads=ON" "-Dgtest_force_shared_crt=${BUILD_SHARED_LIBS}") else() ginkgo_load_git_package(gtest_external "https://github.com/google/googletest.git" - "ee3aa831172090fd5442820f215cb04ab6062756" + "6a7ed316a5cdc07b6d26362c90770787513822d4" # Work around the linking errors when compiling gtest with CUDA "-Dgtest_disable_pthreads=ON" "-DCMAKE_CXX_FLAGS=-fPIC")