Loading src/Benchmarks/Sorting/Measurer.h +2 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ #include "ReferenceAlgorithms/MancaQuicksort.h" #endif #include "ReferenceAlgorithms/CedermanQuicksort.h" #include "ReferenceAlgorithms/ThrustRadixsort.h" #include "ReferenceAlgorithms/NvidiaBitonicSort.h" #endif #include "timer.h" Loading src/Benchmarks/Sorting/ReferenceAlgorithms/NvidiaBitonicSort.h 0 → 100644 +16 −0 Original line number Diff line number Diff line #include <6_Advanced/sortingNetworks/bitonicSort.cu> #include <TNL/Containers/Array.h> struct NvidiaBitonicSort { static void sort( Containers::ArrayView< int, Devices::Cuda >& view ) { Array<int, Devices::Cuda> arr; arr = view; bitonicSort((unsigned *)view.getData(), (unsigned *)arr.getData(), (unsigned *)view.getData(), (unsigned *)arr.getData(), 1, arr.getSize(), 1); cudaDeviceSynchronize(); } }; src/Benchmarks/Sorting/ReferenceAlgorithms/ThrustRadixsort.h 0 → 100644 +13 −0 Original line number Diff line number Diff line #include <thrust/sort.h> #include <thrust/execution_policy.h> #include <TNL/Containers/Array.h> struct ThrustRadixsort { static void sort( Containers::ArrayView< int, Devices::Cuda >& view ) { thrust::sort(thrust::device, view.getData(), view.getData() + view.getSize()); cudaDeviceSynchronize(); } }; src/Benchmarks/Sorting/tnl-benchmark-sort.h +35 −26 Original line number Diff line number Diff line Loading @@ -85,38 +85,47 @@ int main(int argc, char *argv[]) { if(argc == 1) { std::cout << "STL sort on CPU ... " << std::endl; start< STLSort >( cout, "\t" ); #ifdef HAVE_CUDA std::cout << "Quicksort on GPU ... " << std::endl; start< Quicksort >(cout, "\t"); std::cout << "Bitonic sort on GPU ... " << std::endl; start< BitonicSort >( cout, "\t" ); #ifdef HAVE_CUDA #ifdef HAVE_CUDA_SAMPLES std::cout << "Manca quicksort on GPU ... " << std::endl; start< MancaQuicksort >( cout, "\t" ); std::cout << "Nvidia bitonic sort on GPU ... " << std::endl; start< NvidiaBitonicSort >( cout, "\t" ); #endif std::cout << "Cederman quicksort on GPU ... " << std::endl; start< CedermanQuicksort >( cout, "\t" ); std::cout << "Thrust radixsort on GPU ... " << std::endl; start< ThrustRadixsort >( cout, "\t" ); #endif std::cout << "STL sort on CPU ... " << std::endl; start< STLSort >( cout, "\t" ); } else { std::ofstream out(argv[1]); std::cout << "STL sort on CPU ... " << std::endl; start< STLSort >( out, "," ); #ifdef HAVE_CUDA std::cout << "Quicksort on GPU ... " << std::endl; start< Quicksort >(out, ","); std::cout << "Bitonic sort on GPU ... " << std::endl; start< BitonicSort >(out, ","); #ifdef HAVE_CUDA #ifdef HAVE_CUDA_SAMPLES std::cout << "Manca quicksort on GPU ... " << std::endl; start< MancaQuicksort >( out, "," ); std::cout << "Nvidia bitonic sort on GPU ... " << std::endl; start< NvidiaBitonicSort >( out, "," ); #endif std::cout << "Cederman quicksort on GPU ... " << std::endl; start< CedermanQuicksort >( out, "," ); std::cout << "Thrust radixsort on GPU ... " << std::endl; start< ThrustRadixsort >( out, "," ); #endif std::cout << "STL sort on CPU ... " << std::endl; start< STLSort >( out, "," ); } return 0; } Loading
src/Benchmarks/Sorting/Measurer.h +2 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ #include "ReferenceAlgorithms/MancaQuicksort.h" #endif #include "ReferenceAlgorithms/CedermanQuicksort.h" #include "ReferenceAlgorithms/ThrustRadixsort.h" #include "ReferenceAlgorithms/NvidiaBitonicSort.h" #endif #include "timer.h" Loading
src/Benchmarks/Sorting/ReferenceAlgorithms/NvidiaBitonicSort.h 0 → 100644 +16 −0 Original line number Diff line number Diff line #include <6_Advanced/sortingNetworks/bitonicSort.cu> #include <TNL/Containers/Array.h> struct NvidiaBitonicSort { static void sort( Containers::ArrayView< int, Devices::Cuda >& view ) { Array<int, Devices::Cuda> arr; arr = view; bitonicSort((unsigned *)view.getData(), (unsigned *)arr.getData(), (unsigned *)view.getData(), (unsigned *)arr.getData(), 1, arr.getSize(), 1); cudaDeviceSynchronize(); } };
src/Benchmarks/Sorting/ReferenceAlgorithms/ThrustRadixsort.h 0 → 100644 +13 −0 Original line number Diff line number Diff line #include <thrust/sort.h> #include <thrust/execution_policy.h> #include <TNL/Containers/Array.h> struct ThrustRadixsort { static void sort( Containers::ArrayView< int, Devices::Cuda >& view ) { thrust::sort(thrust::device, view.getData(), view.getData() + view.getSize()); cudaDeviceSynchronize(); } };
src/Benchmarks/Sorting/tnl-benchmark-sort.h +35 −26 Original line number Diff line number Diff line Loading @@ -85,38 +85,47 @@ int main(int argc, char *argv[]) { if(argc == 1) { std::cout << "STL sort on CPU ... " << std::endl; start< STLSort >( cout, "\t" ); #ifdef HAVE_CUDA std::cout << "Quicksort on GPU ... " << std::endl; start< Quicksort >(cout, "\t"); std::cout << "Bitonic sort on GPU ... " << std::endl; start< BitonicSort >( cout, "\t" ); #ifdef HAVE_CUDA #ifdef HAVE_CUDA_SAMPLES std::cout << "Manca quicksort on GPU ... " << std::endl; start< MancaQuicksort >( cout, "\t" ); std::cout << "Nvidia bitonic sort on GPU ... " << std::endl; start< NvidiaBitonicSort >( cout, "\t" ); #endif std::cout << "Cederman quicksort on GPU ... " << std::endl; start< CedermanQuicksort >( cout, "\t" ); std::cout << "Thrust radixsort on GPU ... " << std::endl; start< ThrustRadixsort >( cout, "\t" ); #endif std::cout << "STL sort on CPU ... " << std::endl; start< STLSort >( cout, "\t" ); } else { std::ofstream out(argv[1]); std::cout << "STL sort on CPU ... " << std::endl; start< STLSort >( out, "," ); #ifdef HAVE_CUDA std::cout << "Quicksort on GPU ... " << std::endl; start< Quicksort >(out, ","); std::cout << "Bitonic sort on GPU ... " << std::endl; start< BitonicSort >(out, ","); #ifdef HAVE_CUDA #ifdef HAVE_CUDA_SAMPLES std::cout << "Manca quicksort on GPU ... " << std::endl; start< MancaQuicksort >( out, "," ); std::cout << "Nvidia bitonic sort on GPU ... " << std::endl; start< NvidiaBitonicSort >( out, "," ); #endif std::cout << "Cederman quicksort on GPU ... " << std::endl; start< CedermanQuicksort >( out, "," ); std::cout << "Thrust radixsort on GPU ... " << std::endl; start< ThrustRadixsort >( out, "," ); #endif std::cout << "STL sort on CPU ... " << std::endl; start< STLSort >( out, "," ); } return 0; }