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

About DirectML & DirectCompute #383

Open
Looong01 opened this issue Feb 6, 2023 · 2 comments
Open

About DirectML & DirectCompute #383

Looong01 opened this issue Feb 6, 2023 · 2 comments

Comments

@Looong01
Copy link

Looong01 commented Feb 6, 2023

I notice that "Or you could use HLSL to write a compute shader, perhaps to implement a physics simulation. However, if for example you're inclined to write your own convolution operator (for image processing) as HLSL in a compute shader, then you'll get better performance in that scenario if you use Direct Machine Learning (DirectML) instead." here.

  1. Does DirectML have all the characteristics of DirectCompute?
  2. Are all the APIs and functions in DirectCompute compatible with DirectML?
  3. What are the differences between DirectCompute and DirectML?
  4. In which situation should I use DirectCompute? When should I use DirectML?
@BytePetter
Copy link

Push, because I need answers to these questions, too.

@jstoecker
Copy link
Contributor

Background:

  • DirectCompute is synonymous with compute shaders, which are general-purpose programs that run on a GPU as part of the Direct3D programming API. There isn't a separate DirectCompute API, and there isn't a separate library/DLL for it; it's all just the Direct3D API and runtime library. I think DirectCompute was just a fancy marketing name back when the feature originally came out.
  • HLSL is the language used to write compute shaders, which are then compiled into a form of bytecode using a shader compiler. The shader bytecode is then handed off to a GPU driver using the Direct3D API.
  • DirectML is basically (oversimplifying here) a library of pre-compiled compute shaders. DirectML is a separate library and API that is distinct from Direct3D. The DirectML API can be viewed as an extension of the Direct3D 12 API; you cannot use DirectML without also using Direct3D 12.

Your questions:

  1. Not sure how to answer this, because DirectML uses compute shaders. DirectML is not a superset or replacement for compute shaders, which should hopefully be more clear from background.
  2. DirectML is compatible with Direct3D 12 and hand-written compute shaders. You can mix both types of work into the same D3D12 command lists, for example.
  3. Hopefully explained earlier.
  4. This is similar to asking when you should use an API like std::sort instead of writing your own sorting algorithm. You're encouraged to use the DirectML APIs if they fit your use case, but it can't cover all possible cases.

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

No branches or pull requests

3 participants