diff --git a/projects/rocr-runtime/libhsakmt/include/hsakmt/hsakmt_virtio.h b/projects/rocr-runtime/libhsakmt/include/hsakmt/hsakmt_virtio.h index 6a2aa6554e..d2110cf907 100644 --- a/projects/rocr-runtime/libhsakmt/include/hsakmt/hsakmt_virtio.h +++ b/projects/rocr-runtime/libhsakmt/include/hsakmt/hsakmt_virtio.h @@ -26,7 +26,9 @@ #ifndef HSAKMT_VIRTIO_H #define HSAKMT_VIRTIO_H +#if defined(__linux__) #include "hsakmt/linux/kfd_ioctl.h" +#endif #include "hsakmt/hsakmt.h" #include diff --git a/projects/rocr-runtime/libhsakmt/include/hsakmt/hsakmttypes.h b/projects/rocr-runtime/libhsakmt/include/hsakmt/hsakmttypes.h index 9784d36373..d621158997 100644 --- a/projects/rocr-runtime/libhsakmt/include/hsakmt/hsakmttypes.h +++ b/projects/rocr-runtime/libhsakmt/include/hsakmt/hsakmttypes.h @@ -227,8 +227,9 @@ typedef union HSAuint32 Value; struct { - unsigned int PerSDMAQueueResetSupported : 1; // Indicates per-sdma queue reset supported - unsigned int Reserved : 31; // Reserved + unsigned int PerSDMAQueueResetSupported : 1; // Indicates per-sdma queue reset supported + unsigned int AqlEmulationPm4_ : 1; // Indicates device uses AQL emulation via PM4 packets + unsigned int Reserved : 30; // Reserved } ui32; } HSA_CAPABILITY2; @@ -585,9 +586,10 @@ typedef struct _HsaMemFlags unsigned int ExtendedCoherent: 1; // system-scope coherence on atomic instructions unsigned int GTTAccess: 1; // default = 0; If 1: The caller indicates this memory will be mapped to GART for MES // KFD will allocate GTT memory with the Preferred_node set as gpu_id for GART mapping - unsigned int Contiguous: 1; // Allocate contiguous VRAM - unsigned int ExecuteBlit: 1; // default = 0; If 1: The caller indicates that the memory is for blit kernel object. - unsigned int Reserved: 8; + unsigned int Contiguous: 1; // Allocate contiguous VRAM + unsigned int ExecuteBlit: 1; // default = 0; If 1: The caller indicates that the memory is for blit kernel object. + unsigned int QueueObject: 1; // AQL queue object, used in windows for CPU access to get the read pointer from amd_queue_t + unsigned int Reserved: 7; } ui32; HSAuint32 Value; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp index 7988ef0c92..1c64c169a9 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp @@ -249,6 +249,9 @@ KfdDriver::AllocateMemory(const core::MemoryRegion &mem_region, ? 1 : kmt_alloc_flags.ui32.Uncached); + kmt_alloc_flags.ui32.QueueObject = + (alloc_flags & core::MemoryRegion::AllocateQueueObject ? 1 + : kmt_alloc_flags.ui32.QueueObject); if (kmt_alloc_flags.ui32.Uncached) { /* Uncached overwrites CoarseGrain and ExtendedCoherent */ kmt_alloc_flags.ui32.CoarseGrain = 0; @@ -672,7 +675,6 @@ hsa_status_t KfdDriver::DeregisterMemory(void* ptr) const { hsa_status_t KfdDriver::MakeMemoryResident(const void* mem, size_t size, uint64_t* alternate_va, const HsaMemMapFlags* mem_flags, uint32_t num_nodes, const uint32_t* nodes) const { -#if defined(__linux__) if (mem_flags == nullptr && nodes == nullptr) { if (HSAKMT_CALL(hsaKmtMapMemoryToGPU(const_cast(mem), size, alternate_va)) != HSAKMT_STATUS_SUCCESS) { @@ -686,19 +688,6 @@ hsa_status_t KfdDriver::MakeMemoryResident(const void* mem, size_t size, uint64_ debug_print("Invalid memory flags ptr:%p nodes ptr:%p\n", mem_flags, nodes); return HSA_STATUS_ERROR_INVALID_ARGUMENT; } -#else - assert(num_nodes > 0); - assert(nodes != NULL); - - *alternate_va = 0; - const HSAKMT_STATUS status = - HSAKMT_CALL(hsaKmtMapMemoryToGPUNodes(const_cast(mem), size, alternate_va, *mem_flags, - num_nodes, const_cast(nodes))); - - if (status != HSAKMT_STATUS_SUCCESS) { - return HSA_STATUS_ERROR; - } -#endif return HSA_STATUS_SUCCESS; } diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/memory_region.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/memory_region.h index 5da2b62fbd..413d7cdd93 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/memory_region.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/memory_region.h @@ -109,6 +109,7 @@ class MemoryRegion : public Checked<0x9C961F19EE175BB3> { // this flag is ignored by Thunk and only used for emulator/dxg to track code-object // allocations in AQL to PM4 conversion. AllocateExecutableBlitKernelObject = (1 << 12), + AllocateQueueObject = (1 << 13), // Allocates AQL queue object, KMD requires physical access for the fence update }; typedef uint32_t AllocateFlags; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index 1f2b2473b3..97dacd9cae 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -1792,13 +1792,16 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u core::SharedQueue* shared_queue = nullptr; if (dev_mem_queue_descriptor) { - shared_queue = static_cast( - finegrain_allocator()(sizeof(core::SharedQueue), core::MemoryRegion::AllocateUncached)); + shared_queue = static_cast(finegrain_allocator()( + sizeof(core::SharedQueue), + core::MemoryRegion::AllocateUncached | MemoryRegion::AllocateQueueObject)); } else { shared_queue = static_cast(core::Runtime::runtime_singleton_->system_allocator()( sizeof(core::SharedQueue), MemoryRegion::GetPageSize(), - isMES() ? (MemoryRegion::AllocateGTTAccess | MemoryRegion::AllocateNonPaged) : 0, + isMES() ? (MemoryRegion::AllocateGTTAccess | MemoryRegion::AllocateNonPaged | + MemoryRegion::AllocateQueueObject) + : MemoryRegion::AllocateQueueObject, node_id())); } diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp index 3a4e6ecf1f..d141a73793 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp @@ -289,9 +289,14 @@ void SurfaceGpuList(std::vector& gpu_list, bool xnack_mode, bool enable core::g_use_interrupt_wait = false; if (core::Runtime::runtime_singleton_->thunkLoader()->IsDXG()) { - core::g_use_interrupt_wait = false; +#if defined(_WIN32) + if (node_prop.Capability2.ui32.AqlEmulationPm4_) +#endif + { + core::g_use_interrupt_wait = false; + core::Runtime::runtime_singleton_->flag().disable_scratch(); + } core::Runtime::runtime_singleton_->flag().set_sdma(false, false); - core::Runtime::runtime_singleton_->flag().disable_scratch(); core::Runtime::runtime_singleton_->flag().disable_image(true); core::Runtime::runtime_singleton_->flag().disable_xnack(); core::Runtime::runtime_singleton_->flag().disable_fine_grain_pcie(); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/signal.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/signal.cpp index 5d6cfdc670..6cc1eaf759 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/signal.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/signal.cpp @@ -376,7 +376,7 @@ uint32_t Signal::WaitAnyExceptions(uint32_t signal_count, const hsa_signal_t* hs #if defined(__linux__) uint64_t event_age[unique_evts]; #else - auto event_age = reinterpret_cast(_alloca(unique_evts * sizeof(unique_evts))); + auto event_age = reinterpret_cast(_alloca(unique_evts * sizeof(uint64_t))); #endif memset(event_age, 0, unique_evts * sizeof(uint64_t)); if (core::Runtime::runtime_singleton_->KfdVersion().supports_event_age)