NVSHMEM CMake best practice

Hi all,

I just wanted to ask is there some kind of best practice to include nvshmem in your project if you are using cmake as your build system. I have done some digging but unfortunately didn’t find anything conclusive.


Hi Luis,

In order to include nvshmem in your project’s cmake file, you will want to first have the compiled binary package of nvshmem, version 2.9.

Then you just need to add the following llines to your CMakeLists.txt file:

find_package(NVSHMEM REQUIRED HINTS ${NVSHMEM_PREFIX}/lib/cmake/nvshmem)
add_library(nvshmem ALIAS nvshmem::nvshmem) //Note - this is only needed if you are statically linking both host and device.
add_library(nvshmem_host ALIAS nvshmem::nvshmem_host) // dynamically linked host library
add_library(nvshmem_device ALIAS nvshmem::nvshmem_device) // statically linked host library

Note - NVSHMEM_PREFIX should be set to the TLD of the nvshmem binary package.
I apologize, we don’t have this specifically documented for NVSHMEM yet, but there is some good information on the cmake website (find_package — CMake 3.26.3 Documentation) for how to use CMake configuration files like the ones we expose in NVSHMEM.

Please feel free to reach out with more questions or suggestions.

1 Like

Many thanks for your reply, that was exactly what I was looking for :)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.