Skip to content

Commit

Permalink
Merge pull request #89 from kirillgarbar/io
Browse files Browse the repository at this point in the history
Benchmarks and IO fix
  • Loading branch information
gsvgit authored Nov 6, 2023
2 parents 099e787 + e6bae88 commit 8452ee6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 38 deletions.
4 changes: 2 additions & 2 deletions benchmarks/GraphBLAS-sharp.Benchmarks/Configs/Context.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NVIDIA*
AMD*
Gpu
32
64
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BFSBenchmark
BFSWithoutTransfer
4 changes: 2 additions & 2 deletions benchmarks/GraphBLAS-sharp.Benchmarks/Scripts/Benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

from dataclasses import dataclass

ROOT = pathlib.Path(__file__).parent.parent.parent.parent
BENCHMARKS = pathlib.Path(__file__).parent.parent
ROOT = pathlib.Path(__file__).resolve().parent.parent.parent.parent
BENCHMARKS = pathlib.Path(__file__).resolve().parent.parent
CONFIGS = BENCHMARKS / "Configs"
BINARIES = BENCHMARKS / "bin" / "Release" / "net7.0"
RESULTS = ROOT / "BenchmarkDotNet.Artifacts" / "results"
Expand Down
72 changes: 39 additions & 33 deletions src/GraphBLAS-sharp/IO/MtxReader.fs
Original file line number Diff line number Diff line change
Expand Up @@ -68,40 +68,46 @@ type MtxReader(pathToFile: string) =
let sortedData =
match this.Symmetry with
| General ->
[ 0 .. nnz - 1 ]
|> List.map (fun _ -> streamReader.ReadLine().Split(' '))
|> Array.ofList
|> Array.Parallel.map
(fun line ->
let i = int line.[0]
let j = int line.[1]

let v =
converter
<| if line.Length > 2 then line.[2] else ""

struct (pack i j, v))
|> Array.sortBy (fun struct (packedIndex, _) -> packedIndex)
let result =
[| 0 .. nnz - 1 |]
|> Array.map
(fun _ ->
let line = streamReader.ReadLine().Split(' ')

let i = int line.[0]
let j = int line.[1]

let v =
converter
<| if line.Length > 2 then line.[2] else ""

struct (pack i j, v))

Array.sortInPlaceBy (fun struct (packedIndex, _) -> packedIndex) result
result
| Symmetric ->
[ 0 .. nnz - 1 ]
|> List.map (fun _ -> streamReader.ReadLine().Split(' '))
|> Array.ofList
|> Array.Parallel.map
(fun line ->
let i = int line.[0]
let j = int line.[1]

let v =
converter
<| if line.Length > 2 then line.[2] else ""

if i = j then
[| struct (pack i j, v) |]
else
[| struct (pack i j, v)
struct (pack j i, v) |])
|> Array.concat
|> Array.sortBy (fun struct (packedIndex, _) -> packedIndex)
let result =
[| 0 .. nnz - 1 |]
|> Array.map
(fun _ ->
let line = streamReader.ReadLine().Split(' ')

let i = int line.[0]
let j = int line.[1]

let v =
converter
<| if line.Length > 2 then line.[2] else ""

if i = j then
[| struct (pack i j, v) |]
else
[| struct (pack i j, v)
struct (pack j i, v) |])
|> Array.concat

Array.sortInPlaceBy (fun struct (packedIndex, _) -> packedIndex) result
result
| _ ->
failwith
<| sprintf "This symmetry processing is not implemented: %A" this.Symmetry
Expand Down

0 comments on commit 8452ee6

Please sign in to comment.