Skip to content

How to use CuPy's headers in a CUDA file? #2530

@leofang

Description

@leofang

I must have missed something trivial. I want to use CuPy's Thrust headers to do some tests, but I am unable to compile even a simple file like this:

//file: do_nothing.cu
#include <cupy/complex.cuh>

__device__ float xxx (const float x) {
    return x+1;
}

Compile it with nvcc -Icupy/core/include -c do_nothing.cu in the root of CuPy source to generate an object file, I got the following errors:

cupy/core/include/cupy/complex/arithmetic.h:258:78: error: ‘float thrust::abs(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline float abs(const complex<float>& z) {
                                                                              ^
cupy/core/include/cupy/complex/arithmetic.h:262:80: error: ‘double thrust::abs(const thrust::complex<double>&)’ is not declared in ‘thrust’
 __device__ inline double abs(const complex<double>& z) {
                                                                                ^
cupy/core/include/cupy/complex/cexp.h:169:91: error: ‘thrust::complex<double> thrust::exp(const thrust::complex<double>&)’ is not declared in ‘thrust’
 __device__ inline complex<double> exp(const complex<double>& z) {
                                                                                           ^
cupy/core/include/cupy/complex/cexpf.h:149:89: error: ‘thrust::complex<float> thrust::exp(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> exp(const complex<float>& z) {
                                                                                         ^
cupy/core/include/cupy/complex/clog.h:192:91: error: ‘thrust::complex<double> thrust::log(const thrust::complex<double>&)’ is not declared in ‘thrust’
 __device__ inline complex<double> log(const complex<double>& z) {
                                                                                           ^
cupy/core/include/cupy/complex/clogf.h:188:89: error: ‘thrust::complex<float> thrust::log(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> log(const complex<float>& z) {
                                                                                         ^
cupy/core/include/cupy/complex/ccosh.h:195:2: error: ‘thrust::complex<double> thrust::cos(const thrust::complex<double>&)’ is not declared in ‘thrust’
     const thrust::complex<double>& z) {
  ^
cupy/core/include/cupy/complex/ccosh.h:201:2: error: ‘thrust::complex<double> thrust::cosh(const thrust::complex<double>&)’ is not declared in ‘thrust’
     const thrust::complex<double>& z) {
  ^
cupy/core/include/cupy/complex/ccoshf.h:126:89: error: ‘thrust::complex<float> thrust::cos(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> cos(const complex<float>& z) {
                                                                                         ^
cupy/core/include/cupy/complex/ccoshf.h:131:90: error: ‘thrust::complex<float> thrust::cosh(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> cosh(const complex<float>& z) {
                                                                                          ^
cupy/core/include/cupy/complex/csinh.h:183:91: error: ‘thrust::complex<double> thrust::sin(const thrust::complex<double>&)’ is not declared in ‘thrust’
 __device__ inline complex<double> sin(const complex<double>& z) {
                                                                                           ^
cupy/core/include/cupy/complex/csinh.h:188:92: error: ‘thrust::complex<double> thrust::sinh(const thrust::complex<double>&)’ is not declared in ‘thrust’
 __device__ inline complex<double> sinh(const complex<double>& z) {
                                                                                            ^
cupy/core/include/cupy/complex/csinhf.h:124:89: error: ‘thrust::complex<float> thrust::sin(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> sin(const complex<float>& z) {
                                                                                         ^
cupy/core/include/cupy/complex/csinhf.h:129:90: error: ‘thrust::complex<float> thrust::sinh(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> sinh(const complex<float>& z) {
                                                                                          ^
cupy/core/include/cupy/complex/ctanh.h:182:91: error: ‘thrust::complex<double> thrust::tan(const thrust::complex<double>&)’ is not declared in ‘thrust’
 __device__ inline complex<double> tan(const complex<double>& z) {
                                                                                           ^
cupy/core/include/cupy/complex/ctanhf.h:107:89: error: ‘thrust::complex<float> thrust::tan(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> tan(const complex<float>& z) {
                                                                                         ^
cupy/core/include/cupy/complex/csqrt.h:140:92: error: ‘thrust::complex<double> thrust::sqrt(const thrust::complex<double>&)’ is not declared in ‘thrust’
 __device__ inline complex<double> sqrt(const complex<double>& z) {
                                                                                            ^
cupy/core/include/cupy/complex/csqrtf.h:137:90: error: ‘thrust::complex<float> thrust::sqrt(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> sqrt(const complex<float>& z) {
                                                                                          ^
cupy/core/include/cupy/complex/catrig.h:697:92: error: ‘thrust::complex<double> thrust::acos(const thrust::complex<double>&)’ is not declared in ‘thrust’
 __device__ inline complex<double> acos(const complex<double>& z) {
                                                                                            ^
cupy/core/include/cupy/complex/catrig.h:702:92: error: ‘thrust::complex<double> thrust::asin(const thrust::complex<double>&)’ is not declared in ‘thrust’
 __device__ inline complex<double> asin(const complex<double>& z) {
                                                                                            ^
cupy/core/include/cupy/complex/catrig.h:708:92: error: ‘thrust::complex<double> thrust::atan(const thrust::complex<double>&)’ is not declared in ‘thrust’
 __device__ inline complex<double> atan(const complex<double>& z) {
                                                                                            ^
cupy/core/include/cupy/complex/catrig.h:725:93: error: ‘thrust::complex<double> thrust::atanh(const thrust::complex<double>&)’ is not declared in ‘thrust’
 __device__ inline complex<double> atanh(const complex<double>& z) {
                                                                                             ^
cupy/core/include/cupy/complex/catrigf.h:411:90: error: ‘thrust::complex<float> thrust::acos(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> acos(const complex<float>& z) {
                                                                                          ^
cupy/core/include/cupy/complex/catrigf.h:416:90: error: ‘thrust::complex<float> thrust::asin(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> asin(const complex<float>& z) {
                                                                                          ^
cupy/core/include/cupy/complex/catrigf.h:422:90: error: ‘thrust::complex<float> thrust::atan(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> atan(const complex<float>& z) {
                                                                                          ^
cupy/core/include/cupy/complex/catrigf.h:439:91: error: ‘thrust::complex<float> thrust::atanh(const thrust::complex<float>&)’ is not declared in ‘thrust’
 __device__ inline complex<float> atanh(const complex<float>& z) {
                                                                                           ^

Any hint or comment is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions