Skip to content

Commit 8452ee6

Browse files
authored
Merge pull request #89 from kirillgarbar/io
Benchmarks and IO fix
2 parents 099e787 + e6bae88 commit 8452ee6

File tree

4 files changed

+44
-38
lines changed

4 files changed

+44
-38
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
NVIDIA*
1+
AMD*
22
Gpu
3-
32
3+
64
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BFSBenchmark
1+
BFSWithoutTransfer

benchmarks/GraphBLAS-sharp.Benchmarks/Scripts/Benchmark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
from dataclasses import dataclass
99

10-
ROOT = pathlib.Path(__file__).parent.parent.parent.parent
11-
BENCHMARKS = pathlib.Path(__file__).parent.parent
10+
ROOT = pathlib.Path(__file__).resolve().parent.parent.parent.parent
11+
BENCHMARKS = pathlib.Path(__file__).resolve().parent.parent
1212
CONFIGS = BENCHMARKS / "Configs"
1313
BINARIES = BENCHMARKS / "bin" / "Release" / "net7.0"
1414
RESULTS = ROOT / "BenchmarkDotNet.Artifacts" / "results"

src/GraphBLAS-sharp/IO/MtxReader.fs

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,40 +68,46 @@ type MtxReader(pathToFile: string) =
6868
let sortedData =
6969
match this.Symmetry with
7070
| General ->
71-
[ 0 .. nnz - 1 ]
72-
|> List.map (fun _ -> streamReader.ReadLine().Split(' '))
73-
|> Array.ofList
74-
|> Array.Parallel.map
75-
(fun line ->
76-
let i = int line.[0]
77-
let j = int line.[1]
78-
79-
let v =
80-
converter
81-
<| if line.Length > 2 then line.[2] else ""
82-
83-
struct (pack i j, v))
84-
|> Array.sortBy (fun struct (packedIndex, _) -> packedIndex)
71+
let result =
72+
[| 0 .. nnz - 1 |]
73+
|> Array.map
74+
(fun _ ->
75+
let line = streamReader.ReadLine().Split(' ')
76+
77+
let i = int line.[0]
78+
let j = int line.[1]
79+
80+
let v =
81+
converter
82+
<| if line.Length > 2 then line.[2] else ""
83+
84+
struct (pack i j, v))
85+
86+
Array.sortInPlaceBy (fun struct (packedIndex, _) -> packedIndex) result
87+
result
8588
| Symmetric ->
86-
[ 0 .. nnz - 1 ]
87-
|> List.map (fun _ -> streamReader.ReadLine().Split(' '))
88-
|> Array.ofList
89-
|> Array.Parallel.map
90-
(fun line ->
91-
let i = int line.[0]
92-
let j = int line.[1]
93-
94-
let v =
95-
converter
96-
<| if line.Length > 2 then line.[2] else ""
97-
98-
if i = j then
99-
[| struct (pack i j, v) |]
100-
else
101-
[| struct (pack i j, v)
102-
struct (pack j i, v) |])
103-
|> Array.concat
104-
|> Array.sortBy (fun struct (packedIndex, _) -> packedIndex)
89+
let result =
90+
[| 0 .. nnz - 1 |]
91+
|> Array.map
92+
(fun _ ->
93+
let line = streamReader.ReadLine().Split(' ')
94+
95+
let i = int line.[0]
96+
let j = int line.[1]
97+
98+
let v =
99+
converter
100+
<| if line.Length > 2 then line.[2] else ""
101+
102+
if i = j then
103+
[| struct (pack i j, v) |]
104+
else
105+
[| struct (pack i j, v)
106+
struct (pack j i, v) |])
107+
|> Array.concat
108+
109+
Array.sortInPlaceBy (fun struct (packedIndex, _) -> packedIndex) result
110+
result
105111
| _ ->
106112
failwith
107113
<| sprintf "This symmetry processing is not implemented: %A" this.Symmetry

0 commit comments

Comments
 (0)