Skip to content
Snippets Groups Projects
Commit 62ca0c97 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added benchmarks for array operations using different host allocators

parent 0982605f
No related branches found
No related tags found
1 merge request!33Allocators
......@@ -20,14 +20,15 @@ namespace TNL {
namespace Benchmarks {
template< typename Real = double,
typename Index = int >
typename Index = int,
template<typename> class HostAllocator = Allocators::Default< Devices::Host >::Allocator,
template<typename> class CudaAllocator = Allocators::Default< Devices::Cuda >::Allocator >
bool
benchmarkArrayOperations( Benchmark & benchmark,
const long & size )
{
typedef Containers::Array< Real, Devices::Host, Index > HostArray;
typedef Containers::Array< Real, Devices::Cuda, Index > CudaArray;
using namespace std;
using HostArray = Containers::Array< Real, Devices::Host, Index, HostAllocator< Real > >;
using CudaArray = Containers::Array< Real, Devices::Cuda, Index, CudaAllocator< Real > >;
double datasetSize = (double) size * sizeof( Real ) / oneGB;
......
......@@ -12,6 +12,8 @@
#pragma once
#include <TNL/Allocators/CudaHost.h>
#include <TNL/Allocators/CudaManaged.h>
#include <TNL/Devices/Host.h>
#include <TNL/Devices/Cuda.h>
#include <TNL/Config/ConfigDescription.h>
......@@ -38,7 +40,7 @@ runBlasBenchmarks( Benchmark & benchmark,
metadata["precision"] = precision;
// Array operations
benchmark.newBenchmark( String("Array operations (") + precision + ")",
benchmark.newBenchmark( String("Array operations (") + precision + ", host allocator = Host)",
metadata );
for( std::size_t size = minSize; size <= maxSize; size *= 2 ) {
benchmark.setMetadataColumns( Benchmark::MetadataColumns({
......@@ -46,6 +48,24 @@ runBlasBenchmarks( Benchmark & benchmark,
} ));
benchmarkArrayOperations< Real >( benchmark, size );
}
#ifdef HAVE_CUDA
benchmark.newBenchmark( String("Array operations (") + precision + ", host allocator = CudaHost)",
metadata );
for( std::size_t size = minSize; size <= maxSize; size *= 2 ) {
benchmark.setMetadataColumns( Benchmark::MetadataColumns({
{ "size", convertToString( size ) },
} ));
benchmarkArrayOperations< Real, int, Allocators::CudaHost >( benchmark, size );
}
benchmark.newBenchmark( String("Array operations (") + precision + ", host allocator = CudaManaged)",
metadata );
for( std::size_t size = minSize; size <= maxSize; size *= 2 ) {
benchmark.setMetadataColumns( Benchmark::MetadataColumns({
{ "size", convertToString( size ) },
} ));
benchmarkArrayOperations< Real, int, Allocators::CudaManaged >( benchmark, size );
}
#endif
// Vector operations
benchmark.newBenchmark( String("Vector operations (") + precision + ")",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment