Skip to content

Commit ac6fe48

Browse files
chrilaMSFTfdwr
andauthored
Adjust max chunk size to fix error limit check from DX12 for large resources that are CPU accessible. (microsoft#22680)
Adjust max chunk size to fix error limit check from DX12 for large resources that are CPU accessible. ### Description Current agility SDK restricts CPU visible buffers to 0xFFFF0000 bytes or slightly smaller than 4GiB. Verified restriction is still in latest Agility SDK 1.614.1. ### Motivation and Context Allocation of Resources 4GiB or larger fail in DX12 verification layer. --------- Co-authored-by: Dwayne Robinson <[email protected]>
1 parent 120cb5a commit ac6fe48

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

onnxruntime/core/providers/dml/DmlExecutionProvider/src/PooledUploadHeap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ namespace Dml
125125

126126
// No chunks were able to accommodate the allocation - create a new chunk and return that instead
127127

128-
// At least double the capacity of the pool
129-
const size_t newChunkSize = std::max({ m_totalCapacity, c_minChunkSize, sizeInBytes });
128+
// At least double the capacity of the pool, limit to c_maxChunkSize so DX12 does not reject size
129+
const size_t newChunkSize = std::min(std::max({ m_totalCapacity, c_minChunkSize, sizeInBytes }), c_maxChunkSize);
130130
m_chunks.push_back(CreateChunk(m_device.Get(), newChunkSize));
131131
m_totalCapacity += newChunkSize;
132132

onnxruntime/core/providers/dml/DmlExecutionProvider/src/PooledUploadHeap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace Dml
3232
private:
3333
static constexpr size_t c_minChunkSize = 1024 * 1024; // 1MB
3434
static constexpr size_t c_allocationAlignment = 512; // In bytes; as per D3D12 requirement for buffers
35+
static constexpr size_t c_maxChunkSize = 0xFFFF0000; // ~4 GiB limitation for DX12 CPU-visible resource
3536

3637
// A suballoction from a chunk
3738
struct Allocation

0 commit comments

Comments
 (0)