11namespace GraphBLAS.FSharp.Backend
22
3- open Brahma.FSharp .OpenCL
4- open GraphBLAS.FSharp .Backend .Common
3+ open GraphBLAS.FSharp .Backend
54open Brahma.FSharp
65open Microsoft.FSharp .Quotations
76
87module ClArray =
8+ type ClContext with
9+ member this.CreateClArrayWithGPUOnlyFlags ( size : int ) =
10+ this.CreateClArray(
11+ size,
12+ deviceAccessMode = DeviceAccessMode.ReadWrite,
13+ hostAccessMode = HostAccessMode.NotAccessible,
14+ allocationMode = AllocationMode.Default
15+ )
16+
17+ member this.CreateClArrayWithGPUOnlyFlags ( array : 'a []) =
18+ this.CreateClArray(
19+ array,
20+ deviceAccessMode = DeviceAccessMode.ReadWrite,
21+ hostAccessMode = HostAccessMode.NotAccessible,
22+ allocationMode = AllocationMode.CopyHostPtr
23+ )
24+
925 let init ( initializer : Expr < int -> 'a >) ( clContext : ClContext ) workGroupSize =
1026
1127 let init =
@@ -20,7 +36,8 @@ module ClArray =
2036
2137 fun ( processor : MailboxProcessor < _ >) ( length : int ) ->
2238 // TODO: Выставить нужные флаги
23- let outputArray = clContext.CreateClArray( length)
39+ let outputArray =
40+ clContext.CreateClArrayWithGPUOnlyFlags( length)
2441
2542 let kernel = program.GetKernel()
2643
@@ -47,7 +64,8 @@ module ClArray =
4764 fun ( processor : MailboxProcessor < _ >) ( length : int ) ( value : 'a ) ->
4865 let value = clContext.CreateClCell( value)
4966
50- let outputArray = clContext.CreateClArray( length)
67+ let outputArray =
68+ clContext.CreateClArrayWithGPUOnlyFlags( length)
5169
5270 let kernel = program.GetKernel()
5371
@@ -83,7 +101,7 @@ module ClArray =
83101 Range1D.CreateValid( inputArray.Length, workGroupSize)
84102
85103 let outputArray =
86- clContext.CreateClArray ( inputArray.Length, allocationMode = AllocationMode.Default )
104+ clContext.CreateClArrayWithGPUOnlyFlags inputArray.Length
87105
88106 let kernel = program.GetKernel()
89107
@@ -111,7 +129,7 @@ module ClArray =
111129 let outputArrayLength = inputArray.Length * count
112130
113131 let outputArray =
114- clContext.CreateClArray ( outputArrayLength , allocationMode = AllocationMode.Default )
132+ clContext.CreateClArrayWithGPUOnlyFlags outputArrayLength
115133
116134 let ndRange =
117135 Range1D.CreateValid( outputArray.Length, workGroupSize)
@@ -228,12 +246,7 @@ module ClArray =
228246 Range1D.CreateValid( inputLength, workGroupSize)
229247
230248 let bitmap =
231- clContext.CreateClArray(
232- inputLength,
233- hostAccessMode = HostAccessMode.NotAccessible,
234- deviceAccessMode = DeviceAccessMode.ReadWrite,
235- allocationMode = AllocationMode.Default
236- )
249+ clContext.CreateClArrayWithGPUOnlyFlags inputLength
237250
238251 let kernel = kernel.GetKernel()
239252
@@ -261,7 +274,7 @@ module ClArray =
261274 Range1D.CreateValid( inputArray.Length, workGroupSize)
262275
263276 let outputArray =
264- clContext.CreateClArray ( outputArraySize , allocationMode = AllocationMode.Default )
277+ clContext.CreateClArrayWithGPUOnlyFlags outputArraySize
265278
266279 let kernel = kernel.GetKernel()
267280
0 commit comments