Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
51884a04
There was an error fetching the commit references. Please try again later.
Commit
51884a04
authored
5 years ago
by
Tomáš Oberhuber
Committed by
Tomáš Oberhuber
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Debuging SpMV benchmark.
parent
93c68aef
No related branches found
No related tags found
1 merge request
!48
Segments
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Benchmarks/SpMV/spmv.h
+48
-38
48 additions, 38 deletions
src/Benchmarks/SpMV/spmv.h
src/Benchmarks/SpMV/tnl-benchmark-spmv.h
+5
-5
5 additions, 5 deletions
src/Benchmarks/SpMV/tnl-benchmark-spmv.h
with
53 additions
and
43 deletions
src/Benchmarks/SpMV/spmv.h
+
48
−
38
View file @
51884a04
...
...
@@ -25,6 +25,11 @@
#include
<TNL/Matrices/BiEllpack.h>
#include
<TNL/Matrices/MatrixReader.h>
#include
<TNL/Matrices/SparseMatrix.h>
#include
<TNL/Containers/Segments/CSR.h>
#include
<TNL/Containers/Segments/Ellpack.h>
#include
<TNL/Containers/Segments/SlicedEllpack.h>
using
namespace
TNL
::
Matrices
;
#include
"cusparseCSRMatrix.h"
...
...
@@ -36,6 +41,22 @@ namespace Benchmarks {
template
<
typename
Real
,
typename
Device
,
typename
Index
>
using
SlicedEllpackAlias
=
Matrices
::
SlicedEllpack
<
Real
,
Device
,
Index
>
;
// Segments based sparse matrix aliases
template
<
typename
Real
,
typename
Device
,
typename
Index
>
using
SparseMatrix_CSR
=
Matrices
::
SparseMatrix
<
Real
,
Containers
::
Segments
::
CSR
,
Device
,
Index
>
;
template
<
typename
Device
,
typename
Index
>
using
EllpackSegments
=
Containers
::
Segments
::
Ellpack
<
Device
,
Index
>
;
template
<
typename
Real
,
typename
Device
,
typename
Index
>
using
SparseMatrix_Ellpack
=
Matrices
::
SparseMatrix
<
Real
,
EllpackSegments
,
Device
,
Index
>
;
template
<
typename
Device
,
typename
Index
>
using
SlicedEllpackSegments
=
Containers
::
Segments
::
SlicedEllpack
<
Device
,
Index
>
;
template
<
typename
Real
,
typename
Device
,
typename
Index
>
using
SparseMatrix_SlicedEllpack
=
Matrices
::
SparseMatrix
<
Real
,
SlicedEllpackSegments
,
Device
,
Index
>
;
// Get the name (with extension) of input matrix file
std
::
string
getMatrixFileName
(
const
String
&
InputFileName
)
{
...
...
@@ -85,7 +106,7 @@ void printMatrixInfo( const Matrix& matrix,
template
<
typename
Real
,
template
<
typename
,
typename
,
typename
>
class
Matrix
,
template
<
typename
,
typename
,
typename
,
typename
>
class
Vector
=
Containers
::
Vector
>
bool
void
benchmarkSpMV
(
Benchmark
&
benchmark
,
const
String
&
inputFileName
,
bool
verboseMR
)
...
...
@@ -98,19 +119,10 @@ benchmarkSpMV( Benchmark& benchmark,
CSR_DeviceMatrix
CSRdeviceMatrix
;
// Read the matrix for CSR, to set up cuSPARSE
try
{
if
(
!
MatrixReader
<
CSR_HostMatrix
>::
readMtxFile
(
inputFileName
,
CSRhostMatrix
,
verboseMR
)
)
{
throw
std
::
bad_alloc
();
return
false
;
}
}
catch
(
std
::
bad_alloc
&
e
)
{
e
.
what
();
return
false
;
}
if
(
!
MatrixReader
<
CSR_HostMatrix
>::
readMtxFile
(
inputFileName
,
CSRhostMatrix
,
verboseMR
)
)
{
throw
std
::
bad_alloc
();
}
#ifdef HAVE_CUDA
// cuSPARSE handle setup
...
...
@@ -140,19 +152,10 @@ benchmarkSpMV( Benchmark& benchmark,
CudaVector
deviceVector
,
deviceVector2
;
// Load the format
try
{
if
(
!
MatrixReader
<
HostMatrix
>::
readMtxFile
(
inputFileName
,
hostMatrix
,
verboseMR
)
)
{
throw
std
::
bad_alloc
();
return
false
;
}
}
catch
(
std
::
bad_alloc
&
e
)
{
e
.
what
();
return
false
;
}
if
(
!
MatrixReader
<
HostMatrix
>::
readMtxFile
(
inputFileName
,
hostMatrix
,
verboseMR
)
)
{
throw
std
::
bad_alloc
();
}
// Setup MetaData here (not in tnl-benchmark-spmv.h, as done in Benchmarks/BLAS),
...
...
@@ -244,7 +247,7 @@ benchmarkSpMV( Benchmark& benchmark,
resultcuSPARSEDeviceVector2
=
deviceVector2
;
// Difference between GPU (curent format) and GPU-cuSPARSE results
// Difference between GPU (cur
r
ent format) and GPU-cuSPARSE results
//Real cuSparseDifferenceAbsMax = resultDeviceVector2.differenceAbsMax( resultcuSPARSEDeviceVector2 );
Real
cuSparseDifferenceAbsMax
=
max
(
abs
(
resultDeviceVector2
-
resultcuSPARSEDeviceVector2
)
);
//Real cuSparseDifferenceLpNorm = resultDeviceVector2.differenceLpNorm( resultcuSPARSEDeviceVector2, 1 );
...
...
@@ -279,26 +282,33 @@ benchmarkSpMV( Benchmark& benchmark,
#endif
std
::
cout
<<
std
::
endl
;
return
true
;
}
template
<
typename
Real
=
double
,
typename
Index
=
int
>
bool
void
benchmarkSpmvSynthetic
(
Benchmark
&
benchmark
,
const
String
&
inputFileName
,
bool
verboseMR
)
{
bool
result
=
true
;
result
|=
benchmarkSpMV
<
Real
,
Matrices
::
CSR
>
(
benchmark
,
inputFileName
,
verboseMR
);
result
|=
benchmarkSpMV
<
Real
,
Matrices
::
Ellpack
>
(
benchmark
,
inputFileName
,
verboseMR
);
result
|=
benchmarkSpMV
<
Real
,
SlicedEllpackAlias
>
(
benchmark
,
inputFileName
,
verboseMR
);
result
|=
benchmarkSpMV
<
Real
,
Matrices
::
ChunkedEllpack
>
(
benchmark
,
inputFileName
,
verboseMR
);
benchmarkSpMV
<
Real
,
Matrices
::
CSR
>
(
benchmark
,
inputFileName
,
verboseMR
);
benchmarkSpMV
<
Real
,
Matrices
::
Ellpack
>
(
benchmark
,
inputFileName
,
verboseMR
);
benchmarkSpMV
<
Real
,
SlicedEllpackAlias
>
(
benchmark
,
inputFileName
,
verboseMR
);
benchmarkSpMV
<
Real
,
Matrices
::
ChunkedEllpack
>
(
benchmark
,
inputFileName
,
verboseMR
);
////
// Segments based sparse matrices
std
::
cerr
<<
"*********************************"
<<
std
::
endl
;
benchmarkSpMV
<
Real
,
SparseMatrix_CSR
>
(
benchmark
,
inputFileName
,
verboseMR
);
std
::
cerr
<<
"*********************************"
<<
std
::
endl
;
benchmarkSpMV
<
Real
,
SparseMatrix_Ellpack
>
(
benchmark
,
inputFileName
,
verboseMR
);
std
::
cerr
<<
"*********************************"
<<
std
::
endl
;
benchmarkSpMV
<
Real
,
SparseMatrix_SlicedEllpack
>
(
benchmark
,
inputFileName
,
verboseMR
);
std
::
cerr
<<
"*********************************"
<<
std
::
endl
;
// AdEllpack is broken
// result |= benchmarkSpMV< Real, Matrices::AdEllpack >( benchmark, inputFileName, verboseMR );
result
|=
benchmarkSpMV
<
Real
,
Matrices
::
BiEllpack
>
(
benchmark
,
inputFileName
,
verboseMR
);
return
result
;
// benchmarkSpMV< Real, Matrices::AdEllpack >( benchmark, inputFileName, verboseMR );
benchmarkSpMV
<
Real
,
Matrices
::
BiEllpack
>
(
benchmark
,
inputFileName
,
verboseMR
);
}
}
// namespace Benchmarks
...
...
This diff is collapsed.
Click to expand it.
src/Benchmarks/SpMV/tnl-benchmark-spmv.h
+
5
−
5
View file @
51884a04
...
...
@@ -96,11 +96,11 @@ main( int argc, char* argv[] )
// * The guide on what parameters to use prints twice.
// FIXME: When ./tnl-benchmark-spmv-dbg is called with '--help':
// * The guide on what parameter to use print once.
//
But then it CRASHES due to segfault:
//
The program attempts to get unknown parameter openmp-enabled
//
Aborting the program.
//
terminate called after throwing an instance of 'int'
//
[1] 17156 abort (core dumped) ~/tnl-dev/Debug/bin/./tnl-benchmark-spmv-dbg --help
// But then it CRASHES due to segfault:
//
The program attempts to get unknown parameter openmp-enabled
//
Aborting the program.
//
terminate called after throwing an instance of 'int'
//
[1] 17156 abort (core dumped) ~/tnl-dev/Debug/bin/./tnl-benchmark-spmv-dbg --help
if
(
!
parseCommandLine
(
argc
,
argv
,
conf_desc
,
parameters
)
)
{
conf_desc
.
printUsage
(
argv
[
0
]
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment