From c4bba2456b580de6587f96e3f2469ccc9ebae9ae Mon Sep 17 00:00:00 2001 From: Satyanvesh Dittakavi Date: Wed, 18 Aug 2021 17:48:12 +0000 Subject: [PATCH] SWDEV-298985 - hipMemPrefetchAsync should prefetch the data to the specified destination device Pass the device agent specified by the user to the ROCr api instead of passing the device agent attached to the specified stream Change-Id: I86c98935b9dc404eaa6d47ccdd082a8c3678fb36 [ROCm/clr commit: 169cc857fd5bbeae46851b1aadeab20b180e2a23] --- projects/clr/rocclr/device/rocm/rocvirtual.cpp | 2 +- projects/clr/rocclr/platform/command.hpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/clr/rocclr/device/rocm/rocvirtual.cpp b/projects/clr/rocclr/device/rocm/rocvirtual.cpp index 5898bc7d0b..95d92d0b8e 100644 --- a/projects/clr/rocclr/device/rocm/rocvirtual.cpp +++ b/projects/clr/rocclr/device/rocm/rocvirtual.cpp @@ -1578,7 +1578,7 @@ void VirtualGPU::submitSvmPrefetchAsync(amd::SvmPrefetchAsyncCommand& cmd) { // Find the requested agent for the transfer hsa_agent_t agent = (cmd.cpu_access() || (dev().settings().hmmFlags_ & Settings::Hmm::EnableSystemMemory)) ? - dev().getCpuAgent() : gpu_device(); + dev().getCpuAgent() : (static_cast(cmd.device()))->getBackendDevice(); // Initiate a prefetch command hsa_status_t status = hsa_amd_svm_prefetch_async( diff --git a/projects/clr/rocclr/platform/command.hpp b/projects/clr/rocclr/platform/command.hpp index 47bc74ac92..780a8309ce 100644 --- a/projects/clr/rocclr/platform/command.hpp +++ b/projects/clr/rocclr/platform/command.hpp @@ -1509,17 +1509,19 @@ class CopyMemoryP2PCommand : public CopyMemoryCommand { /*! \brief Prefetch command for SVM memory * - * \details Prefetches SVM memory into the current device or CPU + * \details Prefetches SVM memory into the destination device or CPU */ class SvmPrefetchAsyncCommand : public Command { const void* dev_ptr_; //!< Device pointer to memory for prefetch size_t count_; //!< the size for prefetch - bool cpu_access_; //!< Prefetch data into CPU location + bool cpu_access_; //!< Prefetch data into CPU location + amd::Device* dev_; //!< Destination device to prefetch to public: SvmPrefetchAsyncCommand(HostQueue& queue, const EventWaitList& eventWaitList, - const void* dev_ptr, size_t count, bool cpu_access) - : Command(queue, 1, eventWaitList), dev_ptr_(dev_ptr), count_(count), cpu_access_(cpu_access) {} + const void* dev_ptr, size_t count, amd::Device* dev, bool cpu_access) + : Command(queue, 1, eventWaitList), dev_ptr_(dev_ptr), count_(count), + dev_(dev), cpu_access_(cpu_access) {} virtual void submit(device::VirtualDevice& device) { device.submitSvmPrefetchAsync(*this); } @@ -1527,6 +1529,7 @@ class SvmPrefetchAsyncCommand : public Command { const void* dev_ptr() const { return dev_ptr_; } size_t count() const { return count_; } + amd::Device* device() const { return dev_; } size_t cpu_access() const { return cpu_access_; } };