From f847396cc07640c53973ba877a996db3e88606da Mon Sep 17 00:00:00 2001 From: Terry Cojean Date: Mon, 26 Oct 2020 10:10:51 +0100 Subject: [PATCH] Review updates. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + Fix some documentation issues. + Fix some spacing issues. + Do not duplicate `GKO_DECLARE_EXECUTOR_FRIEND` macro. Co-authored-by: Pratik Nayak Co-authored-by: Thomas Grützmacher --- CMakeLists.txt | 3 ++- core/device_hooks/dpcpp_hooks.cpp | 3 +++ core/test/base/executor.cpp | 11 +++++++++++ doc/examples/examples.hpp.in | 2 +- include/ginkgo/core/base/executor.hpp | 11 +++-------- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f01c5881f80..8f1af54f0d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,8 @@ option(GINKGO_BUILD_EXAMPLES "Build Ginkgo's examples" ON) option(GINKGO_BUILD_BENCHMARKS "Build Ginkgo's benchmarks" ON) option(GINKGO_BUILD_REFERENCE "Compile reference CPU kernels" ON) option(GINKGO_BUILD_OMP "Compile OpenMP kernels for CPU" ${GINKGO_HAS_OMP}) -option(GINKGO_BUILD_DPCPP "Compile DPC++ kernels for CPU" ${GINKGO_HAS_DPCPP}) +option(GINKGO_BUILD_DPCPP "Compile DPC++ kernels for Intel GPUs or other DPC++" + "enabled hardware" ${GINKGO_HAS_DPCPP}) option(GINKGO_BUILD_CUDA "Compile kernels for NVIDIA GPUs" ${GINKGO_HAS_CUDA}) option(GINKGO_BUILD_HIP "Compile kernels for AMD or NVIDIA GPUs" ${GINKGO_HAS_HIP}) option(GINKGO_BUILD_DOC "Generate documentation" OFF) diff --git a/core/device_hooks/dpcpp_hooks.cpp b/core/device_hooks/dpcpp_hooks.cpp index 56d61760fed..cce8fdec27e 100644 --- a/core/device_hooks/dpcpp_hooks.cpp +++ b/core/device_hooks/dpcpp_hooks.cpp @@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace gko { + version version_info::get_dpcpp_version() noexcept { // We just return the version with a special "not compiled" tag in @@ -85,10 +86,12 @@ void DpcppExecutor::raw_copy_to(const CudaExecutor *, size_type num_bytes, const void *src_ptr, void *dest_ptr) const GKO_NOT_COMPILED(dpcpp); + void DpcppExecutor::raw_copy_to(const HipExecutor *, size_type num_bytes, const void *src_ptr, void *dest_ptr) const GKO_NOT_COMPILED(dpcpp); + void DpcppExecutor::raw_copy_to(const DpcppExecutor *, size_type num_bytes, const void *src_ptr, void *dest_ptr) const GKO_NOT_COMPILED(dpcpp); diff --git a/core/test/base/executor.cpp b/core/test/base/executor.cpp index f43e375cf19..b968bbe210a 100644 --- a/core/test/base/executor.cpp +++ b/core/test/base/executor.cpp @@ -82,6 +82,7 @@ TEST(OmpExecutor, RunsCorrectOperation) exec_ptr omp = gko::OmpExecutor::create(); omp->run(ExampleOperation(value)); + ASSERT_EQ(1, value); } @@ -96,6 +97,7 @@ TEST(OmpExecutor, RunsCorrectLambdaOperation) exec_ptr omp = gko::OmpExecutor::create(); omp->run(omp_lambda, cuda_lambda, hip_lambda, dpcpp_lambda); + ASSERT_EQ(1, value); } @@ -160,6 +162,7 @@ TEST(ReferenceExecutor, RunsCorrectOperation) exec_ptr ref = gko::ReferenceExecutor::create(); ref->run(ExampleOperation(value)); + ASSERT_EQ(5, value); } @@ -174,6 +177,7 @@ TEST(ReferenceExecutor, RunsCorrectLambdaOperation) exec_ptr ref = gko::ReferenceExecutor::create(); ref->run(omp_lambda, cuda_lambda, hip_lambda, dpcpp_lambda); + ASSERT_EQ(1, value); } @@ -285,6 +289,7 @@ TEST(CudaExecutor, RunsCorrectOperation) gko::CudaExecutor::create(0, gko::OmpExecutor::create(), true); cuda->run(ExampleOperation(value)); + ASSERT_EQ(2, value); } @@ -300,6 +305,7 @@ TEST(CudaExecutor, RunsCorrectLambdaOperation) gko::CudaExecutor::create(0, gko::OmpExecutor::create(), true); cuda->run(omp_lambda, cuda_lambda, hip_lambda, dpcpp_lambda); + ASSERT_EQ(2, value); } @@ -357,6 +363,7 @@ TEST(HipExecutor, RunsCorrectOperation) exec_ptr hip = gko::HipExecutor::create(0, gko::OmpExecutor::create()); hip->run(ExampleOperation(value)); + ASSERT_EQ(3, value); } @@ -371,6 +378,7 @@ TEST(HipExecutor, RunsCorrectLambdaOperation) exec_ptr hip = gko::HipExecutor::create(0, gko::OmpExecutor::create()); hip->run(omp_lambda, cuda_lambda, hip_lambda, dpcpp_lambda); + ASSERT_EQ(3, value); } @@ -428,6 +436,7 @@ TEST(DpcppExecutor, RunsCorrectOperation) exec_ptr dpcpp = gko::DpcppExecutor::create(0, gko::OmpExecutor::create()); dpcpp->run(ExampleOperation(value)); + ASSERT_EQ(4, value); } @@ -442,6 +451,7 @@ TEST(DpcppExecutor, RunsCorrectLambdaOperation) exec_ptr dpcpp = gko::DpcppExecutor::create(0, gko::OmpExecutor::create()); dpcpp->run(omp_lambda, cuda_lambda, hip_lambda, dpcpp_lambda); + ASSERT_EQ(4, value); } @@ -498,6 +508,7 @@ TEST(ExecutorDeleter, DeletesObject) TEST(ExecutorDeleter, AvoidsDeletionForNullExecutor) { int x[5]; + ASSERT_NO_THROW(gko::executor_deleter{nullptr}(x)); } diff --git a/doc/examples/examples.hpp.in b/doc/examples/examples.hpp.in index ce5b5add69a..5290b4ecaf6 100644 --- a/doc/examples/examples.hpp.in +++ b/doc/examples/examples.hpp.in @@ -64,7 +64,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
    *
  1. -DGINKGO_BUILD_CUDA=ON option for NVIDIA GPUs. *
  2. -DGINKGO_BUILD_HIP=ON option for AMD or NVIDIA GPUs. - *
  3. -DGINKGO_BUILD_SYCL=ON option for Intel GPUs (and + *
  4. -DGINKGO_BUILD_DPCPP=ON option for Intel GPUs (and * possibly any other platform). *
{ template friend class detail::ExecutorBase; -#define GKO_DECLARE_EXECUTOR_FRIEND(_type, ...) friend class _type - GKO_ENABLE_FOR_ALL_EXECUTORS(GKO_DECLARE_EXECUTOR_FRIEND); -#undef GKO_DECLARE_EXECUTOR_FRIEND - public: virtual ~Executor() = default; @@ -817,12 +815,8 @@ namespace detail { template class ExecutorBase : public Executor { -#define GKO_DECLARE_EXECUTOR_FRIEND(_type, ...) friend class _type - GKO_ENABLE_FOR_ALL_EXECUTORS(GKO_DECLARE_EXECUTOR_FRIEND); -#undef GKO_DECLARE_EXECUTOR_FRIEND - public: void run(const Operation &op) const override { @@ -850,6 +844,7 @@ class ExecutorBase : public Executor { } }; +#undef GKO_DECLARE_EXECUTOR_FRIEND /** * Controls whether the DeviceReset function should be called thanks to a