Use SDMA for small copies in VRAM.

For small copies cache flush latency is larger than data transfer
latency in local VRAM.  Select SDMA for small copies.

Environment key HSA_FORCE_SDMA_SIZE is added for easy adjustment
of the small copy size.  This may be removed after tuning is done.

Change-Id: I733fa0ae01c616617c5de50e71226b51fd589ef2


[ROCm/ROCR-Runtime commit: 2a0c6774fb]
Этот коммит содержится в:
Sean Keely
2020-09-03 03:06:03 -05:00
родитель 700dca7dd4
Коммит fe47915a8e
3 изменённых файлов: 16 добавлений и 3 удалений
+2 -1
Просмотреть файл
@@ -502,7 +502,8 @@ class GpuAgent : public GpuAgentInt {
lazy_ptr<core::Blit>& GetPcieBlit(const core::Agent& dst_agent, const core::Agent& src_agent);
// Bind the Blit object that will drive the copy operation
lazy_ptr<core::Blit>& GetBlitObject(const core::Agent& dst_agent, const core::Agent& src_agent);
lazy_ptr<core::Blit>& GetBlitObject(const core::Agent& dst_agent, const core::Agent& src_agent,
const size_t size);
// @brief Alternative aperture base address. Only on KV.
uintptr_t ape1_base_;
+7 -2
Просмотреть файл
@@ -645,7 +645,7 @@ hsa_status_t GpuAgent::DmaCopy(void* dst, core::Agent& dst_agent,
std::vector<core::Signal*>& dep_signals,
core::Signal& out_signal) {
// Bind the Blit object that will drive this copy operation
lazy_ptr<core::Blit>& blit = GetBlitObject(dst_agent, src_agent);
lazy_ptr<core::Blit>& blit = GetBlitObject(dst_agent, src_agent, size);
if (profiling_enabled()) {
// Track the agent so we could translate the resulting timestamp to system
@@ -1354,7 +1354,7 @@ lazy_ptr<core::Blit>& GpuAgent::GetPcieBlit(const core::Agent& dst_agent,
}
lazy_ptr<core::Blit>& GpuAgent::GetBlitObject(const core::Agent& dst_agent,
const core::Agent& src_agent) {
const core::Agent& src_agent, const size_t size) {
// At this point it is guaranteed that one of
// the two devices is a GPU, potentially both
assert(((src_agent.device_type() == core::Agent::kAmdGpuDevice) ||
@@ -1363,6 +1363,11 @@ lazy_ptr<core::Blit>& GpuAgent::GetBlitObject(const core::Agent& dst_agent,
// Determine if Src and Dst devices are same
if ((src_agent.public_handle().handle) == (dst_agent.public_handle().handle)) {
// If the copy is very small then cache flush overheads can dominate.
// Choose a (potentially) SDMA enabled engine to avoid cache flushing.
if (size < core::Runtime::runtime_singleton_->flag().force_sdma_size()) {
return blits_[BlitDevToHost];
}
return blits_[BlitDevToDev];
}
+7
Просмотреть файл
@@ -121,6 +121,9 @@ class Flag {
var = os::GetEnvVar("HSA_LOADER_ENABLE_MMAP_URI");
loader_enable_mmap_uri_ = (var == "1") ? true : false;
var = os::GetEnvVar("HSA_FORCE_SDMA_SIZE");
force_sdma_size_ = var.empty() ? 1024 * 1024 : atoi(var.c_str());
}
bool check_flat_scratch() const { return check_flat_scratch_; }
@@ -165,6 +168,8 @@ class Flag {
bool loader_enable_mmap_uri() const { return loader_enable_mmap_uri_; }
size_t force_sdma_size() const { return force_sdma_size_; }
private:
bool check_flat_scratch_;
bool enable_vm_fault_message_;
@@ -193,6 +198,8 @@ class Flag {
std::string tools_lib_names_;
size_t force_sdma_size_;
DISALLOW_COPY_AND_ASSIGN(Flag);
};