Skip to content

SpGeMM #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add: measure maxAllocSize
  • Loading branch information
IgorErin committed May 3, 2023
commit bae988eb483bdc50f77f41515a2dfa5e6308daf0
3 changes: 0 additions & 3 deletions src/GraphBLAS-sharp.Backend/Common/ClArray.fs
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,6 @@ module ClArray =
sourceArrays
|> Seq.sumBy (fun array -> array.Length)

if resultLength >= clContext.MaxMemAllocSize then
failwith "It is impossible to allocate more than MaxAllocSize"

let result =
clContext.CreateClArrayWithSpecificAllocationMode(allocationMode, resultLength)

Expand Down
11 changes: 10 additions & 1 deletion src/GraphBLAS-sharp.Backend/Matrix/Matrix.fs
Original file line number Diff line number Diff line change
Expand Up @@ -419,5 +419,14 @@ module Matrix =
fun (processor: MailboxProcessor<_>) allocationMode (leftMatrix: ClMatrix<'a>) (rightMatrix: ClMatrix<'b>) ->
match leftMatrix, rightMatrix with
| ClMatrix.CSR leftMatrix, ClMatrix.CSR rightMatrix ->
run processor allocationMode (clContext.MaxMemAllocSize / 10) leftMatrix rightMatrix
let allocCapacity =
List.max [ sizeof<'a>
sizeof<'c>
sizeof<'b> ]
* 1<Byte>

let resultCapacity =
(clContext.MaxMemAllocSize / allocCapacity) / 3

run processor allocationMode resultCapacity leftMatrix rightMatrix
| _ -> failwith "Matrix formats are not matching"
5 changes: 1 addition & 4 deletions src/GraphBLAS-sharp.Backend/Matrix/SpGeMM/Expand.fs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ module Expand =

let rightMatrixGather = Gather.run clContext workGroupSize

fun (processor: MailboxProcessor<_>) lengths (segmentsPointers: ClArray<int>) (leftMatrix: ClMatrix.COO<'a>) (rightMatrix: ClMatrix.CSR<'b>) ->

assert (lengths < clContext.MaxMemAllocSize)

fun (processor: MailboxProcessor<_>) (lengths: int) (segmentsPointers: ClArray<int>) (leftMatrix: ClMatrix.COO<'a>) (rightMatrix: ClMatrix.CSR<'b>) ->
// Compute left matrix positions
let leftMatrixPositions = zeroCreate processor DeviceOnly lengths

Expand Down
1 change: 1 addition & 0 deletions src/GraphBLAS-sharp.Backend/Objects/ClContextExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ module ClContext =
Cl
.GetDeviceInfo(this.ClDevice.Device, OpenCL.Net.DeviceInfo.MaxMemAllocSize, error)
.CastTo<int>()
* 1<Byte>
6 changes: 3 additions & 3 deletions tests/GraphBLAS-sharp.Tests/GraphBLAS-sharp.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<Compile Include="Backend/Common/ClArray/Pairwise.fs" />
<Compile Include="Backend/Common/ClArray/RemoveDuplicates.fs" />
<Compile Include="Backend/Common/ClArray/Replicate.fs" />
<Compile Include="Backend\Common\ClArray\UpperBound.fs" />
<Compile Include="Backend/Common/ClArray/UpperBound.fs" />
<Compile Include="Backend/Common/Gather.fs" />
<Compile Include="Backend/Common/Reduce/Reduce.fs" />
<Compile Include="Backend/Common/Reduce/ReduceByKey.fs" />
Expand All @@ -49,8 +49,8 @@
<Compile Include="Backend/Matrix/SpGeMM/Masked.fs" />
<Compile Include="Backend/Matrix/Transpose.fs" />
<Compile Include="Backend/Matrix/Merge.fs" />
<Compile Include="Backend\Matrix\ExpandRows.fs" />
<Compile Include="Backend\Matrix\SubRows.fs" />
<Compile Include="Backend/Matrix/ExpandRows.fs" />
<Compile Include="Backend/Matrix/SubRows.fs" />
<Compile Include="Backend/Vector/AssignByMask.fs" />
<Compile Include="Backend/Vector/Convert.fs" />
<Compile Include="Backend/Vector/Copy.fs" />
Expand Down