Skip to content

Commit bae988e

Browse files
committed
add: measure maxAllocSize
1 parent 7e58687 commit bae988e

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

src/GraphBLAS-sharp.Backend/Common/ClArray.fs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,6 @@ module ClArray =
613613
sourceArrays
614614
|> Seq.sumBy (fun array -> array.Length)
615615

616-
if resultLength >= clContext.MaxMemAllocSize then
617-
failwith "It is impossible to allocate more than MaxAllocSize"
618-
619616
let result =
620617
clContext.CreateClArrayWithSpecificAllocationMode(allocationMode, resultLength)
621618

src/GraphBLAS-sharp.Backend/Matrix/Matrix.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,5 +419,14 @@ module Matrix =
419419
fun (processor: MailboxProcessor<_>) allocationMode (leftMatrix: ClMatrix<'a>) (rightMatrix: ClMatrix<'b>) ->
420420
match leftMatrix, rightMatrix with
421421
| ClMatrix.CSR leftMatrix, ClMatrix.CSR rightMatrix ->
422-
run processor allocationMode (clContext.MaxMemAllocSize / 10) leftMatrix rightMatrix
422+
let allocCapacity =
423+
List.max [ sizeof<'a>
424+
sizeof<'c>
425+
sizeof<'b> ]
426+
* 1<Byte>
427+
428+
let resultCapacity =
429+
(clContext.MaxMemAllocSize / allocCapacity) / 3
430+
431+
run processor allocationMode resultCapacity leftMatrix rightMatrix
423432
| _ -> failwith "Matrix formats are not matching"

src/GraphBLAS-sharp.Backend/Matrix/SpGeMM/Expand.fs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ module Expand =
109109

110110
let rightMatrixGather = Gather.run clContext workGroupSize
111111

112-
fun (processor: MailboxProcessor<_>) lengths (segmentsPointers: ClArray<int>) (leftMatrix: ClMatrix.COO<'a>) (rightMatrix: ClMatrix.CSR<'b>) ->
113-
114-
assert (lengths < clContext.MaxMemAllocSize)
115-
112+
fun (processor: MailboxProcessor<_>) (lengths: int) (segmentsPointers: ClArray<int>) (leftMatrix: ClMatrix.COO<'a>) (rightMatrix: ClMatrix.CSR<'b>) ->
116113
// Compute left matrix positions
117114
let leftMatrixPositions = zeroCreate processor DeviceOnly lengths
118115

src/GraphBLAS-sharp.Backend/Objects/ClContextExtensions.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ module ClContext =
4848
Cl
4949
.GetDeviceInfo(this.ClDevice.Device, OpenCL.Net.DeviceInfo.MaxMemAllocSize, error)
5050
.CastTo<int>()
51+
* 1<Byte>

tests/GraphBLAS-sharp.Tests/GraphBLAS-sharp.Tests.fsproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<Compile Include="Backend/Common/ClArray/Pairwise.fs" />
3030
<Compile Include="Backend/Common/ClArray/RemoveDuplicates.fs" />
3131
<Compile Include="Backend/Common/ClArray/Replicate.fs" />
32-
<Compile Include="Backend\Common\ClArray\UpperBound.fs" />
32+
<Compile Include="Backend/Common/ClArray/UpperBound.fs" />
3333
<Compile Include="Backend/Common/Gather.fs" />
3434
<Compile Include="Backend/Common/Reduce/Reduce.fs" />
3535
<Compile Include="Backend/Common/Reduce/ReduceByKey.fs" />
@@ -49,8 +49,8 @@
4949
<Compile Include="Backend/Matrix/SpGeMM/Masked.fs" />
5050
<Compile Include="Backend/Matrix/Transpose.fs" />
5151
<Compile Include="Backend/Matrix/Merge.fs" />
52-
<Compile Include="Backend\Matrix\ExpandRows.fs" />
53-
<Compile Include="Backend\Matrix\SubRows.fs" />
52+
<Compile Include="Backend/Matrix/ExpandRows.fs" />
53+
<Compile Include="Backend/Matrix/SubRows.fs" />
5454
<Compile Include="Backend/Vector/AssignByMask.fs" />
5555
<Compile Include="Backend/Vector/Convert.fs" />
5656
<Compile Include="Backend/Vector/Copy.fs" />

0 commit comments

Comments
 (0)