@@ -7,6 +7,7 @@ open Microsoft.FSharp.Quotations
77open GraphBLAS.FSharp .Backend .Objects
88open GraphBLAS.FSharp .Backend
99open GraphBLAS.FSharp .Backend .Objects .ClMatrix
10+ open GraphBLAS.FSharp .Backend .Objects .ClContext
1011
1112module COOMatrix =
1213 let private preparePositions < 'a , 'b , 'c when 'a : struct and 'b : struct and 'c : struct and 'c : equality >
@@ -57,18 +58,10 @@ module COOMatrix =
5758 Range1D.CreateValid( length, workGroupSize)
5859
5960 let rawPositionsGpu =
60- clContext.CreateClArray< int>(
61- length,
62- hostAccessMode = HostAccessMode.NotAccessible,
63- allocationMode = AllocationMode.Default
64- )
61+ clContext.CreateClArrayWithFlag< int>( GPUOnly, length)
6562
6663 let allValues =
67- clContext.CreateClArray< 'c>(
68- length,
69- hostAccessMode = HostAccessMode.NotAccessible,
70- allocationMode = AllocationMode.Default
71- )
64+ clContext.CreateClArrayWithFlag< 'c>( GPUOnly, length)
7265
7366 let kernel = kernel.GetKernel()
7467
@@ -225,44 +218,19 @@ module COOMatrix =
225218 let sumOfSides = firstSide + secondSide
226219
227220 let allRows =
228- clContext.CreateClArray< int>(
229- sumOfSides,
230- deviceAccessMode = DeviceAccessMode.WriteOnly,
231- hostAccessMode = HostAccessMode.NotAccessible,
232- allocationMode = AllocationMode.Default
233- )
221+ clContext.CreateClArrayWithFlag< int>( GPUOnly, sumOfSides)
234222
235223 let allColumns =
236- clContext.CreateClArray< int>(
237- sumOfSides,
238- deviceAccessMode = DeviceAccessMode.WriteOnly,
239- hostAccessMode = HostAccessMode.NotAccessible,
240- allocationMode = AllocationMode.Default
241- )
224+ clContext.CreateClArrayWithFlag< int>( GPUOnly, sumOfSides)
242225
243226 let leftMergedValues =
244- clContext.CreateClArray< 'a>(
245- sumOfSides,
246- deviceAccessMode = DeviceAccessMode.WriteOnly,
247- hostAccessMode = HostAccessMode.NotAccessible,
248- allocationMode = AllocationMode.Default
249- )
227+ clContext.CreateClArrayWithFlag< 'a>( GPUOnly, sumOfSides)
250228
251229 let rightMergedValues =
252- clContext.CreateClArray< 'b>(
253- sumOfSides,
254- deviceAccessMode = DeviceAccessMode.WriteOnly,
255- hostAccessMode = HostAccessMode.NotAccessible,
256- allocationMode = AllocationMode.Default
257- )
230+ clContext.CreateClArrayWithFlag< 'b>( GPUOnly, sumOfSides)
258231
259232 let isLeft =
260- clContext.CreateClArray< int>(
261- sumOfSides,
262- deviceAccessMode = DeviceAccessMode.WriteOnly,
263- hostAccessMode = HostAccessMode.NotAccessible,
264- allocationMode = AllocationMode.Default
265- )
233+ clContext.CreateClArrayWithFlag< int>( GPUOnly, sumOfSides)
266234
267235 let ndRange =
268236 Range1D.CreateValid( sumOfSides, workGroupSize)
@@ -301,6 +269,7 @@ module COOMatrix =
301269 ( clContext : ClContext )
302270 ( opAdd : Expr < 'a option -> 'b option -> 'c option >)
303271 workGroupSize
272+ flag
304273 =
305274
306275 let merge = merge clContext workGroupSize
@@ -309,7 +278,7 @@ module COOMatrix =
309278 preparePositions clContext opAdd workGroupSize
310279
311280 let setPositions =
312- Matrix.Common.setPositions< 'c> clContext workGroupSize
281+ Matrix.Common.setPositions< 'c> clContext workGroupSize flag
313282
314283 fun ( queue : MailboxProcessor < _ >) ( matrixLeft : ClMatrix.COO < 'a >) ( matrixRight : ClMatrix.COO < 'b >) ->
315284
@@ -345,11 +314,11 @@ module COOMatrix =
345314 Columns = resultColumns
346315 Values = resultValues }
347316
348- let getTuples ( clContext : ClContext ) workGroupSize =
317+ let getTuples ( clContext : ClContext ) workGroupSize flag =
349318
350- let copy = ClArray.copy clContext workGroupSize
319+ let copy = ClArray.copy clContext workGroupSize flag
351320
352- let copyData = ClArray.copy clContext workGroupSize
321+ let copyData = ClArray.copy clContext workGroupSize flag
353322
354323 fun ( processor : MailboxProcessor < _ >) ( matrix : ClMatrix.COO < 'a >) ->
355324
@@ -364,7 +333,7 @@ module COOMatrix =
364333 ColumnIndices = resultColumns
365334 Values = resultValues }
366335
367- let private compressRows ( clContext : ClContext ) workGroupSize =
336+ let private compressRows ( clContext : ClContext ) workGroupSize flag =
368337
369338 let compressRows =
370339 <@ fun ( ndRange : Range1D ) ( rows : ClArray < int >) ( nnz : int ) ( rowPointers : ClArray < int >) ->
@@ -379,7 +348,7 @@ module COOMatrix =
379348
380349 let program = clContext.Compile( compressRows)
381350
382- let create = ClArray.create clContext workGroupSize
351+ let create = ClArray.create clContext workGroupSize flag
383352
384353 let scan =
385354 ClArray.prefixSumBackwardsIncludeInplace <@ min @> clContext workGroupSize
@@ -401,11 +370,11 @@ module COOMatrix =
401370
402371 rowPointers
403372
404- let toCSR ( clContext : ClContext ) workGroupSize =
405- let prepare = compressRows clContext workGroupSize
373+ let toCSR ( clContext : ClContext ) workGroupSize flag =
374+ let prepare = compressRows clContext workGroupSize flag
406375
407- let copy = ClArray.copy clContext workGroupSize
408- let copyData = ClArray.copy clContext workGroupSize
376+ let copy = ClArray.copy clContext workGroupSize flag
377+ let copyData = ClArray.copy clContext workGroupSize flag
409378
410379 fun ( processor : MailboxProcessor < _ >) ( matrix : ClMatrix.COO < 'a >) ->
411380 let rowPointers =
@@ -421,8 +390,8 @@ module COOMatrix =
421390 Columns = cols
422391 Values = vals }
423392
424- let toCSRInplace ( clContext : ClContext ) workGroupSize =
425- let prepare = compressRows clContext workGroupSize
393+ let toCSRInplace ( clContext : ClContext ) workGroupSize flag =
394+ let prepare = compressRows clContext workGroupSize flag
426395
427396 fun ( processor : MailboxProcessor < _ >) ( matrix : ClMatrix.COO < 'a >) ->
428397 let rowPointers =
@@ -444,9 +413,10 @@ module COOMatrix =
444413 ( clContext : ClContext )
445414 ( opAdd : Expr < AtLeastOne < 'a , 'b > -> 'c option >)
446415 workGroupSize
416+ flag
447417 =
448418
449- elementwise clContext ( Convert.atLeastOneToOption opAdd) workGroupSize
419+ elementwise clContext ( Convert.atLeastOneToOption opAdd) workGroupSize flag
450420
451421 let transposeInplace ( clContext : ClContext ) workGroupSize =
452422
@@ -463,11 +433,11 @@ module COOMatrix =
463433 Columns = matrix.Rows
464434 Values = matrix.Values }
465435
466- let transpose ( clContext : ClContext ) workGroupSize =
436+ let transpose ( clContext : ClContext ) workGroupSize flag =
467437
468438 let transposeInplace = transposeInplace clContext workGroupSize
469- let copy = ClArray.copy clContext workGroupSize
470- let copyData = ClArray.copy clContext workGroupSize
439+ let copy = ClArray.copy clContext workGroupSize flag
440+ let copyData = ClArray.copy clContext workGroupSize flag
471441
472442 fun ( queue : MailboxProcessor < _ >) ( matrix : ClMatrix.COO < 'a >) ->
473443
0 commit comments