rocr: Add AQL queue support under Windows (#1211)
Add 2 extra caps into the thunk interface to indicate the queue object creation and PM4 emulation
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7cc026bf98
Коммит
7ca2497378
@@ -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 <libdrm/amdgpu.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;
|
||||
|
||||
+3
-14
@@ -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<void*>(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<void*>(mem), size, alternate_va, *mem_flags,
|
||||
num_nodes, const_cast<uint32_t*>(nodes)));
|
||||
|
||||
if (status != HSAKMT_STATUS_SUCCESS) {
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
#endif
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<core::SharedQueue*>(
|
||||
finegrain_allocator()(sizeof(core::SharedQueue), core::MemoryRegion::AllocateUncached));
|
||||
shared_queue = static_cast<core::SharedQueue*>(finegrain_allocator()(
|
||||
sizeof(core::SharedQueue),
|
||||
core::MemoryRegion::AllocateUncached | MemoryRegion::AllocateQueueObject));
|
||||
} else {
|
||||
shared_queue =
|
||||
static_cast<core::SharedQueue*>(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()));
|
||||
}
|
||||
|
||||
|
||||
@@ -289,9 +289,14 @@ void SurfaceGpuList(std::vector<int32_t>& 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();
|
||||
|
||||
@@ -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<uint64_t*>(_alloca(unique_evts * sizeof(unique_evts)));
|
||||
auto event_age = reinterpret_cast<uint64_t*>(_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)
|
||||
|
||||
Ссылка в новой задаче
Block a user