lion03 / thrust

Automatically exported from code.google.com/p/thrust
Apache License 2.0
0 stars 0 forks source link

host_defines.h does not exist #312

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I was trying to compile a program like:

#include <thrust/host_vector.h>
int main(){
        return 0;
}

With g++ and I get:

./thrust/detail/config/host_device.h:27:26: error: host_defines.h: No such file 
or directory

Is it supposed to e possible to use host_vector inside pure c++ programs?
Am I supposed to define host_defines.h myself?

Original issue reported on code.google.com by filipe.c...@gmail.com on 27 Feb 2011 at 6:40

GoogleCodeExporter commented 8 years ago
Issue 313 has been merged into this issue.

Original comment by jaredhoberock on 28 Feb 2011 at 3:56

GoogleCodeExporter commented 8 years ago

Original comment by jaredhoberock on 28 Feb 2011 at 3:56

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
@filipe: It is possible, and I do just that myself all the time.  The problem 
here is that host_defines.h is part of CUDA.   By default Thrust chooses a CUDA 
backend . You need to select the OpenMP backend by adding #define 
THRUST_DEVICE_BACKEND 2 at the top, in which case Thrust will not attempt to 
include host_defines.h

Original comment by andrew.c...@gmail.com on 28 Feb 2011 at 12:05

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I see.  So If want to use the CUDA and cpp files I can include the CUDA include 
directory? It seems to work in this case.

Original comment by filipe.c...@gmail.com on 28 Feb 2011 at 5:20

GoogleCodeExporter commented 8 years ago
I too am making use of thrust in an environment where we're falling back to 
OpenMP when CUDA isn't available.

The host_defines.h header isn't particularly nvcc specific and can be used with 
GCC/OpenMP directly.

We've taken to shipping host_defines.h in our source tree as a workaround for 
the moment until this issue is fixed.

Original comment by richware...@gmail.com on 31 Mar 2011 at 11:57

GoogleCodeExporter commented 8 years ago
I'm not convinced this is a bug.  host_defines.h is only #included when CUDA is 
being targeted [1].  It seems like any user targeting CUDA would necessarily 
have this header on his system.

[1] 
http://code.google.com/p/thrust/source/browse/thrust/detail/config/host_device.h
#25

Original comment by jaredhoberock on 31 Mar 2011 at 6:06

GoogleCodeExporter commented 8 years ago
Unfortunately, whenever the user is targeting the CUDA backend we can't safely 
#define __host__ and __device__ ourselves since doing so can result in the 
following error
  /usr/local/cuda/include/host_defines.h:165:1: warning: "__device__" redefined

Here are two solutions:
1) compile the .cpp files with nvcc
2) supply the path to the CUDA headers to the host compiler (e.g. g++ -I 
/usr/local/cuda/include)

If you are not targeting the CUDA backend then you should define 
THRUST_DEVICE_BACKEND as explained here [1].

[1] http://code.google.com/p/thrust/wiki/DeviceBackends

Original comment by wnbell on 23 Aug 2011 at 4:20