diff --git a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp index b81f4db604..4a9060d58d 100644 --- a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp +++ b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp @@ -1897,7 +1897,7 @@ VirtualGPU::submitKernelInternal( // Get the HSA kernel object const HSAILKernel& hsaKernel = static_cast(*(kernel.getDeviceKernel(dev()))); - dispMemList_.resize(0); + std::vector dispMemList; //!< Memory list of all mem objects used in the disaptch bool printfEnabled = (hsaKernel.printfInfo().size() > 0) ? true:false; if (!printfDbgHSA().init(*this, printfEnabled )) { @@ -1906,7 +1906,7 @@ VirtualGPU::submitKernelInternal( } // Check memory dependency and SVM objects - if (!processMemObjectsHSA(kernel, parameters, nativeMem)) { + if (!processMemObjectsHSA(kernel, parameters, nativeMem, &dispMemList)) { LogError("Wrong memory objects!"); return false; } @@ -1932,9 +1932,9 @@ VirtualGPU::submitKernelInternal( vmDefQueue = gpuDefQueue->virtualQueue_->vmAddress(); // Add memory handles before the actual dispatch - dispMemList_.push_back(gpuDefQueue->virtualQueue_); - dispMemList_.push_back(gpuDefQueue->schedParams_); - dispMemList_.push_back(hsaKernel.prog().kernelTable()); + dispMemList.push_back(gpuDefQueue->virtualQueue_); + dispMemList.push_back(gpuDefQueue->schedParams_); + dispMemList.push_back(hsaKernel.prog().kernelTable()); gpuDefQueue->writeVQueueHeader(*this, hsaKernel.prog().kernelTable()->vmAddress()); } @@ -1990,7 +1990,7 @@ VirtualGPU::submitKernelInternal( // Program the kernel arguments for the GPU execution hsa_kernel_dispatch_packet_t* aqlPkt = hsaKernel.loadArguments(*this, kernel, tmpSizes, parameters, nativeMem, - vmDefQueue, &vmParentWrap, dispMemList_); + vmDefQueue, &vmParentWrap, dispMemList); if (nullptr == aqlPkt) { LogError("Couldn't load kernel arguments"); return false; @@ -2000,12 +2000,12 @@ VirtualGPU::submitKernelInternal( // Check if the device allocated more registers than the old setup if (hsaKernel.workGroupInfo()->scratchRegs_ > 0) { scratch = dev().scratch(hwRing()); - dispMemList_.push_back(scratch->memObj_); + dispMemList.push_back(scratch->memObj_); } // Add GSL handle to the memory list for VidMM - for (uint i = 0; i < dispMemList_.size(); ++i) { - addVmMemory(dispMemList_[i]); + for (uint i = 0; i < dispMemList.size(); ++i) { + addVmMemory(dispMemList[i]); } // HW Debug for the kernel? @@ -2170,7 +2170,7 @@ VirtualGPU::submitKernelInternal( param->scratch = scratchBuf->vmAddress(); param->numMaxWaves = 32 * dev().info().maxComputeUnits_; param->scratchOffset = dev().scratch(gpuDefQueue->hwRing())->offset_; - dispMemList_.push_back(scratchBuf); + dispMemList.push_back(scratchBuf); } else { param->numMaxWaves = 0; @@ -2181,11 +2181,11 @@ VirtualGPU::submitKernelInternal( // Add all kernels in the program to the mem list. //! \note Runtime doesn't know which one will be called - hsaKernel.prog().fillResListWithKernels(dispMemList_); + hsaKernel.prog().fillResListWithKernels(dispMemList); // Add GPU memory handle to the memory list for VidMM - for (uint i = 0; i < dispMemList_.size(); ++i) { - gpuDefQueue->addVmMemory(dispMemList_[i]); + for (uint i = 0; i < dispMemList.size(); ++i) { + gpuDefQueue->addVmMemory(dispMemList[i]); } Pal::gpusize signalAddr = gpuDefQueue->schedParams_->vmAddress() + @@ -2200,8 +2200,8 @@ VirtualGPU::submitKernelInternal( gpuDefQueue->eventEnd(MainEngine, gpuEvent, ForceSubmitFirst); // Set GPU event for the used resources - for (uint i = 0; i < dispMemList_.size(); ++i) { - dispMemList_[i]->setBusy(*gpuDefQueue, gpuEvent); + for (uint i = 0; i < dispMemList.size(); ++i) { + dispMemList[i]->setBusy(*gpuDefQueue, gpuEvent); } if (dev().settings().useDeviceQueue_) { @@ -2223,8 +2223,8 @@ VirtualGPU::submitKernelInternal( } // Set GPU event for the used resources - for (uint i = 0; i < dispMemList_.size(); ++i) { - dispMemList_[i]->setBusy(*this, gpuEvent); + for (uint i = 0; i < dispMemList.size(); ++i) { + dispMemList[i]->setBusy(*this, gpuEvent); } // Update the global GPU event @@ -3081,7 +3081,8 @@ bool VirtualGPU::processMemObjectsHSA( const amd::Kernel& kernel, const_address params, - bool nativeMem) + bool nativeMem, + std::vector* memList) { static const bool NoAlias = true; const HSAILKernel& hsaKernel = static_cast @@ -3143,7 +3144,7 @@ VirtualGPU::processMemObjectsHSA( // Validate SVM passed in the non argument list memoryDependency().validate(*this, gpuMemory, IsReadOnly); - dispMemList_.push_back(gpuMemory); + memList->push_back(gpuMemory); } else { return false; @@ -3207,6 +3208,9 @@ VirtualGPU::processMemObjectsHSA( memoryDependency().validate(*this, mem, IsReadOnly); } + // Mark the tracker with the processed kernel + memoryDependency().newKernel(); + return true; } diff --git a/projects/clr/rocclr/runtime/device/pal/palvirtual.hpp b/projects/clr/rocclr/runtime/device/pal/palvirtual.hpp index 2db08ea683..1931a271fa 100644 --- a/projects/clr/rocclr/runtime/device/pal/palvirtual.hpp +++ b/projects/clr/rocclr/runtime/device/pal/palvirtual.hpp @@ -526,7 +526,8 @@ private: bool processMemObjectsHSA( const amd::Kernel& kernel, //!< AMD kernel object for execution const_address params, //!< Pointer to the param's store - bool nativeMem //!< Native memory objects + bool nativeMem, //!< Native memory objects + std::vector* memList //!< Memory list for KMD tracking ); //! Common function for fill memory used by both svm Fill and non-svm fill @@ -600,7 +601,6 @@ private: Pal::ICmdAllocator* cmdAllocator_; //!< Command buffer allocator Queue* queues_[AllEngines]; //!< HW queues for all engines MemoryRange sdmaRange_; //!< SDMA memory range for write access - std::vector dispMemList_; //!< Memory list of all mem objects used in the disaptch }; /*@}*/} // namespace pal