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.
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…
After scratching my head with this problem for the last week. I managed to archive a working solution
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
Sorry for never replying to this. Don’t have a good excuse, I just forgot.
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.
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…
Thx @krasznaa for your sharing, I truly find your CMakeLists insightful !
Is my time to apologize because I just noticed your response until today.
(… and reactivated my forum account)
It is true, my goal is not just using HIP to build NVidia binaries, but to have a single code that can build AMD or NVidia binaries with CMake reliably. But, I wish my code to only support CUDA on NVidia and HIP on AMD platform, strictly.
Just as an update, I’m coming back to explore HIP for the second time, and I can see a lot of progress on HIP 6.2.4 although the support for HIP on NVidia still limited. However, this time I found an easier time by controlling the language and linkage properties of the sources. To the point of being able to generate NVidia binaries from HIP reliably.
Moreover, we can now specify a CMAKE_HIP_PLATFORM finally (like for a CUDA build). Here I leave an update of my old snippets to reflect what I have learned so far.