File: stable_sort_large.cu

package info (click to toggle)
cccl 2.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 89,900 kB
  • sloc: cpp: 697,664; ansic: 26,964; python: 11,928; sh: 3,284; asm: 2,154; perl: 460; makefile: 112; xml: 13
file content (32 lines) | stat: -rw-r--r-- 878 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <unittest/unittest.h>
#include <thrust/sort.h>
#include <thrust/functional.h>


template <typename T, unsigned int N>
void _TestStableSortWithLargeKeys(void)
{
    size_t n = (128 * 1024) / sizeof(FixedVector<T,N>);

    thrust::host_vector< FixedVector<T,N> > h_keys(n);

    for(size_t i = 0; i < n; i++)
        // XXX Use proper random number generation facility.
        h_keys[i] = FixedVector<T,N>(rand());

    thrust::device_vector< FixedVector<T,N> > d_keys = h_keys;
    
    thrust::stable_sort(h_keys.begin(), h_keys.end());
    thrust::stable_sort(d_keys.begin(), d_keys.end());

    ASSERT_EQUAL_QUIET(h_keys, d_keys);
}

void TestStableSortWithLargeKeys(void)
{
    _TestStableSortWithLargeKeys<int,    2>();
    _TestStableSortWithLargeKeys<int,   17>();
    _TestStableSortWithLargeKeys<int,  128>();
}
DECLARE_UNITTEST(TestStableSortWithLargeKeys);