Thrust and CUDA 2.3a problem

everything is updated to the new version.

CUDA toolkit 2.3.a
CUDA DRiver 2.3.1a
on Snow Leopard:

I have problem with thrust:

I got this error on all examples using thrust:

/usr/include/c++/4.2.1/ext/atomicity.h(51): error: identifier “__sync_fetch_and_add” is undefined

/usr/include/c++/4.2.1/ext/atomicity.h(55): error: identifier “__sync_fetch_and_add” is undefined

2 errors detected in the compilation of “/tmp/tmpxft_00002fed_00000000-4_version.cpp1.ii”.

If I use the old gcc (g++) 4.0.1 than everything is fine…

For the examples in the SDK I had to modify the common.mk to use -m32, otherwise all compiled and working…
So my question is: What is the problem with thrust?

Any help, or just wait for the new release?

Thanks,

TRS

Thanks for bringing this to our attention. This is probably some incompatibility with gcc-4.2 + nvcc 2.3a that we can work around. We’re looking into it.

Thrust v1.1 should now work with CUDA 2.3a & Snow Leopard. Please let us know if you have any further difficulty.

What was your workaround there. I’m getting the same error “__sync_add” message when try to compile a mix of .cpp and .cu files using FindCUDA on the release candidate three of cmake. I’m using fedora 11 with gcc 4.4.1. Cheers

Use this incantation before any standard headers get included:

#if defined(__APPLE__)

#if _GLIBCXX_ATOMIC_BUILTINS == 1

#undef _GLIBCXX_ATOMIC_BUILTINS

#endif // _GLIBCXX_ATOMIC_BUILTINS

#endif // __APPLE__

I want to use reduce from thrust and made this code

device_vector<float> Y1(3*iH*iW,0);

int sum;

sum = thrust::reduce(Y1.begin(), Y1.end(), (float) 0, thrust::plus<float>());

and encountered error in lint of reduce function while linking.

In function `float thrust::detail::device::detail::reduce_device<thrust::detail::normal_iterator<thrust::device_ptr<float> >, float, thrust::plus<float> >(thrust::detail::normal_iterator<thrust::device_ptr<float> >, thrust::detail::normal_iterator<thrust::device_ptr<float> >, float, thrust::plus<float>, thrust::detail::integral_constant<bool, false>)':

main.cpp:(.text._ZN6thrust6detail6device6detail13reduce_deviceINS0

_15normal_iteratorINS_10device_ptrIfEEEEfNS_4plusIfEEEET0_T_S

B_SA_T1_NS0_17integral_constantIbLb0EEE[float thrust::detail::device::detail::reduce_device<thrust::detail::normal_iterator<thrust::device_ptr<float> >, float, thrust::plus<float> >(thrust::detail::normal_iterator<thrust::device_ptr<float> >, thrust::detail::normal_iterator<thrust::device_ptr<float> >, float, thrust::plus<float>, thrust::detail::integral_constant<bool, false>)]+0x6b): undefined reference to `float thrust::detail::device::cuda::reduce<thrust::detail::device::detail::reduce_functor<thrust::detail::normal_iterator<thrust::device_ptr<float> >, float>, float, thrust::plus<float> >(thrust::detail::device::detail::reduce_functor<thrust::detail::normal_iterator<thrust::device_ptr<float> >, float>, unsigned int, float, thrust::plus<float>)'

I use Eclipse to edit, CUDA 2.3 and findCUDA for CUDA, all headers of thrust folder are included

Rename your source to main.cu and compile with nvcc.