Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functionality to choose dml adapter by luid #1041

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DavitGrigoryan132
Copy link

Description: This PR adds functionality to allow users to specify a "DML" (DirectML) execution provider device adapter by providing the adapter's LUID (Locally Unique Identifier). Previously, the system would automatically select the most performant adapter by default. With this enhancement, users can now select a specific adapter by passing the luid_high_part and luid_low_part options, giving them greater control over device selection.

Key Changes:

Added support for selecting a DML execution provider device adapter using luid_high_part and luid_low_part.
Default behavior remains the same, choosing the most performant adapter unless these options are specified.

Motivation: This update provides more flexibility for users needing to target specific adapters, enhancing customizability in environments with multiple available adapters.

@natke
Copy link
Contributor

natke commented Nov 7, 2024

Thank you for this contribution. Can you please add a test/tests for the new functionality?

@pranavsharma
Copy link
Contributor

This should be reviewed by the DML team.

Comment on lines 57 to 67
ComPtr<IDXGIAdapter1> adapter;
for (uint32_t adapter_index = 0; dxgi_factory->EnumAdapters1(adapter_index, &adapter) != DXGI_ERROR_NOT_FOUND; adapter_index++) {
// We can't assume the ordering of hardware and software adapters, so keep looping. This path should only execute on Windows 10
// version 1709 or earlier; IDD (e.g. remote desktop) adapters do not exist when taking this code path.
if (IsSoftwareAdapter(adapter.Get())) {
continue;
}

// Make sure that we are able to create the device
ComPtr<ID3D12Device> d3d12_device;
THROW_IF_FAILED(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&d3d12_device)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enumeration code is the same as the code below. I think It's better to have a single else block, and to only have an if (device_luid) when it's time to actually push it to the adapter_infos vector.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I updated it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants