//@HEADER // ************************************************************************ // // Kokkos v. 4.0 // Copyright (2022) National Technology & Engineering // Solutions of Sandia, LLC (NTESS). // // Under the terms of Contract DE-NA0003525 with NTESS, // the U.S. Government retains certain rights in this software. // // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. // See https://kokkos.org/LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //@HEADER #ifndef KOKKOS_HIP_DEEP_COPY_HPP #define KOKKOS_HIP_DEEP_COPY_HPP #include #include // HIP_SAFE_CALL #include namespace Kokkos { namespace Impl { void DeepCopyHIP(void* dst, const void* src, size_t n); void DeepCopyAsyncHIP(const HIP& instance, void* dst, const void* src, size_t n); void DeepCopyAsyncHIP(void* dst, const void* src, size_t n); template struct DeepCopy::value>> { DeepCopy(void* dst, const void* src, size_t n) { DeepCopyHIP(dst, src, n); } DeepCopy(const HIP& instance, void* dst, const void* src, size_t n) { DeepCopyAsyncHIP(instance, dst, src, n); } }; template struct DeepCopy::value>> { DeepCopy(void* dst, const void* src, size_t n) { DeepCopyHIP(dst, src, n); } DeepCopy(const HIP& instance, void* dst, const void* src, size_t n) { DeepCopyAsyncHIP(instance, dst, src, n); } }; template struct DeepCopy::value && is_hip_type_space::value>> { DeepCopy(void* dst, const void* src, size_t n) { DeepCopyHIP(dst, src, n); } DeepCopy(const HIP& instance, void* dst, const void* src, size_t n) { DeepCopyAsyncHIP(instance, dst, src, n); } }; template struct DeepCopy::value && is_hip_type_space::value && !std::is_same::value>> { inline DeepCopy(void* dst, const void* src, size_t n) { DeepCopyHIP(dst, src, n); } inline DeepCopy(const ExecutionSpace& exec, void* dst, const void* src, size_t n) { exec.fence(fence_string()); DeepCopyAsyncHIP(dst, src, n); } private: static const std::string& fence_string() { static const std::string string = std::string("Kokkos::Impl::DeepCopy<") + MemSpace1::name() + "Space, " + MemSpace2::name() + "Space, ExecutionSpace>::DeepCopy: fence before copy"; return string; } }; template struct DeepCopy::value && !std::is_same::value>> { inline DeepCopy(void* dst, const void* src, size_t n) { DeepCopyHIP(dst, src, n); } inline DeepCopy(const ExecutionSpace& exec, void* dst, const void* src, size_t n) { exec.fence(fence_string()); DeepCopyAsyncHIP(dst, src, n); } private: static const std::string& fence_string() { static const std::string string = std::string("Kokkos::Impl::DeepCopy<") + MemSpace::name() + "Space, HostSpace, ExecutionSpace>::DeepCopy: fence before copy"; return string; } }; template struct DeepCopy::value && !std::is_same::value>> { inline DeepCopy(void* dst, const void* src, size_t n) { DeepCopyHIP(dst, src, n); } inline DeepCopy(const ExecutionSpace& exec, void* dst, const void* src, size_t n) { exec.fence(fence_string()); DeepCopyAsyncHIP(dst, src, n); } private: static const std::string& fence_string() { static const std::string string = std::string("Kokkos::Impl::DeepCopy::DeepCopy: fence before copy"; return string; } }; } // namespace Impl } // namespace Kokkos #endif