microsoft / OpenCLOn12

The OpenCL-on-D3D12 mapping layer
MIT License
104 stars 13 forks source link

Questions #37

Closed eladmaimoni closed 1 year ago

eladmaimoni commented 1 year ago

Hi,

A few questions regarding this project, I could not find answers online.

MathiasMagnus commented 1 year ago

While I'm not affiliated with the project, here are some answers I can provide:

eladmaimoni commented 1 year ago

@MathiasMagnus thanks for the valuable info!

Can you share how exactly do you setup the environment? I can successfully build the project on my environment (Windows) but the test project can't find the CLOn12Compiler.dll at runtime.

BTW, the reason I asked about uchar buffer access is because hlsl is limited on that regard. I could not find how to access byte offset with hlsl.

MathiasMagnus commented 1 year ago

I haven't built it yet, because the compiler resides in Mesa and I wasn't dedicated enough to build Mesa myself. If you're only interested in using OpenCLOn12 then I'd suggest installing it from the Microsoft Store.

As for indexing an uchar array, just create a buffer with the appropriate size, initialize it like with any other type. Inside the kernel refer to it like a global uchar* arr kernel argument and index into it. OpenCL is a proper compute API so you can do pretty much whatever you can in C.

If you get stuck, I suggest giving the Getting Started on Windows guide a read. Should you have any more questions after that, don't hesitate to ask.

Note: if installing it from the MS Store you don't see the platform, you need to build an OpenCL ICD Loader yourself, because it can only be loaded by a recent enough Loader. (One that is no older than 2 years-ish.) If the one inside System32 is too old, you'll have to make sure you copy your "custom" Loader next to every executable you build. I would discourage from overwriting the system Loader, because that's owned by your drivers.

MathiasMagnus commented 1 year ago

I'm not in front of a computer ATM, but if you look at an older GPUInfo.org submission of mine from an RX580 laptop, and look at the extensions it supports cl_khr_byte_addressable_store using OPENCLON12 which is a ubiquitous extension, because it became a core spec feature in OpenCL 1.1.

jenatali commented 1 year ago

Yes, cl_khr_byte_addressable_store is supported, but it's not efficient. DXIL does not (yet) have support for 8-bit buffer accesses. Loads will be wider and then only the relevant channels will be used. Stores will be turned into a pair of atomics: one AND to set the relevant bits to 0, and then an OR to set the relevant bits to the new value.

eladmaimoni commented 1 year ago

@jenatali thanks for the info. I really hope DXIL will support such basic features in the near future, it is very essential to many compute usage scenarios. Do you know if there is a forum where I can request for such features to be supported?

jenatali commented 1 year ago

Sorry for the long delay on this.

Do you know if there is a forum where I can request for such features to be supported?

https://github.com/microsoft/hlsl-specs is the new repository where a feature can be proposed to HLSL/DXIL. That said, I'm pretty sure this one is already on the backlog.

Since I believe the questions have been answered, I'll go ahead and close this, but please re-open or otherwise let me know if there's other questions.