Pergunta

When I try to compile the following code with c++ on OS X 10.8, it works fine - no compile errors.

#include <gmpxx.h>
int main(int argc, const char * argv[]) { }

However, when I try to do the same with nvcc, I get a ton of errors:

/usr/local/Cellar/gcc47/4.7.3/gcc/lib/gcc/x86_64-apple-darwin12.5.0/4.7.3/../../../../include/c++/4.7.3/limits(1405): error: identifier "__int128" is undefined
/usr/local/Cellar/gcc47/4.7.3/gcc/lib/gcc/x86_64-apple-darwin12.5.0/4.7.3/../../../../include/c++/4.7.3/limits(1421): error: function call is not allowed in a constant expression
...

How can I use GMP with NVCC/CUDA? To clarify, I don't intend to perform GMP calculations on the device, just the host.

Foi útil?

Solução

  1. Create a .cpp module that you compile with your host compiler, and include your GMP code there.

  2. Create a separate .cu module that you compile with nvcc, and include your CUDA code there.

  3. Link them together.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top