Skip to content

Commit 02fa1ff

Browse files
committed
add: MaxMemAllocSize
1 parent fcbeee4 commit 02fa1ff

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ open GraphBLAS.FSharp.Backend.Matrix
77
open GraphBLAS.FSharp.Backend.Objects
88
open GraphBLAS.FSharp.Backend.Objects.ClMatrix
99
open GraphBLAS.FSharp.Backend.Vector
10+
open GraphBLAS.FSharp.Backend.Objects.ClContext
1011

1112
module Matrix =
1213
let copy (clContext: ClContext) workGroupSize =
@@ -418,6 +419,5 @@ module Matrix =
418419
fun (processor: MailboxProcessor<_>) allocationMode (leftMatrix: ClMatrix<'a>) (rightMatrix: ClMatrix<'b>) ->
419420
match leftMatrix, rightMatrix with
420421
| ClMatrix.CSR leftMatrix, ClMatrix.CSR rightMatrix ->
421-
// TODO(max alloc size)
422-
run processor allocationMode 1000 leftMatrix rightMatrix
422+
run processor allocationMode (clContext.MaxMemAllocSize / 10) leftMatrix rightMatrix
423423
| _ -> failwith "Matrix formats are not matching"

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,10 @@ module ClContext =
4141
hostAccessMode = HostAccessMode.ReadWrite,
4242
allocationMode = AllocationMode.CopyHostPtr
4343
)
44+
45+
member this.MaxMemAllocSize =
46+
let error = ref Unchecked.defaultof<ClErrorCode>
47+
48+
Cl
49+
.GetDeviceInfo(this.ClDevice.Device, OpenCL.Net.DeviceInfo.MaxMemAllocSize, error)
50+
.CastTo<int>()

tests/GraphBLAS-sharp.Tests/Backend/Matrix/SpGeMM/Expand.fs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ let createGeneralTest (zero: 'a) isEqual (opAddQ, opAdd) (opMulQ, opMul) testFun
215215
testFun opAddQ opMulQ context Utils.defaultWorkGroupSize
216216
|> makeGeneralTest zero isEqual opAdd opMul
217217
|> testPropertyWithConfig
218-
{ config with
219-
endSize = 10000
220-
maxTest = 100 }
218+
{ config with endSize = 100; maxTest = 10 }
221219
$"test on %A{typeof<'a>}"
222220

223221
let generalTests =

0 commit comments

Comments
 (0)