Question regarding CUDA support in CMake 3.8.0-rc2

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Question regarding CUDA support in CMake 3.8.0-rc2

Nick Henderson
Hello!

I am testing out the CUDA support in CMake 3.8.0-rc2.

When running `make VERBOSE=1` in the build directory, I get a warning generated related to the GPU architecture flags for nvcc:

```
[ 80%] Linking CUDA device code /home/nwh/git/foobar/build/exec/CMakeFiles/exec.dir/cmake_device_link.o
cd /home/nwh/git/foobar/build/exec && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/exec.dir/dlink.txt --verbose=1
/usr/local/cuda/bin/nvcc   -Xcompiler=-fPIC -shared -dlink CMakeFiles/exec.dir/exec.cc.o -o CMakeFiles/exec.dir/cmake_device_link.o ../libfoobar.a
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
```

I don't get the warning when the executable source is being compiled because an up-to-date architecture is specified:

```
[ 60%] Building CUDA object exec/CMakeFiles/exec.dir/exec.cc.o
cd /home/nwh/git/foobar/build/exec && /usr/local/cuda/bin/nvcc   -I/home/nwh/git/foobar  -arch compute_30 -std=c++11 -x cu -c /home/nwh/git/foobar/exec/exec.cc -o CMakeFiles/exec.dir/exec.cc.o
```

Link to sample project: https://github.com/nwh/foobar

Questions:

* Is this a problem?
* What is the purpose of cmake_device_link.o?

Thanks,
Nick
Reply | Threaded
Open this post in threaded view
|

Re: Question regarding CUDA support in CMake 3.8.0-rc2

Robert Maynard
Hi,

The purpose of the cmake_device_link.o is to resolve device side
symbols when doing separable compilation. We do this device linking
step for all CUDA enabled targets as it makes the internal CMake to
logic significantly easier ( no need to propagate another property
through the graph, etc ). Updating CMake to only do device linking
where needed is theoretical possible, but opens up a new question on
consistency [1].

What you have pointed out is actually two issues. The first is that
target_compile_options by design does not propagate any flags to the
linker, which is a design decision made by CMake. The second being
that for CUDA arch/code flags in general need to be passed to both the
compiler and the linker.

So currently CUDA projects should specify arch/code flags through
CMAKE_CUDA_FLAGS/CMAKE_CUDA_FLAGS_<CONFIG> to have them propagate to
the linker.

[1] - If we only do device linking for targets that need separable
compilation, we introduce a split in CUDA targets where some are
satisfied by add_compile_options, and others require
CMAKE_CUDA_FLAGS/CMAKE_CUDA_FLAGS_<CONFIG>. To complicate this
situation you can't provide -arch/code in both as that will generally
result in a collection of invalid flags.


On Wed, Mar 15, 2017 at 8:22 PM, Nick Henderson
<[hidden email]> wrote:

> Hello!
>
> I am testing out the CUDA support in CMake 3.8.0-rc2.
>
> When running `make VERBOSE=1` in the build directory, I get a warning
> generated related to the GPU architecture flags for nvcc:
>
> ```
> [ 80%] Linking CUDA device code
> /home/nwh/git/foobar/build/exec/CMakeFiles/exec.dir/cmake_device_link.o
> cd /home/nwh/git/foobar/build/exec && /usr/local/bin/cmake -E
> cmake_link_script CMakeFiles/exec.dir/dlink.txt --verbose=1
> /usr/local/cuda/bin/nvcc   -Xcompiler=-fPIC -shared -dlink
> CMakeFiles/exec.dir/exec.cc.o -o CMakeFiles/exec.dir/cmake_device_link.o
> ../libfoobar.a
> nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are
> deprecated, and may be removed in a future release (Use
> -Wno-deprecated-gpu-targets to suppress warning).
> ```
>
> I don't get the warning when the executable source is being compiled because
> an up-to-date architecture is specified:
>
> ```
> [ 60%] Building CUDA object exec/CMakeFiles/exec.dir/exec.cc.o
> cd /home/nwh/git/foobar/build/exec && /usr/local/cuda/bin/nvcc
> -I/home/nwh/git/foobar  -arch compute_30 -std=c++11 -x cu -c
> /home/nwh/git/foobar/exec/exec.cc -o CMakeFiles/exec.dir/exec.cc.o
> ```
>
> Link to sample project: https://github.com/nwh/foobar
>
> Questions:
>
> * Is this a problem?
> * What is the purpose of cmake_device_link.o?
>
> Thanks,
> Nick
>
>
>
> --
> View this message in context: http://cmake.3232098.n2.nabble.com/Question-regarding-CUDA-support-in-CMake-3-8-0-rc2-tp7595171.html
> Sent from the CMake mailing list archive at Nabble.com.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Question regarding CUDA support in CMake 3.8.0-rc2

Nick Henderson
Thank you!

Setting:

set(CMAKE_CUDA_FLAGS "-arch compute_30 ${CMAKE_CUDA_FLAGS}")

did the trick.

Is there any documentation or example projects related to the new CUDA support?

CUDA support is great to have and will simplify my build system!  Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Question regarding CUDA support in CMake 3.8.0-rc2

Robert Maynard
A good starting spot would be the tests in CMake itself for CUDA support:

https://gitlab.kitware.com/cmake/cmake/tree/master/Tests/Cuda
https://gitlab.kitware.com/cmake/cmake/tree/master/Tests/CudaOnly

On Thu, Mar 16, 2017 at 1:58 PM, Nick Henderson
<[hidden email]> wrote:

> Thank you!
>
> Setting:
>
> set(CMAKE_CUDA_FLAGS "-arch compute_30 ${CMAKE_CUDA_FLAGS}")
>
> did the trick.
>
> Is there any documentation or example projects related to the new CUDA
> support?
>
> CUDA support is great to have and will simplify my build system!  Thank you.
>
>
>
> --
> View this message in context: http://cmake.3232098.n2.nabble.com/Question-regarding-CUDA-support-in-CMake-3-8-0-rc2-tp7595171p7595174.html
> Sent from the CMake mailing list archive at Nabble.com.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake