From 04d38431ee3395fb5446a01389e7d2d19a27ecd8 Mon Sep 17 00:00:00 2001 From: Marcel Koch Date: Wed, 13 Dec 2023 16:39:26 +0000 Subject: [PATCH] remove hwloc tests --- core/test/base/executor.cpp | 37 ----- cuda/test/base/cuda_executor_topology.cu | 141 ------------------- hip/test/base/hip_executor_topology.hip.cpp | 147 -------------------- 3 files changed, 325 deletions(-) delete mode 100644 cuda/test/base/cuda_executor_topology.cu delete mode 100644 hip/test/base/hip_executor_topology.hip.cpp diff --git a/core/test/base/executor.cpp b/core/test/base/executor.cpp index d2b2e8297d3..c4e68fec94a 100644 --- a/core/test/base/executor.cpp +++ b/core/test/base/executor.cpp @@ -81,43 +81,6 @@ TEST(OmpExecutor, IsItsOwnMaster) } -#if GKO_HAVE_HWLOC - - -inline int get_os_id(int log_id) -{ - return gko::machine_topology::get_instance()->get_core(log_id)->os_id; -} - - -TEST(MachineTopology, CanBindToASpecificCore) -{ - auto cpu_sys = sched_getcpu(); - - const int bind_core = 3; - gko::machine_topology::get_instance()->bind_to_cores( - std::vector{bind_core}); - - cpu_sys = sched_getcpu(); - ASSERT_EQ(cpu_sys, get_os_id(bind_core)); -} - - -TEST(MachineTopology, CanBindToARangeofCores) -{ - auto cpu_sys = sched_getcpu(); - - const std::vector bind_core = {1, 3}; - gko::machine_topology::get_instance()->bind_to_cores(bind_core); - - cpu_sys = sched_getcpu(); - ASSERT_TRUE(cpu_sys == get_os_id(3) || cpu_sys == get_os_id(1)); -} - - -#endif - - TEST(ReferenceExecutor, AllocatesAndFreesMemory) { const int num_elems = 10; diff --git a/cuda/test/base/cuda_executor_topology.cu b/cuda/test/base/cuda_executor_topology.cu deleted file mode 100644 index c1597655e91..00000000000 --- a/cuda/test/base/cuda_executor_topology.cu +++ /dev/null @@ -1,141 +0,0 @@ -// SPDX-FileCopyrightText: 2017-2023 The Ginkgo authors -// -// SPDX-License-Identifier: BSD-3-Clause - -#include - - -#include -#include -#include - - -#if defined(__unix__) || defined(__APPLE__) -#include -#include -#endif - - -#include - - -#include -#include - - -#include "cuda/test/utils.hpp" - - -namespace { - - -class CudaExecutor : public ::testing::Test { -protected: - CudaExecutor() - : ref(gko::ReferenceExecutor::create()), cuda(nullptr), cuda2(nullptr) - {} - - void SetUp() - { - ASSERT_GT(gko::CudaExecutor::get_num_devices(), 0); - cuda = gko::CudaExecutor::create(0, ref); - cuda2 = gko::CudaExecutor::create( - gko::CudaExecutor::get_num_devices() - 1, ref); - } - - void TearDown() - { - if (cuda != nullptr) { - // ensure that previous calls finished and didn't throw an error - ASSERT_NO_THROW(cuda->synchronize()); - } - } - - std::shared_ptr ref; - std::shared_ptr cuda; - std::shared_ptr cuda2; -}; - - -#if GKO_HAVE_HWLOC - - -inline int get_cpu_os_id(int log_id) -{ - return gko::machine_topology::get_instance()->get_pu(log_id)->os_id; -} - - -inline int get_core_os_id(int log_id) -{ - return gko::machine_topology::get_instance()->get_core(log_id)->os_id; -} - - -TEST_F(CudaExecutor, CanBindToSinglePu) -{ - cuda = gko::CudaExecutor::create(0, gko::ReferenceExecutor::create()); - - const int bind_pu = 1; - gko::machine_topology::get_instance()->bind_to_pu(bind_pu); - - auto cpu_sys = sched_getcpu(); - ASSERT_TRUE(cpu_sys == get_cpu_os_id(1)); -} - - -TEST_F(CudaExecutor, CanBindToPus) -{ - cuda = gko::CudaExecutor::create(0, gko::ReferenceExecutor::create()); - - std::vector bind_pus = {1, 3}; - gko::machine_topology::get_instance()->bind_to_pus(bind_pus); - - auto cpu_sys = sched_getcpu(); - ASSERT_TRUE(cpu_sys == get_cpu_os_id(3) || cpu_sys == get_cpu_os_id(1)); -} - - -TEST_F(CudaExecutor, CanBindToCores) -{ - cuda = gko::CudaExecutor::create(0, gko::ReferenceExecutor::create()); - - std::vector bind_cores = {1, 3}; - gko::machine_topology::get_instance()->bind_to_cores(bind_cores); - - auto cpu_sys = sched_getcpu(); - ASSERT_TRUE(cpu_sys == get_core_os_id(3) || cpu_sys == get_core_os_id(1)); -} - - -TEST_F(CudaExecutor, ClosestCpusIsPopulated) -{ - cuda = gko::CudaExecutor::create(0, gko::ReferenceExecutor::create()); - auto close_cpus = cuda->get_closest_pus(); - if (close_cpus.size() == 0) { - GTEST_SKIP(); - } - - ASSERT_NE(close_cpus[0], -1); -} - - -TEST_F(CudaExecutor, KnowsItsNuma) -{ - cuda = gko::CudaExecutor::create(0, gko::ReferenceExecutor::create()); - auto numa0 = cuda->get_closest_numa(); - auto close_cpus = cuda->get_closest_pus(); - if (close_cpus.size() == 0) { - GTEST_SKIP(); - } - - auto numa_sys0 = numa_node_of_cpu(get_cpu_os_id(close_cpus[0])); - - ASSERT_TRUE(numa0 == numa_sys0); -} - - -#endif - - -} // namespace diff --git a/hip/test/base/hip_executor_topology.hip.cpp b/hip/test/base/hip_executor_topology.hip.cpp deleted file mode 100644 index 62a07faea8b..00000000000 --- a/hip/test/base/hip_executor_topology.hip.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// SPDX-FileCopyrightText: 2017-2023 The Ginkgo authors -// -// SPDX-License-Identifier: BSD-3-Clause - -// force-top: on -// prevent compilation failure related to disappearing assert(...) statements -#include -// force-top: off - - -#include - - -#include -#include -#include - - -#if defined(__unix__) || defined(__APPLE__) -#include -#include -#endif - - -#include - - -#include -#include - - -#include "hip/test/utils.hip.hpp" - - -namespace { - - -class HipExecutor : public ::testing::Test { -protected: - HipExecutor() - : ref(gko::ReferenceExecutor::create()), hip(nullptr), hip2(nullptr) - {} - - void SetUp() - { - ASSERT_GT(gko::HipExecutor::get_num_devices(), 0); - hip = gko::HipExecutor::create(0, ref); - hip2 = gko::HipExecutor::create(gko::HipExecutor::get_num_devices() - 1, - ref); - } - - void TearDown() - { - if (hip != nullptr) { - // ensure that previous calls finished and didn't throw an error - ASSERT_NO_THROW(hip->synchronize()); - } - } - - std::shared_ptr ref; - std::shared_ptr hip; - std::shared_ptr hip2; -}; - - -#if GKO_HAVE_HWLOC - - -inline int get_cpu_os_id(int log_id) -{ - return gko::machine_topology::get_instance()->get_pu(log_id)->os_id; -} - - -inline int get_core_os_id(int log_id) -{ - return gko::machine_topology::get_instance()->get_core(log_id)->os_id; -} - - -TEST_F(HipExecutor, CanBindToSinglePu) -{ - hip = gko::HipExecutor::create(0, gko::ReferenceExecutor::create()); - - const int bind_pu = 1; - gko::machine_topology::get_instance()->bind_to_pu(bind_pu); - - auto cpu_sys = sched_getcpu(); - ASSERT_TRUE(cpu_sys == get_cpu_os_id(1)); -} - - -TEST_F(HipExecutor, CanBindToPus) -{ - hip = gko::HipExecutor::create(0, gko::ReferenceExecutor::create()); - - std::vector bind_pus = {1, 3}; - gko::machine_topology::get_instance()->bind_to_pus(bind_pus); - - auto cpu_sys = sched_getcpu(); - ASSERT_TRUE(cpu_sys == get_cpu_os_id(3) || cpu_sys == get_cpu_os_id(1)); -} - - -TEST_F(HipExecutor, CanBindToCores) -{ - hip = gko::HipExecutor::create(0, gko::ReferenceExecutor::create()); - - std::vector bind_cores = {1, 3}; - gko::machine_topology::get_instance()->bind_to_cores(bind_cores); - - auto cpu_sys = sched_getcpu(); - ASSERT_TRUE(cpu_sys == get_core_os_id(3) || cpu_sys == get_core_os_id(1)); -} - - -TEST_F(HipExecutor, ClosestCpusIsPopulated) -{ - hip = gko::HipExecutor::create(0, gko::ReferenceExecutor::create()); - auto close_cpus = hip->get_closest_pus(); - if (close_cpus.size() == 0) { - GTEST_SKIP(); - } - - ASSERT_NE(close_cpus[0], -1); -} - - -TEST_F(HipExecutor, KnowsItsNuma) -{ - hip = gko::HipExecutor::create(0, gko::ReferenceExecutor::create()); - auto numa0 = hip->get_closest_numa(); - auto close_cpus = hip->get_closest_pus(); - if (close_cpus.size() == 0) { - GTEST_SKIP(); - } - - auto numa_sys0 = numa_node_of_cpu(get_cpu_os_id(close_cpus[0])); - - ASSERT_TRUE(numa0 == numa_sys0); -} - - -#endif - - -} // namespace