Commit 02c843d5 authored by Pierre NARVOR's avatar Pierre NARVOR
Browse files

[cuda] Added host/device definition for complex numbers

parent 4f64e0ca
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <cstring> #include <cstring>
#include <complex>
#include <cuda_runtime.h> #include <cuda_runtime.h>
...@@ -41,8 +42,25 @@ ...@@ -41,8 +42,25 @@
} \ } \
} while(0) \ } while(0) \
// Using NVIDIA thrust framework when compiling CUDA code.
#ifdef RTAC_CUDACC
#include <thrust/complex.h>
#endif //RTAC_CUDACC
namespace rtac { namespace cuda { namespace rtac { namespace cuda {
// Complex number definition : using thrust::complex when in CUDA device code
// (NVCC compiler) and std::complex when in host code (CPU side). Both are
// binary compatible (a buffer can be created an initialized on host side then
// uploaded to device and the other way around seamlessly).
#ifdef RTAC_CUDACC
template <typename T>
using Complex = thrust::complex<T>;
#else
template <typename T>
using Complex = std::complex<T>;
#endif //RTAC_CUDACC
inline void init_cuda() inline void init_cuda()
{ {
// CUDA will init on the first API call. // CUDA will init on the first API call.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment