DirectML/DxDispatch
Justin Stoecker 96faab60cb
Update DxDispatch dependencies and event duration method (#393)
2023-02-22 15:38:19 -08:00
..
cmake Update DxDispatch dependencies and event duration method (#393) 2023-02-22 15:38:19 -08:00
doc Add DxDispatch file reading/writing support (raw files and NumPy .npy arrays) (#293) 2022-11-16 13:33:01 -08:00
models DxDispatch hlsl_add.hlsl fix tiny typo (#335) 2022-11-28 14:45:58 -08:00
src Update DxDispatch dependencies and event duration method (#393) 2023-02-22 15:38:19 -08:00
tools Update DxDispatch dependencies and event duration method (#393) 2023-02-22 15:38:19 -08:00
.gitignore Add DxDispatch tool (#198) 2022-01-27 21:39:53 -08:00
CMakeLists.txt Update DxDispatch dependencies and event duration method (#393) 2023-02-22 15:38:19 -08:00
CMakePresets.json DxDispatch programmatic capture & ONNX models options (#252) 2022-06-30 14:10:26 -07:00
LICENSE Add DxDispatch tool (#198) 2022-01-27 21:39:53 -08:00
README.md Update DxDispatch dependencies and event duration method (#393) 2023-02-22 15:38:19 -08:00
ThirdPartyNotices.txt DxDispatch programmatic capture & ONNX models options (#252) 2022-06-30 14:10:26 -07:00
cgmanifest.json Update DxDispatch dependencies and event duration method (#393) 2023-02-22 15:38:19 -08:00

README.md

DxDispatch

DxDispatch is simple command-line executable for launching DirectX 12 compute programs without writing all the C++ boilerplate. The input to the tool is a JSON model that defines resources, dispatchables (compute shaders, DirectML operators, ONNX models), and commands to execute. The model abstraction makes it easy to experiment, but it also preserves low-level control and flexibility.

Some of the things you can do with this tool:

  • Launch DirectML operators to understand how they work with different inputs.
  • Run custom HLSL compute shaders that are compiled at runtime using the DirectX Shader Compiler.
  • Run ONNX models using ONNX Runtime with the DirectML execution provider.
  • Debug binding and API usage issues. DxDispatch hooks into the Direct3D and DirectML debug layers and prints errors and warnings directly to the console; no need to attach a debugger.
  • Experiment with performance by benchmarking dispatches.
  • Take GPU or timing captures using PIX on Windows. Labeled events and resources make it easy to correlate model objects to D3D objects.

This tool is not designed to be a general-purpose framework for building large computational models or running in production scenarios. The focus is on experimentation and learning!

Getting Started

See the guide for detailed usage instructions. The models directory contains some simple examples to get started. For example, here's an example that invokes DML's reduction operator:

> dxdispatch.exe models/dml_reduce.json

Running on 'NVIDIA GeForce RTX 2070 SUPER'
Resource 'input': 1, 2, 3, 4, 5, 6, 7, 8, 9
Resource 'output': 6, 15, 24

System Requirements

The exact system requirements vary depending on how you configure and run DxDispatch. The default builds rely on redistributable versions of DirectX components when possible, which provides the latest features to the widest range of systems. For default builds of DxDispatch you should consider the following as the minimum system requirements across the range of platforms:

  • A DirectX 12 capable hardware device.
  • Windows 10 November 2019 Update (Version 1909; Build 18363) or newer.
  • If testing shaders that use Shader Model 6.6:

Features and DirectX Components

DxDispatch tries to depend on pre-built redistributable versions of its external dependencies. However, the build can be configured to use alternative sources when desired or necessary. Each component can use one of the available () sources in the table below, with the default selection for each platform listed first. Not all configurations are tested, and some platforms don't include the optional+ components.

Platform DirectML Direct3D 12 DX Compiler+ PIX Event Runtime+ ONNX Runtime+
Windows - x64 nuget
winsdk
local
nuget
winsdk
archive nuget nuget
Windows - x86 nuget
winsdk
local
nuget
winsdk
none none nuget
Windows - ARM64 nuget
winsdk
local
nuget
winsdk
archive nuget nuget
Linux - x64 (WSL) nuget
local
wsl none none none

The default redistributable versions of components (e.g. nuget, archives):

Configuration is done using CMake cache variables. For example, Direct3D can be switched to a system dependency by adding -DDXD_DIRECT3D_TYPE=winsdk to the command line when first configuring the project. Use cmake-gui or ccmake to view the available variables.

Building, Testing, and Installing

DxDispatch relies on several external dependencies that are downloaded when the project is configured. See ThirdPartyNotices.txt for relevant license info.

Configure presets are listed configuration in CMakePresets.json:

> cmake --list-presets
Available configure presets:

  "win-x64"       - Windows x64
  "win-x86"       - Windows x86
  "win-arm64"     - Windows ARM64
  "xbox-scarlett" - Xbox Scarlett
  "linux-x64"     - Linux x64

To generate the project, provide one of the above names (e.g. win-x64) to cmake:

> cmake --preset <configure_preset_name>

You can build from the generated VS solution under build\<configure_preset_name>\dxdispatch.sln.

Alternatively, build from the command line by using --build option and appending the build configuration to the preset name (e.g. the win-x64 configure preset has the build presets named win-x64-release and win-x64-debug).

> cmake --build --preset <configure_preset_name>-(release|debug)

To run tests, change your working directory to the build folder and execute ctest (only supported on some platforms). You need to specify the build configuration (release or debug) since the presets use VS, which is a multi-configuration generator:

> cd build\<configure_preset_name>
> ctest -C Release .