SWDEV-232428 - PAL Hostcall support
Since the majority of the Hostcall implementation now sits in the commmon layer, the PAL backend simply just needs to invoke it. One thing that is missing though is HSA signal support. The newly added pal::Signal class is a light emulaion of what HSA signals provide. The current implementation is just enough to get Hostcall working, but it can be expanded in the future if needed to fully emulate HSA signals. The major difference for now between PAL and ROCm hostcall implemenations is that PAL doesn't support blocking signals. This will be enabled in the near future. For now use active wait for PAL. Change-Id: I746557354ab9d71a7d4a31f9320fcc2fee5aee7f
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "device/pal/palblit.hpp"
|
||||
#include "device/pal/paldebugger.hpp"
|
||||
#include "device/appprofile.hpp"
|
||||
#include "device/devhostcall.hpp"
|
||||
#include "hsa.h"
|
||||
#include "amd_hsa_kernel_code.h"
|
||||
#include "amd_hsa_queue.h"
|
||||
@@ -1032,6 +1033,9 @@ bool VirtualGPU::create(bool profiling, uint deviceQueueSize, uint rtCUs,
|
||||
&dbg_vmid);
|
||||
}
|
||||
|
||||
// The hostcall buffer for this vqueue is initialized on demand.
|
||||
hostcallBuffer_ = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1142,6 +1146,14 @@ VirtualGPU::~VirtualGPU() {
|
||||
it->execution().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
if (hostcallBuffer_ != nullptr) {
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_QUEUE,
|
||||
"deleting hostcall buffer %p for virtual queue %p",
|
||||
hostcallBuffer_, this);
|
||||
disableHostcalls(hostcallBuffer_);
|
||||
dev().context().svmFree(hostcallBuffer_);
|
||||
}
|
||||
}
|
||||
|
||||
void VirtualGPU::submitReadMemory(amd::ReadMemoryCommand& vcmd) {
|
||||
@@ -3781,4 +3793,41 @@ void VirtualGPU::submitTransferBufferFromFile(amd::TransferBufferFileCommand& cm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void* VirtualGPU::getOrCreateHostcallBuffer() {
|
||||
if (hostcallBuffer_ != nullptr) {
|
||||
return hostcallBuffer_;
|
||||
}
|
||||
|
||||
// The number of packets required in each buffer is at least equal to the
|
||||
// maximum number of waves supported by the device.
|
||||
auto wavesPerCu = dev().info().maxThreadsPerCU_ / dev().info().wavefrontWidth_;
|
||||
auto numPackets = dev().info().maxComputeUnits_ * wavesPerCu;
|
||||
|
||||
auto size = getHostcallBufferSize(numPackets);
|
||||
auto align = getHostcallBufferAlignment();
|
||||
|
||||
hostcallBuffer_ = dev().context().svmAlloc(size, align, CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS);
|
||||
if (!hostcallBuffer_) {
|
||||
ClPrint(amd::LOG_ERROR, amd::LOG_QUEUE,
|
||||
"Failed to create hostcall buffer");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_QUEUE,
|
||||
"Created hostcall buffer %p (numPackets == %d, size == %d, align == %d) for virtual queue %p\n",
|
||||
hostcallBuffer_,
|
||||
numPackets,
|
||||
size,
|
||||
align,
|
||||
this);
|
||||
|
||||
if (!enableHostcalls(dev(), hostcallBuffer_, numPackets)) {
|
||||
ClPrint(amd::LOG_ERROR, amd::LOG_QUEUE,
|
||||
"Failed to register hostcall buffer %p with listener",
|
||||
hostcallBuffer_);
|
||||
return nullptr;
|
||||
}
|
||||
return hostcallBuffer_;
|
||||
}
|
||||
} // namespace pal
|
||||
|
||||
Reference in New Issue
Block a user