Dear all;

I had got the cuda c code for quick sort, but there is a parameter named “depth”, what was meant by i

```
```

t, and what value i should set when i call the function??

**global** void cdp_simple_quicksort(unsigned int *data, int left, int right, int depth)

{

// If we’re too deep or there are few elements left, we use an insertion sort…

if (depth >= MAX_DEPTH || right - left <= INSERTION_SORT)

{

selection_sort(data, left, right);

return;

}

```
unsigned int *lptr = data + left;
unsigned int *rptr = data + right;
unsigned int pivot = data[(left + right) / 2];
// Do the partitioning.
while (lptr <= rptr)
{
// Find the next left- and right-hand values to swap
unsigned int lval = *lptr;
unsigned int rval = *rptr;
// Move the left pointer as long as the pointed element is smaller than the pivot.
while (lval < pivot)
{
lptr++;
lval = *lptr;
}
// Move the right pointer as long as the pointed element is larger than the pivot.
while (rval > pivot)
{
rptr--;
rval = *rptr;
}
// If the swap points are valid, do the swap!
if (lptr <= rptr)
{
*lptr++ = rval;
*rptr-- = lval;
}
}
// Now the recursive part
int nright = rptr - data;
int nleft = lptr - data;
// Launch a new block to sort the left part.
if (left < (rptr - data))
{
cudaStream_t s;
cudaStreamCreateWithFlags(&s, cudaStreamNonBlocking);
cdp_simple_quicksort << < 1, 1, 0, s >> >(data, left, nright, depth + 1);
cudaStreamDestroy(s);
}
// Launch a new block to sort the right part.
if ((lptr - data) < right)
{
cudaStream_t s1;
cudaStreamCreateWithFlags(&s1, cudaStreamNonBlocking);
cdp_simple_quicksort << < 1, 1, 0, s1 >> >(data, nleft, right, depth + 1);
cudaStreamDestroy(s1);
}
```

}

////////////////////////////////////////////////////////////////////////////////