【问题标题】:Use thrust to sort two OpenGL buffers using sort_by_key? [duplicate]使用推力使用 sort_by_key 对两个 OpenGL 缓冲区进行排序? [复制]
【发布时间】:2019-11-09 15:55:35
【问题描述】:

我有两个用无符号整数填充的 ShaderStorageBufferObjects。 我正在尝试使用推力按键对它们进行排序(这两个缓冲区配对在一起) 这就是我正在做的事情


    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);
}

我在编译器输出中得到了这个“thrust::detail::STATIC_ASSERTION_FAILURE”。

【问题讨论】:

  • This 可能感兴趣。请注意,该问题还链接到该问题的先前 linux 版本。

标签: c++ opengl cuda thrust


【解决方案1】:

我修正了它,一个愚蠢的错误。我将此文件编译为 c/c++ 文件而不是 CUDA 文件。这就是为什么推力给了我一个静态断言。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-28
    相关资源
    最近更新 更多