同じサイズの配列があります(要素3
よりも多い)。300.000
浮動小数点数の 1 つの配列とインデックスの 2 つの配列。したがって、番号ごとに2
IDがあります。
すべての3
配列は既に GPU グローバル メモリにあります。それに応じて、すべての番号を ID で並べ替えたいと思います。
Thrust ライブラリを使用してこのタスクを実行する方法はありますか? Thrustライブラリよりも良い方法はありますか?
もちろん、私はそれらをホスト メモリとの間で何度もコピーしたくありません。ちなみに、これらはベクトルではなく配列です。
事前にご協力いただきありがとうございます。
暫定的な解決策ですが、これは非常に遅いです。ほぼ4
数秒かかり、配列サイズは次の順序です300000
thrust::device_ptr<float> keys(afterSum);
thrust::device_ptr<int> vals0(d_index);
thrust::device_ptr<int> vals1(blockId);
thrust::device_vector<int> sortedIndex(numElements);
thrust::device_vector<int> sortedBlockId(numElements);
thrust::counting_iterator<int> iter(0);
thrust::device_vector<int> indices(numElements);
thrust::copy(iter, iter + indices.size(), indices.begin());
thrust::sort_by_key(keys, keys + numElements , indices.begin());
thrust::gather(indices.begin(), indices.end(), vals0, sortedIndex.begin());
thrust::gather(indices.begin(), indices.end(), vals1, sortedBlockId.begin());
thrust::host_vector<int> h_sortedIndex=sortedIndex;
thrust::host_vector<int> h_sortedBlockId=sortedBlockId;