Skip to content

Commit

Permalink
Enable custom heaps based on query
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffbloo committed Aug 23, 2023
1 parent d3345f3 commit 7520974
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ namespace DmlGraphFusionHelper
{
ComPtr<ID3D12Resource> initializeInputBuffer;

// D3D_FEATURE_LEVEL_1_0_CORE doesn't support Custom heaps
if (providerImpl->IsMcdmDevice())
if (!providerImpl->CustomHeapsSupported())
{
initializeInputBuffer = CreateResource(providerImpl, tensorPtr, tensorByteSize);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,31 @@ namespace Dml
}

m_isMcdmDevice = (featureLevels.MaxSupportedFeatureLevel == D3D_FEATURE_LEVEL_1_0_CORE_PRIVATE);
m_areCustomHeapsSupported = !m_isMcdmDevice;

if (m_isMcdmDevice) {

// TODO: Ingest updated header file
typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS19
{
BOOL MismatchingOutputDimensionsSupported;
UINT SupportedSampleCountsWithNoOutputs;
BOOL PointSamplingAddressesNeverRoundUp;
BOOL RasterizerDesc2Supported;
BOOL NarrowQuadrilateralLinesSupported;
BOOL AnisoFilterWithPointMipSupported;
UINT MaxSamplerDescriptorHeapSize;
UINT MaxSamplerDescriptorHeapSizeWithStaticSamplers;
UINT MaxViewDescriptorHeapSize;
_Out_ BOOL ComputeOnlyCustomHeapSupported;
} D3D12_FEATURE_DATA_D3D12_OPTIONS19;

D3D12_FEATURE_DATA_D3D12_OPTIONS19 options19 = {};

// The call may fail in which case the default value is false
d3d12Device->CheckFeatureSupport((D3D12_FEATURE) 48 /*D3D12_FEATURE_D3D12_OPTIONS19*/, &options19, sizeof(options19));
m_areCustomHeapsSupported = options19.ComputeOnlyCustomHeapSupported;
}

m_context = std::make_shared<ExecutionContext>(m_d3d12Device.Get(), m_dmlDevice.Get(), queue);

Expand Down Expand Up @@ -1088,6 +1113,11 @@ namespace Dml
return m_isMcdmDevice;
}

bool __stdcall ExecutionProviderImpl::CustomHeapsSupported() const noexcept
{
return m_areCustomHeapsSupported;
}

bool __stdcall ExecutionProviderImpl::MetacommandsEnabled() const noexcept
{
return m_areMetacommandsEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ namespace Dml
}

STDMETHOD_(bool, IsMcdmDevice)() const noexcept final;
STDMETHOD_(bool, CustomHeapsSupported)() const noexcept final;

STDMETHOD_(bool, MetacommandsEnabled)() const noexcept final;
std::shared_ptr<onnxruntime::IAllocator> GetGpuAllocator();
Expand Down Expand Up @@ -183,6 +184,7 @@ namespace Dml
ComPtr<ID3D12Device> m_d3d12Device;
ComPtr<IDMLDevice> m_dmlDevice;
bool m_isMcdmDevice = false;
bool m_areCustomHeapsSupported = false;
bool m_areMetacommandsEnabled = true;
bool m_native16BitShaderOpsSupported = false;
std::shared_ptr<ExecutionContext> m_context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ namespace Dml
STDMETHOD(AllocatePooledResource(size_t size, AllocatorRoundingMode roundingMode, ID3D12Resource **d3dResource, IUnknown* *pooledResource)) const noexcept = 0;

STDMETHOD_(bool, IsMcdmDevice)() const noexcept = 0;
STDMETHOD_(bool, CustomHeapsSupported)() const noexcept = 0;
STDMETHOD_(bool, MetacommandsEnabled)() const noexcept = 0;
};
} // namespace Dml

0 comments on commit 7520974

Please sign in to comment.