thrust::stable_sort_by_key报错
float *d_scores = 0;
cudaMalloc((void **) &d_scores, batchSize * scoresLength * sizeof(float));
... d_scores 存放值
int *d_scoresIndex = 0;
cudaMalloc((void **) &d_scoresIndex, batchSize * scoresLength * sizeof(int));
... d_scoresIndex 存放值
thrust::device_ptr<float> thrust_d_scores(d_scores);
thrust::device_ptr<int> thrust_d_scoresIndex(d_scoresIndex);
for (int i = 0; i < batchSize; ++i)
{
std::cout << "for trust i:" << i << std::endl;
thrust::stable_sort_by_key(thrust_d_scores + i * scoresLength,
thrust_d_scores + i * scoresLength + scoresLength,
thrust_d_scoresIndex + i * scoresLength,
thrust::greater<float>());
}
运行报错:
terminate called after throwing an instance of 'thrust::system::system_error'
what(): radix_sort: failed to get memory buffer: invalid configuration argument
Aborted (core dumped)
请问代码有什么问题呢?