Skip to content
Snippets Groups Projects
Commit 8cfdde83 authored by Lukas Cejka's avatar Lukas Cejka Committed by Tomáš Oberhuber
Browse files

Removed HostBadAlloc. Uncommented benchmarks. Commented prints.

parent 7ed2bcae
No related branches found
No related tags found
1 merge request!45Matrices revision
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <TNL/Matrices/MatrixReader.h> #include <TNL/Matrices/MatrixReader.h>
using namespace TNL::Matrices; using namespace TNL::Matrices;
#include <TNL/Exceptions/HostBadAlloc.h>
#include "cusparseCSRMatrix.h" #include "cusparseCSRMatrix.h"
namespace TNL { namespace TNL {
...@@ -94,11 +92,11 @@ benchmarkSpMV( Benchmark & benchmark, ...@@ -94,11 +92,11 @@ benchmarkSpMV( Benchmark & benchmark,
{ {
if( ! MatrixReader< CSR_HostMatrix >::readMtxFile( inputFileName, CSRhostMatrix, verboseMR ) ) if( ! MatrixReader< CSR_HostMatrix >::readMtxFile( inputFileName, CSRhostMatrix, verboseMR ) )
{ {
throw Exceptions::HostBadAlloc(); throw std::bad_alloc();
return false; return false;
} }
} }
catch( Exceptions::HostBadAlloc e ) catch( std::bad_alloc e )
{ {
e.what(); e.what();
return false; return false;
...@@ -136,22 +134,22 @@ benchmarkSpMV( Benchmark & benchmark, ...@@ -136,22 +134,22 @@ benchmarkSpMV( Benchmark & benchmark,
{ {
if( ! MatrixReader< HostMatrix >::readMtxFile( inputFileName, hostMatrix, verboseMR ) ) if( ! MatrixReader< HostMatrix >::readMtxFile( inputFileName, hostMatrix, verboseMR ) )
{ {
throw Exceptions::HostBadAlloc(); throw std::bad_alloc();
return false; return false;
} }
} }
catch( Exceptions::HostBadAlloc e ) catch( std::bad_alloc e )
{ {
e.what(); e.what();
return false; return false;
} }
hostMatrix.print( std::cout ); // hostMatrix.print( std::cout );
std::cout << "\n\n\n\n===============VALUES:\n\n" << std::endl; // std::cout << "\n\n\n\n===============VALUES:\n\n" << std::endl;
hostMatrix.printValues(); // hostMatrix.printValues();
#ifdef COMMENT //#ifdef COMMENT
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
// FIXME: This doesn't work for Ad/BiEllpack, because // FIXME: This doesn't work for Ad/BiEllpack, because
// their cross-device assignment is not implemented yet // their cross-device assignment is not implemented yet
...@@ -293,7 +291,7 @@ benchmarkSpMV( Benchmark & benchmark, ...@@ -293,7 +291,7 @@ benchmarkSpMV( Benchmark & benchmark,
//#endif //#endif
#endif //#endif
std::cout << std::endl; std::cout << std::endl;
return true; return true;
} }
...@@ -307,10 +305,10 @@ benchmarkSpmvSynthetic( Benchmark & benchmark, ...@@ -307,10 +305,10 @@ benchmarkSpmvSynthetic( Benchmark & benchmark,
{ {
bool result = true; bool result = true;
// TODO: benchmark all formats from tnl-benchmark-spmv (different parameters of the base formats) // 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, Matrices::Ellpack >( benchmark, inputFileName, verboseMR );
// result |= benchmarkSpMV< Real, SlicedEllpack >( benchmark, inputFileName, verboseMR ); result |= benchmarkSpMV< Real, SlicedEllpack >( benchmark, inputFileName, verboseMR );
// result |= benchmarkSpMV< Real, Matrices::ChunkedEllpack >( benchmark, inputFileName, verboseMR ); result |= benchmarkSpMV< Real, Matrices::ChunkedEllpack >( benchmark, inputFileName, verboseMR );
// AdEllpack/BiEllpack doesn't have cross-device assignment ('= operator') implemented yet // AdEllpack/BiEllpack doesn't have cross-device assignment ('= operator') implemented yet
// result |= benchmarkSpMV< Real, Matrices::AdEllpack >( benchmark, inputFileName, verboseMR ); // result |= benchmarkSpMV< Real, Matrices::AdEllpack >( benchmark, inputFileName, verboseMR );
......
/***************************************************************************
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment