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
0c6f26e5
There was an error fetching the commit references. Please try again later.
Commit
0c6f26e5
authored
10 years ago
by
Tomáš Oberhuber
Browse files
Options
Downloads
Patches
Plain Diff
Programming SPMV benchmark.
parent
8b80f8f3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/benchmarks/tnl-benchmark-spmv.h
+105
-50
105 additions, 50 deletions
tests/benchmarks/tnl-benchmark-spmv.h
with
105 additions
and
50 deletions
tests/benchmarks/tnl-benchmark-spmv.h
+
105
−
50
View file @
0c6f26e5
...
...
@@ -130,14 +130,14 @@ double computeThroughput( const long int nonzeroElements,
template
<
typename
Matrix
,
typename
Vector
>
void
benchmark
Host
Matrix
(
const
Matrix
&
matrix
,
const
Vector
&
x
,
Vector
&
b
,
const
long
int
nonzeroElements
,
const
char
*
format
,
const
double
&
stopTime
,
int
verbose
,
fstream
&
logFile
)
void
benchmarkMatrix
(
const
Matrix
&
matrix
,
const
Vector
&
x
,
Vector
&
b
,
const
long
int
nonzeroElements
,
const
char
*
format
,
const
double
&
stopTime
,
int
verbose
,
fstream
&
logFile
)
{
tnlTimerRT
timer
;
timer
.
Reset
();
...
...
@@ -160,6 +160,12 @@ void benchmarkHostMatrix( const Matrix& matrix,
logFile
<<
" "
<<
throughput
<<
endl
;
}
void
writeTestFailed
(
fstream
&
logFile
)
{
logFile
<<
"N/A"
<<
endl
;
logFile
<<
"N/A"
<<
endl
;
}
template
<
typename
Real
>
bool
setupBenchmark
(
const
tnlParameterContainer
&
parameters
)
{
...
...
@@ -213,27 +219,27 @@ bool setupBenchmark( const tnlParameterContainer& parameters )
rowLengthsCuda
.
setSize
(
csrMatrix
.
getRows
()
);
rowLengthsCuda
=
rowLengthsHost
;
#endif
benchmark
Host
Matrix
(
csrMatrix
,
hostX
,
hostB
,
nonzeroElements
,
"CSR Host"
,
stopTime
,
verbose
,
logFile
);
benchmarkMatrix
(
csrMatrix
,
hostX
,
hostB
,
nonzeroElements
,
"CSR Host"
,
stopTime
,
verbose
,
logFile
);
//csrMatrix.reset();
typedef
tnlEllpackMatrix
<
Real
,
tnlHost
,
int
>
EllpackMatrixType
;
EllpackMatrixType
ellpackMatrix
;
ellpackMatrix
.
copyFrom
(
csrMatrix
,
rowLengthsHost
);
benchmark
Host
Matrix
(
ellpackMatrix
,
hostX
,
hostB
,
nonzeroElements
,
"Ellpack Host"
,
stopTime
,
verbose
,
logFile
);
benchmarkMatrix
(
ellpackMatrix
,
hostX
,
hostB
,
nonzeroElements
,
"Ellpack Host"
,
stopTime
,
verbose
,
logFile
);
#ifdef HAVE_CUDA
typedef
tnlEllpackMatrix
<
Real
,
tnlCuda
,
int
>
EllpackMatrixCudaType
;
EllpackMatrixCudaType
cudaEllpackMatrix
;
...
...
@@ -241,17 +247,20 @@ bool setupBenchmark( const tnlParameterContainer& parameters )
if
(
!
cudaEllpackMatrix
.
copyFrom
(
ellpackMatrix
,
rowLengthsCuda
)
)
{
cerr
<<
"I am not able to transfer the matrix on GPU."
<<
endl
;
return
false
;
writeTestFailed
(
logFile
);
}
else
{
cout
<<
" done."
<<
endl
;
benchmarkMatrix
(
cudaEllpackMatrix
,
cudaX
,
cudaB
,
nonzeroElements
,
"Ellpack Cuda"
,
stopTime
,
verbose
,
logFile
);
}
cout
<<
" done."
<<
endl
;
benchmarkHostMatrix
(
cudaEllpackMatrix
,
cudaX
,
cudaB
,
nonzeroElements
,
"Ellpack Cuda"
,
stopTime
,
verbose
,
logFile
);
cudaEllpackMatrix
.
reset
();
#endif
ellpackMatrix
.
reset
();
...
...
@@ -259,27 +268,73 @@ bool setupBenchmark( const tnlParameterContainer& parameters )
typedef
tnlSlicedEllpackMatrix
<
Real
,
tnlHost
,
int
>
SlicedEllpackMatrixType
;
SlicedEllpackMatrixType
slicedEllpackMatrix
;
slicedEllpackMatrix
.
copyFrom
(
csrMatrix
,
rowLengthsHost
);
benchmarkHostMatrix
(
slicedEllpackMatrix
,
hostX
,
hostB
,
nonzeroElements
,
"SlicedEllpack Host"
,
stopTime
,
verbose
,
logFile
);
benchmarkMatrix
(
slicedEllpackMatrix
,
hostX
,
hostB
,
nonzeroElements
,
"SlicedEllpack Host"
,
stopTime
,
verbose
,
logFile
);
#ifdef HAVE_CUDA
typedef
tnlSlicedEllpackMatrix
<
Real
,
tnlCuda
,
int
>
SlicedEllpackMatrixCudaType
;
SlicedEllpackMatrixCudaType
cudaSlicedEllpackMatrix
;
cout
<<
"Copying matrix to GPU... "
;
if
(
!
cudaSlicedEllpackMatrix
.
copyFrom
(
slicedEllpackMatrix
,
rowLengthsCuda
)
)
{
cerr
<<
"I am not able to transfer the matrix on GPU."
<<
endl
;
writeTestFailed
(
logFile
);
}
else
{
cout
<<
" done."
<<
endl
;
benchmarkMatrix
(
cudaSlicedEllpackMatrix
,
cudaX
,
cudaB
,
nonzeroElements
,
"SlicedEllpack Cuda"
,
stopTime
,
verbose
,
logFile
);
}
cudaSlicedEllpackMatrix
.
reset
();
#endif
slicedEllpackMatrix
.
reset
();
typedef
tnlChunkedEllpackMatrix
<
Real
,
tnlHost
,
int
>
ChunkedEllpackMatrixType
;
ChunkedEllpackMatrixType
chunkedEllpackMatrix
;
chunkedEllpackMatrix
.
copyFrom
(
csrMatrix
,
rowLengthsHost
);
benchmarkHostMatrix
(
chunkedEllpackMatrix
,
hostX
,
hostB
,
nonzeroElements
,
"ChunkedEllpack Host"
,
stopTime
,
verbose
,
logFile
);
benchmarkMatrix
(
chunkedEllpackMatrix
,
hostX
,
hostB
,
nonzeroElements
,
"ChunkedEllpack Host"
,
stopTime
,
verbose
,
logFile
);
#ifdef HAVE_CUDA
typedef
tnlChunkedEllpackMatrix
<
Real
,
tnlCuda
,
int
>
ChunkedEllpackMatrixCudaType
;
ChunkedEllpackMatrixCudaType
cudaChunkedEllpackMatrix
;
cout
<<
"Copying matrix to GPU... "
;
if
(
!
cudaChunkedEllpackMatrix
.
copyFrom
(
chunkedEllpackMatrix
,
rowLengthsCuda
)
)
{
cerr
<<
"I am not able to transfer the matrix on GPU."
<<
endl
;
writeTestFailed
(
logFile
);
}
else
{
cout
<<
" done."
<<
endl
;
benchmarkMatrix
(
cudaChunkedEllpackMatrix
,
cudaX
,
cudaB
,
nonzeroElements
,
"ChunkedEllpack Cuda"
,
stopTime
,
verbose
,
logFile
);
}
cudaChunkedEllpackMatrix
.
reset
();
#endif
chunkedEllpackMatrix
.
reset
();
}
}
...
...
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