0

I have two ShaderStorageBufferObjects filled with unsigned integers. I'm trying to use thrust to sort these by keys (these two buffers pair together) Here is what I'm doing


    struct cudaGraphicsResource *cuda_keys, *cuda_values;
    thrust::device_ptr<uint> keys_device_ptr, values_device_ptr;


//CellIndexList and ParticleIndexList are my buffers and ID being their uint handle
cudaGraphicsGLRegisterBuffer(&cuda_keys, CellIndexList->GetID(), cudaGraphicsMapFlagsNone);
cudaGraphicsGLRegisterBuffer(&cuda_values, ParticleIndexList->GetID(), cudaGraphicsMapFlagsNone);


uint* keys_ptr, *values_ptr;
size_t keys_size, values_size;
{
//this code is being executed in a loop
    cudaGraphicsMapResources(1, &cuda_keys, 0);
    cudaGraphicsResourceGetMappedPointer((void **)&keys_ptr, &keys_size, cuda_keys);
    cudaGraphicsMapResources(1, &cuda_values,0);
    cudaGraphicsResourceGetMappedPointer((void**)&values_ptr, &values_size, cuda_values);

    keys_device_ptr = thrust::device_pointer_cast(keys_ptr);
    values_device_ptr = thrust::device_pointer_cast(values_ptr);

    thrust::sort_by_key(keys_device_ptr, keys_device_ptr + nParticles, values_device_ptr, thrust::less<uint>());

    cudaGraphicsUnmapResources(1, &cuda_keys, 0);
    cudaGraphicsUnmapResources(1, &cuda_values, 0);
}

I'm getting this "thrust::detail::STATIC_ASSERTION_FAILURE" in my compiler output.

Abbrima
  • 11
  • 1
  • 3
  • 1
    [This](https://stackoverflow.com/questions/25041436/sorting-pixels-from-opengl-using-cuda-and-thrust-windows-port-issues) may be of interest. Note that the question also links to the previous linux version of the question. – Robert Crovella Jun 27 '19 at 16:18

1 Answers1

-1

I fixed it, a stupid mistake. I was compiling this file as a c/c++ file instead of a CUDA file. That is why thrust was giving me a static assert.

Abbrima
  • 11
  • 1
  • 3