From 8cfdde83814df4659da99f1dd1a56cd889556f47 Mon Sep 17 00:00:00 2001 From: Lukas Cejka <lukas.ostatek@gmail.com> Date: Sat, 19 Oct 2019 17:08:57 +0200 Subject: [PATCH] Removed HostBadAlloc. Uncommented benchmarks. Commented prints. --- src/Benchmarks/SpMV/spmv.h | 26 ++++++++++----------- src/TNL/Exceptions/HostBadAlloc.h | 39 ------------------------------- 2 files changed, 12 insertions(+), 53 deletions(-) delete mode 100644 src/TNL/Exceptions/HostBadAlloc.h diff --git a/src/Benchmarks/SpMV/spmv.h b/src/Benchmarks/SpMV/spmv.h index fa48bd811f..e66e770fb4 100644 --- a/src/Benchmarks/SpMV/spmv.h +++ b/src/Benchmarks/SpMV/spmv.h @@ -27,8 +27,6 @@ #include <TNL/Matrices/MatrixReader.h> using namespace TNL::Matrices; -#include <TNL/Exceptions/HostBadAlloc.h> - #include "cusparseCSRMatrix.h" namespace TNL { @@ -94,11 +92,11 @@ benchmarkSpMV( Benchmark & benchmark, { if( ! MatrixReader< CSR_HostMatrix >::readMtxFile( inputFileName, CSRhostMatrix, verboseMR ) ) { - throw Exceptions::HostBadAlloc(); + throw std::bad_alloc(); return false; } } - catch( Exceptions::HostBadAlloc e ) + catch( std::bad_alloc e ) { e.what(); return false; @@ -136,22 +134,22 @@ benchmarkSpMV( Benchmark & benchmark, { if( ! MatrixReader< HostMatrix >::readMtxFile( inputFileName, hostMatrix, verboseMR ) ) { - throw Exceptions::HostBadAlloc(); + throw std::bad_alloc(); return false; } } - catch( Exceptions::HostBadAlloc e ) + catch( std::bad_alloc e ) { e.what(); return false; } - hostMatrix.print( std::cout ); - std::cout << "\n\n\n\n===============VALUES:\n\n" << std::endl; +// hostMatrix.print( std::cout ); +// std::cout << "\n\n\n\n===============VALUES:\n\n" << std::endl; - hostMatrix.printValues(); +// hostMatrix.printValues(); -#ifdef COMMENT +//#ifdef COMMENT #ifdef HAVE_CUDA // FIXME: This doesn't work for Ad/BiEllpack, because // their cross-device assignment is not implemented yet @@ -293,7 +291,7 @@ benchmarkSpMV( Benchmark & benchmark, //#endif -#endif +//#endif std::cout << std::endl; return true; } @@ -307,10 +305,10 @@ benchmarkSpmvSynthetic( Benchmark & benchmark, { bool result = true; // TODO: benchmark all formats from tnl-benchmark-spmv (different parameters of the base formats) -// result |= benchmarkSpMV< Real, Matrices::CSR >( benchmark, inputFileName, verboseMR ); + result |= benchmarkSpMV< Real, Matrices::CSR >( benchmark, inputFileName, verboseMR ); // result |= benchmarkSpMV< Real, Matrices::Ellpack >( benchmark, inputFileName, verboseMR ); -// result |= benchmarkSpMV< Real, SlicedEllpack >( benchmark, inputFileName, verboseMR ); -// result |= benchmarkSpMV< Real, Matrices::ChunkedEllpack >( benchmark, inputFileName, verboseMR ); + result |= benchmarkSpMV< Real, SlicedEllpack >( benchmark, inputFileName, verboseMR ); + result |= benchmarkSpMV< Real, Matrices::ChunkedEllpack >( benchmark, inputFileName, verboseMR ); // AdEllpack/BiEllpack doesn't have cross-device assignment ('= operator') implemented yet // result |= benchmarkSpMV< Real, Matrices::AdEllpack >( benchmark, inputFileName, verboseMR ); diff --git a/src/TNL/Exceptions/HostBadAlloc.h b/src/TNL/Exceptions/HostBadAlloc.h deleted file mode 100644 index 2f0abeb05f..0000000000 --- a/src/TNL/Exceptions/HostBadAlloc.h +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - HostBadAlloc.h - description - ------------------- - begin : Apr 17, 2019 - copyright : (C) 2017 by Tomas Oberhuber et al. - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -// Implemented by: Lukas Cejka - -#pragma once - -#include <new> - -namespace TNL { -namespace Exceptions { - -struct HostBadAlloc - : public std::bad_alloc -{ - HostBadAlloc() - { - // Assert that there is enough space to store the values. -// TNL_ASSERT( Devices::SystemInfo::getFreeMemory() > Matrices::Matrix::getNumberOfMatrixElements() * sizeof( Matrices::Matrix::RealType ), ); - std::cerr << "terminate called after throwing an instance of 'TNL::Exceptions::HostBadAlloc'\n what(): " << what() << std::endl; - std::exit(1); - } - - const char* what() const throw() - { - return "Failed to allocate memory on the Host device: " - "most likely there is not enough space in the host memory."; - } -}; - -} // namespace Exceptions -} // namespace TNL -- GitLab