我是新来的推力,但希望得到一个如何在并行排序情况。我有一个超大的gpu列表(1mil +),我试图将它们分类到各个cpu容器中,其中每个容器都有一个device_vector。这个想法是,我想将gpu列表分类到CPU容器拥有的各种device_vector中。如何使用推力和cuda将gpu数据排序到cpu对象所拥有的单独列表中?
class GpuObject
{
int someData;
int otherValue;
};
class CpuContainer
{
thrust::device_vector<GpuObject>* SortedGpuList;
};
for(int i = 0; i<100; i++)
{
Containers.push_back(new CpuContainer());
}
thrust::device_vector<GpuObject>* completeGpuList;
__device__ __host__
void sortIntoContainers(....)
{
// ... possible to sort completeGpuList into Containers[i].SortedGpuList based on GpuObject.someData ?
}
我的第一个尝试是要建立一个device_vector持有代表该容器一个给GpuObject将得到映射到(大小等于completeGpuList)一个int。然后我使用thrust :: transform与int()运算符的对象返回每个GpuObject的容器ID。在此之后,我使用新的containerIDList对原始gpuCompleteList中的键进行排序。但是如何在排序之后有效地复制所有条目而无需循环列表?
是的,这基本上是一个压缩的稀疏行格式。 CUSP库具有以推力构建的这个故事的GPU实现 – talonmies