Integration of Math-Library

Hi,

I’m interested in using the CUDA-Math library to improve some time-consuming operations. Unfortunately the documentation (at least the one I found) is not very clear, it only talks about including a “math.h” which does the full trick.

Information I did not find:

  • Does the library use the standard CPU-functions automatically when used within an environment with no NVidia card?
  • If not: how can I detect this state and switch to the "normal" math code in such a case?
  • What binaries have to be provided to the end user for the Math-library - only a few libraries or really the full, huge CUDA package?

Every help and hint is welcome!

Elmi

You’ll need to learn more about programming in CUDA. The CUDA math library will only be useful for CUDA device operations when it is used in properly written CUDA device code (e.g. from within a CUDA kernel).

This question makes no sense in light of the above statements by me, because a CUDA kernel (or CUDA device code) cannot be run at all in an environment with no NVIDIA card. The CUDA math library has no bearing on host code, and will not cause math operations in host code to be performed in any different way – they will not somehow use the GPU.

You would write a program with both CUDA device code and ordinary host code. If you wanted such code to run properly in an environment with no NVIDIA GPU, then in host code you would detect the presence of an NVIDIA GPU. If one is found, you could run your CUDA device code with the CUDA math library functions. If an NVIDIA GPU is not found, you would also need to provide an ordinary host code path to perform the same work. This host code path would use the ordinary host math library functions (e.g. provided by math.h, or whatever).

You would need to provide CUDA runtime libraries at a minimum for CUDA runtime API code. However with modern versions of CUDA these can be statically linked to your application. If you write a CUDA driver API program, potentially no additional libraries would be involved, other than what is provided by the CUDA driver in a properly functioning CUDA GPU-equipped machine.