diff --git a/rocclr/runtime/device/devprogram.hpp b/rocclr/runtime/device/devprogram.hpp index a597f97379..5f292a5143 100644 --- a/rocclr/runtime/device/devprogram.hpp +++ b/rocclr/runtime/device/devprogram.hpp @@ -215,6 +215,8 @@ class Program : public amd::HeapObject { //! Global variables are a part of the code segment bool hasGlobalStores() const { return hasGlobalStores_; } + std::vector getUndefMemObj() const { return undef_mem_obj_; } + #if defined(USE_COMGR_LIBRARY) const amd_comgr_metadata_node_t* metadata() const { return metadata_; } diff --git a/rocclr/runtime/device/pal/palvirtual.cpp b/rocclr/runtime/device/pal/palvirtual.cpp index 925e238b51..da8a617cb1 100644 --- a/rocclr/runtime/device/pal/palvirtual.cpp +++ b/rocclr/runtime/device/pal/palvirtual.cpp @@ -3495,7 +3495,12 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p if (hsaKernel.prog().hasGlobalStores()) { // Validate code object for a dependency in the queue memoryDependency().validate(*this, &hsaKernel.prog().codeSegGpu(), IsReadOnly); + std::vector undefined = hsaKernel.prog().getUndefMemObj(); + for (auto it = undefined.begin(); it != undefined.end(); ++it) { + addVmMemory(dev().getGpuMemory(*it)); + } } + addVmMemory(&hsaKernel.prog().codeSegGpu()); if (hsaKernel.workGroupInfo()->scratchRegs_ > 0) {