How to build NVidia binaries using CMake's new HIP language?

I’ve updated my code recently to make use of the “HIP language”, introduced in 3.21.

After some initial success on a host with an AMD card, I was now trying to build some code on a host that has an NVidia card. And had to realise that I don’t know how to do that. What environment/cache variable can one use to tell the build that it should use HIP_PLATFORM=nvidia? Unfortunately looking through the CMake source code I didn’t find any hint about this. :frowning:

Cheers,
Attila

I believe you’re correct, this isn’t working properly yet. I’ll let you know when we have a MR up so you can try it out if you’re interested.

1 Like

Sounds good! Yes, please let me know, I’ll give it a spin.

Hello @zackgalbreath and @krasznaa, any progress on this topic?

I’m experiencing the same problem with a test library that I built on a AMD platform and then try to move it on NVIDIA platform.

I’m using CMake 3.26 at the moment, but perhaps there, is by now, a proper path to address hip compilations on NVIDIA platforms. :thinking:

Hi Manuel,

Since in our code we don’t use HIP all too seriously (there’s just some basic infrastructure for using it, but no actual “algorithmic code”), I lost track of this. (Our build still uses my hand-written implementation for this.)

I would still be very keen on switching to a centrally managed implementation. So if there’s any update around this, I would also be very interested in knowing about it…

Cheers,
Attila

Hi Attila,

After scratching my head with this problem for the last week. I managed to archive a working solution :smile:

In this example, I demonstrate the only work around I was able to obtain in order to produce a truly cross-platform sample library using HIP/CUDA and CMake in a clean/simply manner.

I would appreciate any feedback/critic on this approach :thinking:

kind regards,
Manuel

Hi Manuel,

Sorry for never replying to this. :frowning_face: Don’t have a good excuse, I just forgot. :frowning_face:

That example is fine for what it’s doing, but it’s not really what this thread is about. One can use the runtime API of HIP fairly easily from CMake. Even without support being in CMake directly, one can use the code coming with ROCm.

https://rocm.docs.amd.com/en/latest/understand/cmake_packages.html#consuming-the-hip-api-in-c-code

Very similar to what you do in that example…

But what I’m after is building “device code” for an NVIDIA or AMD backend from the same HIP code. Currently I do this in a very fragile way in our code, with:

But ideally I’d prefer CMake to provide a global CMAKE_HIP_PLATFORM global cache variable, and a target specific HIP_PLATFORM property, which could be used to control what backend any piece of HIP code would be compiled/linked for. And that would need some further development from somebody. Not sure exactly who…

Cheers,
Attila