여러 유형에서 binary_functions로 추력 감소를 어떻게 사용합니까? 내 경우에는 멤버 '거리'가있는 FaceUV 구조체가 있습니다. 나는 모든 FaceUV를 거리 계산에 넣고 싶다! = 0. 어떻게해야합니까?binary_function 및 여러 유형으로 스러스트 감소
는 나는이라고 생각하지만, 컴파일되지 않습니다 :
struct FaceHasUVCmp : public thrust::binary_function<FaceUV, uint32_t, uint32_t> {
__device__
uint32_t operator()(const FaceUV& o1, const uint32_t& count) const {
return count + (o1.distance != 0);
}
};
float get_percent_of_FACES_with_UVs(thrust::device_ptr<FaceUV> face_uvs, unsigned int size){
uint32_t num_with_UVs = thrust::reduce(thrust::cuda::par, face_uvs, face_uvs + size, 0, FaceHasUVCmp());
return num_with_UVs/(float)size;
}
실제로 'thrust :: reduce'를 사용하면 가능하지만 사용자 정의 이진 함수 대신 사용자 유형에 맞게 사용자 정의 반복기를 구현해야합니다 – talonmies