2016-11-15 2 views
1

나는 술어가 양수 검사와 함께 배열을 압축하는 copy_if 추력을 :: 사용하려고 해요 :추력 : 불완전한 유형이 허용되지 않습니다

헤더 파일 : file.h :

struct is_positive 
{ 
    __host__ __device__ 
    bool operator()(const int x) 
    { 
    return (x >= 0); 
    } 
}; 

및 file.cu

#include "../headers/file.h" 
#include <thrust/device_ptr.h> 
#include <thrust/device_vector.h> 
#include <thrust/copy.h> 


void compact(int* d_inputArray, int* d_outputArray, const int size) 
{ 
    thrust::device_ptr<int> t_inputArray(d_inputArray); 
    thrust::device_ptr<int> t_outputArray(d_outputArray); 
    thrust::copy_if(t_inputArray, t_inputArray + size, d_outputArray, is_positive()); 
} 

I로 시작하는 오류 메시지를 받고 있어요 :

/usr/local/cuda/include/thrust/system/detail/generic/memory.inl(40): error: incomplete type is not allowed

full errormsg here

난 그냥 copy_if 대신 사본을 사용하는 경우, 코드는 잘 컴파일, 그래서 나는 밖으로 술어 is_positive()를 제외하고 모든 것을 지배했다.

이러한 추력 오류를 디버그하는 방법에 대한 도움말이나 일반적인 팁에 대해 미리 감사드립니다.

전자 : 나는 그냥 오타를 가지고있는 것처럼 보이는 나에게

답변

3

CUDA는 7.5을 사용하고 있습니다. 이 :

thrust::copy_if(t_inputArray, t_inputArray + size, d_outputArray, is_positive()); 
               ^

이 같아야합니다

thrust::copy_if(t_inputArray, t_inputArray + size, t_outputArray, is_positive()); 

당신은 적절한 추력 장치 포인터와 원시 포인터를 혼합 한,이 문제를 일으키는 것입니다.

+0

글쎄, 당황 스럽네. 감사합니다, 당신 말이 맞아요, 매력처럼 작동합니다! – mimre