Skip to content

Commit 7e58687

Browse files
committed
add: maxAllocSize assert
1 parent 9662efe commit 7e58687

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,9 @@ 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+
616619
let result =
617620
clContext.CreateClArrayWithSpecificAllocationMode(allocationMode, resultLength)
618621

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ module Expand =
111111

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

114+
assert (lengths < clContext.MaxMemAllocSize)
115+
114116
// Compute left matrix positions
115117
let leftMatrixPositions = zeroCreate processor DeviceOnly lengths
116118

@@ -456,6 +458,7 @@ module Expand =
456458

457459
let rows = concat processor allocationMode rowsList
458460

461+
// TODO(overhead: compute result length 3 time)
459462
// release resources
460463
valuesList
461464
|> List.iter (fun array -> array.Free processor)

0 commit comments

Comments
 (0)