cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

joelmatth
Journeyman III

PTX to SPIR compiler

Hi. I am doing some research into compiling PTX into SPIR.

Does anyone know of any projects that do this currently?

The plan is to build a PTX frontend for LLVM and then utilise Clang's existing SPIR backend.

Are there any such frontends already?

0 Likes
3 Replies
dipak
Big Boss

Oops! No reply till now. Sorry, I don't know either. I guess, you should check on Nvidia forum which is more appropriate for this query.

Regards,

0 Likes

Just make sure you don't say that ultimately you wish to generate SPIR. The moment a question even remotely relates to OpenCL, it's importance drops heavily.

On the other hand, while the SPIR back-end of LLVM is pretty much done and could be used, if a new project is starting, I would highly recommend targeting SPIR-V, as it will be much more widely adopted. Even Nvidia will support SPIR-V, as it is the intermediate to Vulkan, which they are interested in. Also, SPIR-V is the intermediate to OpenCL 2.1. I would highly recommend any new project to target SPIR-V in favor of SPIR, as you will be able to target a much wider range of hardware going from Mali, Adreno IGPs through Intel Iris, Tegra and AMD APUs all the way to high-end GPUs, all with a single toolchain

0 Likes
Meteorhead
Challenger

I would like to further elaborate on my earlier post:

First of all, my assumption is, that anyone looking for a PTX-SPIR converter is looking to port CUDA projects over to the portable world. This assumption stems from the fact that pretty much everything has already been written in CUDA, and extracting the IL from these projects, they could be used with portable tools. The aim of such a conversion tool I suspect is not to do the conversion the other way around.

Either way, I feel that such a conversion tool would only prolong the harmful CUDA dominance in compute, and as such I would not suggest anyone to embark on this path. Infact, such a tool would only make the CUDA dominance stronger, as you are likely to generate PTX with nvcc, and not contending tools like Clang. Depending on propriatary tools to gain some half*ssed support of using a propriatary based tool in the portable world puts you in the danger similar to GameWorks, PhysX and other Nvidia initiatives, where you are "shielded" from the details through a tool that is deliberately trying to hinder the competition. The moment such a conversion tool came to existance, the PTX generated by nvcc will take a form that will be harder and harder to optimize by contending compilers. By the sway of a magical wand, you'd be in the same place where DX11 graphics is today. The DX bytecode and API usage is garbage as it is, and you need hundreds of compiler dev man hours to optimize it in the drivers. You can be sure, that the PTX you would get out of cuFFT would be of a form that could only be optimized correctly by the Nv driver. The kind of SPIR IL and the performance you'd get out of it would be nowhere near what you'd expect.

These might be false accusations, but take a look at Witcher 3 for instance, but I could link many other cases. This is borderline unethical industrial self-defense from Nvidia. I personally would be against any tool that by it's existance would solidify or prolong the CUDA dominance, rather than strengthen the portable tools. First of all, because I don't like black boxes handed to me; second, because monopoly is always harmful and competition is needed.

I would suggest reading about this SPIR-V <-> LLVM project, as I feel it would be of greater benefit to all.

0 Likes