CUDA warns about redefining thrust when using OpenMP backend

I am testing out the possibility of swinging thrust’s backend between CUDA, OpenMP and TBB. However, when I tried it with Thrust/OpenMP backend, there are a lot of warnings:

[ 50%] Building NVCC (Device) object CMakeFiles/test.dir/test_generated_test.cu.o
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/execution_policy.h:31:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:33,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/config.h:77:0: warning: "THRUST_CUB_NS_PREFIX" redefined
     #define THRUST_CUB_NS_PREFIX namespace thrust {   namespace cuda_cub {
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_arch.cuh:36:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:32,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_namespace.cuh:41:0: note: this is the location of the previous definition
     #define THRUST_CUB_NS_PREFIX
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/execution_policy.h:31:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:33,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/config.h:78:0: warning: "THRUST_CUB_NS_POSTFIX" redefined
     #define THRUST_CUB_NS_POSTFIX }  }
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_arch.cuh:36:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:32,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_namespace.cuh:45:0: note: this is the location of the previous definition
     #define THRUST_CUB_NS_POSTFIX
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/execution_policy.h:31:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:33,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/config.h:77:0: warning: "THRUST_CUB_NS_PREFIX" redefined
     #define THRUST_CUB_NS_PREFIX namespace thrust {   namespace cuda_cub {
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_arch.cuh:36:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:32,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_namespace.cuh:41:0: note: this is the location of the previous definition
     #define THRUST_CUB_NS_PREFIX
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/execution_policy.h:31:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:33,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/config.h:78:0: warning: "THRUST_CUB_NS_POSTFIX" redefined
     #define THRUST_CUB_NS_POSTFIX }  }
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_arch.cuh:36:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:32,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_namespace.cuh:45:0: note: this is the location of the previous definition
     #define THRUST_CUB_NS_POSTFIX
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/execution_policy.h:31:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:33,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/config.h:77:0: warning: "THRUST_CUB_NS_PREFIX" redefined
     #define THRUST_CUB_NS_PREFIX namespace thrust {   namespace cuda_cub {
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_arch.cuh:36:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:32,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_namespace.cuh:41:0: note: this is the location of the previous definition
     #define THRUST_CUB_NS_PREFIX
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/execution_policy.h:31:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:33,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/config.h:78:0: warning: "THRUST_CUB_NS_POSTFIX" redefined
     #define THRUST_CUB_NS_POSTFIX }  }
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_arch.cuh:36:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:32,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_namespace.cuh:45:0: note: this is the location of the previous definition
     #define THRUST_CUB_NS_POSTFIX
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/execution_policy.h:31:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:33,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/config.h:77:0: warning: "THRUST_CUB_NS_PREFIX" redefined
     #define THRUST_CUB_NS_PREFIX namespace thrust {   namespace cuda_cub {
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_arch.cuh:36:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:32,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_namespace.cuh:41:0: note: this is the location of the previous definition
     #define THRUST_CUB_NS_PREFIX
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/execution_policy.h:31:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:33,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/config.h:78:0: warning: "THRUST_CUB_NS_POSTFIX" redefined
     #define THRUST_CUB_NS_POSTFIX }  }
     
    In file included from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_arch.cuh:36:0,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/util.h:32,
                     from /usr/local/cuda-9.1/include/thrust/system/cuda/detail/terminate.h:31,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/allocator/temporary_allocator.h:84,
                     from /usr/local/cuda-9.1/include/thrust/detail/temporary_array.h:27,
                     from /usr/local/cuda-9.1/include/thrust/detail/overlapped_copy.h:23,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.inl:24,
                     from /usr/local/cuda-9.1/include/thrust/detail/vector_base.h:547,
                     from /usr/local/cuda-9.1/include/thrust/device_vector.h:26,
                     from /home/qth20/Documents/thrust_cuda_test/test.cu:1:
    /usr/local/cuda-9.1/include/thrust/system/cuda/detail/cub/util_namespace.cuh:45:0: note: this is the location of the previous definition
     #define THRUST_CUB_NS_POSTFIX
     
    [100%] Linking CXX executable test
    [100%] Built target test

Here is my CMakeLists.txt:

PROJECT(test)
    set (OUTPUT_NAME test)
    
    cmake_minimum_required (VERSION 2.8)
    
    #test variable
    #set(THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_CUDA)
    set(THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_OMP)
    #set(THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_TBB)
    
    # Set CUDA
    find_package(CUDA REQUIRED)
    list(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_70,code=sm_70)
    list(APPEND CUDA_NVCC_FLAGS -DTHRUST_DEVICE_SYSTEM=${THRUST_DEVICE_SYSTEM})
    list(APPEND CUDA_NVCC_FLAGS -Xcompiler -fopenmp)
    set (sources_gpu_cuda test.cu)
    
    # Set OpenMP
    set(omp_deps gomp)
    
    set (sources ${sources_gpu_cuda})
    
    cuda_add_executable(${OUTPUT_NAME} ${sources} ${headers})
    target_link_libraries (${OUTPUT_NAME} ${omp_deps})

And file test.cu:

#include <thrust/device_vector.h>
    #include <cstdio>
    
    struct cuda_hello
    {
      __host__ __device__
      void operator()(int x)
      {
        printf("Hello, world from Cuda!\n");
      }
    };
    
    int main()
    {
        thrust::device_vector<int> cuda_vec(1, 0);
        thrust::for_each(cuda_vec.begin(),cuda_vec.end(),cuda_hello());
    }

Doesn’t look like I violate anything - as in the code still compiled and run normally. I just want to know what these warning means. This is CUDA 9.1 compiled with gcc 6.4.0.

There is an instructive comment posted on your cross-posting:
[url]https://stackoverflow.com/questions/51127401/cuda-warns-about-redefining-thrust-when-using-openmp-backend[/url]
in short it is a known issue. I don’t have any further information at this time.