Optimize and fix SDMA gang copies

Optimizations include:
- Greedy gang by placing gang leaders on first D2D sdma blit context
to avoid dead locking with other gang leaders and items.  Note that
this is fine since we can't avoid an oversubscription problem when
there is only 1 xGMI link anyways, so treat all xGMI links as a single
pipe for ganging.
- Non-leader gang items don't have to poll on dependency signals so this
opens up more non-blocking SDMA channels.
- unlock gang lock when gangs are not needed.
- Change gang factor lookup from vector pair to map and register all
gpus in gang factor lookup regardless of link type so that we can take
advantage of the O(logN) direct key/value lookup time.

Fixes include:
- HSA_PAGE_SIZE_4KB was an incorrect macro to use for gang size limit.
As a result, small copies ended up ganging and hitting latency limit.
Use hardcoded 4096 bytes instead.
- Cap auxillary gang factor to the number of non-XGMI SDMA engines.

Change-Id: Ic23fde131502906a807134a04599aa6d012e8cbb
This commit is contained in:
Jonathan Kim
2024-01-24 11:35:00 -05:00
parent caedadcc6f
commit 62f3f250ce
4 changed files with 43 additions and 80 deletions
+3 -3
View File
@@ -600,7 +600,7 @@ class GpuAgent : public GpuAgentInt {
void ReleaseScratch(void* base, size_t size, bool large);
// Bind index of peer device that is connected via xGMI links
lazy_ptr<core::Blit>& GetXgmiBlit(const core::Agent& peer_agent, int gang_id);
lazy_ptr<core::Blit>& GetXgmiBlit(const core::Agent& peer_agent);
// Bind the Blit object that will drive the copy operation
// across PCIe links (H2D or D2H) or is within same device D2D
@@ -608,7 +608,7 @@ class GpuAgent : public GpuAgentInt {
// 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,
const size_t size, int gang_id);
const size_t size);
// Bind the Blit object that will drive the copy operation by engine ID
lazy_ptr<core::Blit>& GetBlitObject(uint32_t engine_id);
@@ -662,7 +662,7 @@ class GpuAgent : public GpuAgentInt {
// Check if SDMA engine by ID is free
bool DmaEngineIsFree(uint32_t engine_id);
std::vector<std::pair<core::Agent&,unsigned int>> gang_peers_info_;
std::map<uint64_t,unsigned int> gang_peers_info_;
};
} // namespace amd