的數量和位置說我有鑰匙查找鍵出現的第一按鍵出現的通過CUDA推力
thrust::device_vector<int> keys(10);
keys[0] = 51; // ----->
keys[1] = 51;
keys[2] = 72; // ----->
keys[3] = 72;
keys[4] = 72;
keys[5] = 103; //----->
keys[6] = 103;
keys[7] = 504; // ------>
keys[8] = 504
keys[9] = 504 ;
我已經知道前手有在 這4
區別鍵值的矢量向量。我想填充兩個設備陣列 pidx[4]
和pnum[4]
。
pidx
所述陣列給我的每個不同鍵的在 鍵向量第一位置時,即標有在上面的代碼段---->
的位置。所以,在這個例子中,我應該有pidx[4] = {0, 2, 5, 7}
。pnum
數組給我每個鍵的出現次數。所以,在這個例子中,我應該有pnum[4] = {2, 3, 2, 3}
。
CUDA Thrust將如何執行上述操作?