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
1a798c60
There was an error fetching the commit references. Please try again later.
Commit
1a798c60
authored
6 years ago
by
Lukas Cejka
Committed by
Tomáš Oberhuber
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added getMatrixFormat(). Implemented basic error writing into log files.
parent
b7d2952d
No related branches found
No related tags found
1 merge request
!45
Matrices revision
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Benchmarks/SpMV/spmv.h
+40
-10
40 additions, 10 deletions
src/Benchmarks/SpMV/spmv.h
with
40 additions
and
10 deletions
src/Benchmarks/SpMV/spmv.h
+
40
−
10
View file @
1a798c60
...
...
@@ -30,23 +30,27 @@ namespace Benchmarks {
template
<
typename
Real
,
typename
Device
,
typename
Index
>
using
SlicedEllpack
=
Matrices
::
SlicedEllpack
<
Real
,
Device
,
Index
>
;
// Get only the name of the format from getType().
template
<
typename
Matrix
>
void
printMatrixInfo
(
const
String
&
inputFileName
,
const
Matrix
&
matrix
,
std
::
ostream
&
str
)
std
::
string
getMatrixFormat
(
const
Matrix
&
matrix
)
{
// Get only the name of the format from getType().
std
::
string
mtrxFullType
=
matrix
.
getType
();
std
::
string
mtrxType
=
mtrxFullType
.
substr
(
0
,
mtrxFullType
.
find
(
"<"
));
std
::
string
type
=
mtrxType
.
substr
(
mtrxType
.
find
(
':'
)
+
2
);
std
::
string
format
=
mtrxType
.
substr
(
mtrxType
.
find
(
':'
)
+
2
);
str
<<
"
\n
Format: "
<<
type
<<
std
::
endl
;
return
format
;
}
template
<
typename
Matrix
>
void
printMatrixInfo
(
const
Matrix
&
matrix
,
std
::
ostream
&
str
)
{
str
<<
"
\n
Format: "
<<
getMatrixFormat
(
matrix
)
<<
std
::
endl
;
str
<<
" Rows: "
<<
matrix
.
getRows
()
<<
std
::
endl
;
str
<<
" Cols: "
<<
matrix
.
getColumns
()
<<
std
::
endl
;
str
<<
" Nonzero Elements: "
<<
matrix
.
getNumberOfNonzeroMatrixElements
()
<<
std
::
endl
;
}
// TODO: rename as benchmark_SpMV_synthetic and move to spmv-synthetic.h
template
<
typename
Real
,
template
<
typename
,
typename
,
typename
>
class
Matrix
,
template
<
typename
,
typename
,
typename
>
class
Vector
=
Containers
::
Vector
>
...
...
@@ -68,16 +72,39 @@ benchmarkSpMV( Benchmark & benchmark,
{
if
(
!
MatrixReader
<
HostMatrix
>::
readMtxFile
(
inputFileName
,
hostMatrix
)
)
{
std
::
cerr
<<
"I am not able to read the matrix file "
<<
inputFileName
<<
"."
<<
std
::
endl
;
std
::
cerr
<<
"Failed to read the matrix file "
<<
inputFileName
<<
"."
<<
std
::
endl
;
std
::
string
matrixFormat
=
getMatrixFormat
(
hostMatrix
);
std
::
string
stringErrorMsg
=
"Failed to read the matrix file "
+
(
std
::
string
)
inputFileName
+
".
\n
"
+
"matrix format: "
+
matrixFormat
+
"
\n
Benchmark failed: Unable to read the matrix."
;
char
*
errorMsg
=
&
stringErrorMsg
[
0u
];
benchmark
.
addErrorMessage
(
errorMsg
,
3
);
return
false
;
}
}
catch
(
std
::
bad_alloc
)
{
std
::
cerr
<<
"Not enough memory to read the matrix."
<<
std
::
endl
;
std
::
cerr
<<
"Failed to allocate memory to read the matrix file "
<<
inputFileName
<<
"."
<<
std
::
endl
;
std
::
string
matrixFormat
=
getMatrixFormat
(
hostMatrix
);
std
::
string
stringErrorMsg
=
"Failed to allocate memory to read the matrix file "
+
(
std
::
string
)
inputFileName
+
".
\n
"
+
"matrix format: "
+
matrixFormat
+
"
\n
Benchmark failed: Not enough memory."
;
char
*
errorMsg
=
&
stringErrorMsg
[
0u
];
benchmark
.
addErrorMessage
(
errorMsg
,
3
);
return
false
;
}
printMatrixInfo
(
inputFileName
,
hostMatrix
,
std
::
cout
);
// printMatrixInfo is redundant, because all the information is in the Benchmark's MetadataColumns.
// printMatrixInfo( hostMatrix, std::cout );
#ifdef HAVE_CUDA
// FIXME: This doesn't work for ChunkedEllpack, because
// its cross-device assignment is not implemented yet.
...
...
@@ -85,6 +112,8 @@ benchmarkSpMV( Benchmark & benchmark,
#endif
benchmark
.
setMetadataColumns
(
Benchmark
::
MetadataColumns
({
{
"matrix format"
,
convertToString
(
getMatrixFormat
(
hostMatrix
)
)
},
{
"non-zeros"
,
convertToString
(
hostMatrix
.
getNumberOfNonzeroMatrixElements
()
)
},
{
"rows"
,
convertToString
(
hostMatrix
.
getRows
()
)
},
{
"columns"
,
convertToString
(
hostMatrix
.
getColumns
()
)
}
}
));
...
...
@@ -124,6 +153,7 @@ benchmarkSpMV( Benchmark & benchmark,
#ifdef HAVE_CUDA
benchmark
.
time
<
Devices
::
Cuda
>
(
reset
,
"GPU"
,
spmvCuda
);
#endif
std
::
cout
<<
std
::
endl
;
return
true
;
}
...
...
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