-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Benchmark trying to emulate cscmv with csrmv with T flag
- Loading branch information
Ranjan Anantharaman
committed
Oct 18, 2015
1 parent
bd2c652
commit c5c2913
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using FactCheck | ||
include("funk.jl") | ||
function benchmark(k) | ||
|
||
println("-------------- k = $k ------------") | ||
|
||
a = sprand(10^7, 10^7, k*1e-7) | ||
rowptr = map(x -> Int32(x), a.colptr) | ||
colval = map(x -> Int32(x), a.rowval) | ||
m = a.n | ||
n = a.m | ||
|
||
println("Time taken to transfer matrix to device:") | ||
@time ad = CudaSparseMatrixCSR(Float64, CudaArray(rowptr), CudaArray(colval), CudaArray(a.nzval), (m, n)) | ||
|
||
b = rand(10^7) | ||
println("Time taken to transfer vector: ") | ||
@time bd = CudaArray(b) | ||
|
||
println("Time taken for multiplication: ") | ||
@time cd = ad * bd | ||
|
||
println("Time taken to transfer back to host: ") | ||
@time c = to_host(cd) | ||
|
||
println("Time taken for multiplication on CPU") | ||
@time ch = a * b | ||
|
||
facts("Checking for correctness for k = $k") do | ||
@fact c => roughly(ch) | ||
end | ||
end | ||
|
||
function run_benchmark() | ||
for k = 1:9 | ||
benchmark(k) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using CUSPARSE, CUDArt | ||
|
||
import Base.* | ||
function *(a::CudaSparseMatrixCSR, b::CudaArray) | ||
CUSPARSE.csrmv('T', a, b, 'O') | ||
end |