I am using a modified version of Sample6. After my trace (launch()) I want to find the max and min of a buffer I wrote to in my kernel. I want to use Thrust’s sort() function to accomplish this, but I keep on getting a compile error from Visual Studio 2012.
In my header file MeshViewer.h:
Buffer m_buffer;
In my source file in MeshViewer::initContext():
m_buffer = context->createBuffer( RT_BUFFER_INPUT_OUTPUT | RT_BUFFER_GPU_LOCAL, RT_FORMAT_FLOAT,
WIDTH, HEIGHT );
m_context["buffer"]->set( m_buffer );
During MeshViewer::trace():
context->launch();
reduceBuffer();
And in MeshViewer::reduceBuffer():
786 float *device_ptr = rtGetBDP<float*>(m_context, m_context["buffer"]->getBuffer()->get(), 0);
787 thrust::device_ptr<float> thrust_dev_ptr(device_ptr);
788 thrust::sort( thrust_dev_ptr, thrust_dev_ptr+(WIDTH*HEIGHT) );
Do I need to put this code in a .cu file or can I run it from my .cpp?
Compiler error:
c:\program files\nvidia gpu computing toolkit\cuda\v5.0\include\thrust\detail\backend\cuda\sort.inl(400): error C2027: use of undefined type ‘thrust::detail::STATIC_ASSERTION_FAILURE’
2> with
2> [
2> x=false
2> ]
2> c:\program files\nvidia gpu computing toolkit\cuda\v5.0\include\thrust\detail\backend\sort.inl(70) : see reference to function template instantiation ‘void thrust::detail::backend::cuda::stable_sort<RandomAccessIterator,StrictWeakOrdering>(RandomAccessIterator,RandomAccessIterator,StrictWeakOrdering)’ being compiled
2> with
2> [
2> RandomAccessIterator=thrust::device_ptr,
2> StrictWeakOrdering=thrust::less
2> ]
2> c:\program files\nvidia gpu computing toolkit\cuda\v5.0\include\thrust\detail\backend\sort.inl(158) : see reference to function template instantiation ‘void thrust::detail::backend::dispatch::stable_sort<RandomAccessIterator,StrictWeakOrdering>(RandomAccessIterator,RandomAccessIterator,StrictWeakOrdering,thrust::detail::cuda_device_space_tag)’ being compiled
2> with
2> [
2> RandomAccessIterator=thrust::device_ptr,
2> StrictWeakOrdering=thrust::less
2> ]
2> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include\thrust/detail/backend/generic/sort.h(41) : see reference to function template instantiation ‘void thrust::detail::backend::stable_sort<RandomAccessIterator,StrictWeakOrdering>(RandomAccessIterator,RandomAccessIterator,StrictWeakOrdering)’ being compiled
2> with
2> [
2> RandomAccessIterator=thrust::device_ptr,
2> StrictWeakOrdering=thrust::less
2> ]
2> c:\program files\nvidia gpu computing toolkit\cuda\v5.0\include\thrust\detail\backend\sort.inl(48) : see reference to function template instantiation ‘void thrust::detail::backend::generic::sort<RandomAccessIterator,StrictWeakOrdering>(RandomAccessIterator,RandomAccessIterator,StrictWeakOrdering)’ being compiled
2> with
2> [
2> RandomAccessIterator=thrust::device_ptr,
2> StrictWeakOrdering=thrust::less
2> ]
2> c:\program files\nvidia gpu computing toolkit\cuda\v5.0\include\thrust\detail\backend\sort.inl(147) : see reference to function template instantiation ‘void thrust::detail::backend::dispatch::sort<RandomAccessIterator,StrictWeakOrdering,thrust::detail::cuda_device_space_tag>(RandomAccessIterator,RandomAccessIterator,StrictWeakOrdering,Backend)’ being compiled
2> with
2> [
2> RandomAccessIterator=thrust::device_ptr,
2> StrictWeakOrdering=thrust::less,
2> Backend=thrust::detail::cuda_device_space_tag
2> ]
2> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include\thrust/detail/sort.inl(52) : see reference to function template instantiation ‘void thrust::detail::backend::sort<RandomAccessIterator,StrictWeakOrdering>(RandomAccessIterator,RandomAccessIterator,StrictWeakOrdering)’ being compiled
2> with
2> [
2> RandomAccessIterator=thrust::device_ptr,
2> StrictWeakOrdering=thrust::less
2> ]
2> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include\thrust/detail/sort.inl(43) : see reference to function template instantiation ‘void thrust::sort<RandomAccessIterator,thrust::less>(RandomAccessIterator,RandomAccessIterator,StrictWeakOrdering)’ being compiled
2> with
2> [
2> RandomAccessIterator=thrust::device_ptr,
2> T=KeyType,
2> StrictWeakOrdering=thrust::less
2> ]
2> …..\sample6\MeshViewer.cpp(788) : see reference to function template instantiation ‘void thrust::sort<thrust::device_ptr>(RandomAccessIterator,RandomAccessIterator)’ being compiled
2> with
2> [
2> T=float,
2> RandomAccessIterator=thrust::device_ptr
2> ]
2>
2>Build FAILED