artyom-beilis / dlprimitives

Deep Learning Primitives and Mini-Framework for OpenCL
http://blog.dlprimitives.org/
MIT License
169 stars 16 forks source link

Use CL map layer on D3D12 #35

Closed VOM7HC closed 1 month ago

VOM7HC commented 2 months ago

As I checked in code, current implement code is based on OpenCL 1.2

For Windows, Microsoft open a OpenCL 1.2 map layer on top D3D12.

https://github.com/microsoft/OpenCLOn12

artyom-beilis commented 1 month ago

Interesting. Can you test it over it?

But one thing I don't understand is why? Virtually all vendors provide good quality OpenCL drivers by default, intel, amd and nvidia. I checked and it works very well on windows out of the box. The OpenCL comes by default with all of them.

Why do you need to add an extra layer?

Additionally I use some extensions, for example for Intel I use some intel specific features in GEMM kernel. I do different optimizations depending on architecture. So what is the rationale of using this middle layer.

VOM7HC commented 1 month ago

Hi, as you know D3D12 is newer and will be future of OS from MS. Maybe like Apple do with Metal, they maybe deprecated or remove it next gen OS, or some new CPU like ARM for Windows will support D3D12 soon than OpenCL.

artyom-beilis commented 1 month ago

D3D12 is platform API. OpenCL is generic API. It is supported even on Android - same like Vulkan. It is provided by vendors.

I have no idea what Apple doing in their closed boxes but in general - same like you can run on Windows, Vulkan, D3D and even OpenGL you can use OpenCL (provided by vendors)

artyom-beilis commented 1 month ago

new CPU

While OpenCL can run on CPU dlprimitives target GPUs or at least iGPUs

VOM7HC commented 1 month ago

Yes, that why we still stick on OpenCL, without vendor lock. But as you know, this will focus on target device API, we just keep same OpenCL in our source code. ARM like Snapdragon has their own NPU, GPU but without Cuda or ROCm. And Microsoft they will not have time port old API on newer device, that mean if newer architecture like RISC-V release, this code still can be maintain.

Currently I am focusing on other OpenCL project but your project is very interesting, so I can't help so much. But will help with small time

VOM7HC commented 1 month ago

I asked Microsoft repo, they said they support OpenCL version 3.0 on D3D12 microsoft/OpenCLOn12#63, their readme is out of date

artyom-beilis commented 1 month ago

Nice. Would you run some tests on native OpenCL vs Microsoft OpenCL over direct3d? Also look at https://github.com/artyom-beilis/pytorch_dlprim for larger benchmark set

Also moving to to discussions