Can anyone please help me with how to use CUB library. I found out that it has a function that help me to radix sort on the basis of key value pair. But i am unable to use it even for a sample demo. so that later i can use it in my real project.
my requiremement for demo is:
unsigned int *h_keys = (unsigned int*)malloc(numElements*sizeof(unsigned int));
unsigned int *h_keysSorted = (unsigned int*)malloc(numElements*sizeof(unsigned int));
unsigned int *h_values = 0;
h_values = (unsigned int *)malloc(numElements*sizeof(unsigned int));
unsigned int *d_keys;
unsigned int *d_values;
cudaMalloc((void **)&d_keys, numElements*sizeof(unsigned int));
cudaMalloc((void **)&d_values, numElements*sizeof(unsigned int));
cudaMemset(d_keys,10, numElements*sizeof(unsigned int));
cudaMemset(d_values,2, numElements*sizeof(unsigned int));
for(int i=0; i < loopSize; ++i)
{
h_keys[i] = rand()%100;
h_values[i] = i;
}
cudaMemcpy(d_keys, h_keys, loopSize * sizeof(unsigned int), cudaMemcpyHostToDevice);
cudaMemcpy(d_values, h_values, loopSize * sizeof(unsigned int), cudaMemcpyHostToDevice);
radixsort.sort(d_keys, d_values, loopSize, keybits);
cudaMemcpy(h_keysSorted, d_keys, loopSize * sizeof(unsigned int), cudaMemcpyDeviceToHost);
cudaMemcpy(h_values, d_values, loopSize * sizeof(unsigned int), cudaMemcpyDeviceToHost);
std::cout<<std::endl<<"After Sorting.............."<<std::endl;
for(int i =0; i<50 ;i++)
{
std::cout<<"h_values["<<i<<"]="<<h_values[i]<<" "<<"h_keysSorted["<<i<<"]="<<h_keysSorted[i]<<std::endl;
}
Thank in advance. please help it anyone has used cub libaray before...
http://nvlabs.github.io/cub/[
^]