Skip to content

Commit 2ba22eb

Browse files
committed
refactor: rename flag -> allocationMode
1 parent d82b408 commit 2ba22eb

10 files changed

Lines changed: 197 additions & 198 deletions

File tree

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ module ClArray =
1717

1818
let program = clContext.Compile(init)
1919

20-
fun (processor: MailboxProcessor<_>) flag (length: int) ->
20+
fun (processor: MailboxProcessor<_>) allocationMode (length: int) ->
2121
let outputArray =
22-
clContext.CreateClArrayWithFlag(flag, length)
22+
clContext.CreateClArrayWithFlag(allocationMode, length)
2323

2424
let kernel = program.GetKernel()
2525

@@ -43,11 +43,11 @@ module ClArray =
4343

4444
let program = clContext.Compile(create)
4545

46-
fun (processor: MailboxProcessor<_>) flag (length: int) (value: 'a) ->
46+
fun (processor: MailboxProcessor<_>) allocationMode (length: int) (value: 'a) ->
4747
let value = clContext.CreateClCell(value)
4848

4949
let outputArray =
50-
clContext.CreateClArrayWithFlag(flag, length)
50+
clContext.CreateClArrayWithFlag(allocationMode, length)
5151

5252
let kernel = program.GetKernel()
5353

@@ -64,7 +64,7 @@ module ClArray =
6464

6565
let create = create clContext workGroupSize
6666

67-
fun (processor: MailboxProcessor<_>) flag length -> create processor flag length Unchecked.defaultof<'a>
67+
fun (processor: MailboxProcessor<_>) allocationMode length -> create processor allocationMode length Unchecked.defaultof<'a>
6868

6969
let copy (clContext: ClContext) workGroupSize =
7070
let copy =
@@ -77,12 +77,12 @@ module ClArray =
7777

7878
let program = clContext.Compile(copy)
7979

80-
fun (processor: MailboxProcessor<_>) flag (inputArray: ClArray<'a>) ->
80+
fun (processor: MailboxProcessor<_>) allocationMode (inputArray: ClArray<'a>) ->
8181
let ndRange =
8282
Range1D.CreateValid(inputArray.Length, workGroupSize)
8383

8484
let outputArray =
85-
clContext.CreateClArrayWithFlag(flag, inputArray.Length)
85+
clContext.CreateClArrayWithFlag(allocationMode, inputArray.Length)
8686

8787
let kernel = program.GetKernel()
8888

@@ -94,7 +94,7 @@ module ClArray =
9494

9595
outputArray
9696

97-
let replicate (clContext: ClContext) =
97+
let replicate (clContext: ClContext) workGroupSize =
9898

9999
let replicate =
100100
<@ fun (ndRange: Range1D) (inputArrayBuffer: ClArray<'a>) (outputArrayBuffer: ClArray<'a>) inputArrayLength outputArrayLength ->
@@ -106,11 +106,11 @@ module ClArray =
106106

107107
let kernel = clContext.Compile(replicate)
108108

109-
fun (processor: MailboxProcessor<_>) flag workGroupSize (inputArray: ClArray<'a>) count ->
109+
fun (processor: MailboxProcessor<_>) allocationMode (inputArray: ClArray<'a>) count ->
110110
let outputArrayLength = inputArray.Length * count
111111

112112
let outputArray =
113-
clContext.CreateClArrayWithFlag(flag, outputArrayLength)
113+
clContext.CreateClArrayWithFlag(allocationMode, outputArrayLength)
114114

115115
let ndRange =
116116
Range1D.CreateValid(outputArray.Length, workGroupSize)
@@ -179,9 +179,9 @@ module ClArray =
179179

180180
let copy = copy clContext workGroupSize
181181

182-
fun (processor: MailboxProcessor<_>) flag (inputArray: ClArray<'a>) (totalSum: ClCell<'a>) (zero: 'a) ->
182+
fun (processor: MailboxProcessor<_>) allocationMode (inputArray: ClArray<'a>) (totalSum: ClCell<'a>) (zero: 'a) ->
183183

184-
let outputArray = copy processor flag inputArray
184+
let outputArray = copy processor allocationMode inputArray
185185

186186
runExcludeInplace processor outputArray totalSum zero
187187

@@ -192,9 +192,9 @@ module ClArray =
192192

193193
let copy = copy clContext workGroupSize
194194

195-
fun (processor: MailboxProcessor<_>) flag (inputArray: ClArray<'a>) (totalSum: ClCell<'a>) (zero: 'a) ->
195+
fun (processor: MailboxProcessor<_>) allocationMode (inputArray: ClArray<'a>) (totalSum: ClCell<'a>) (zero: 'a) ->
196196

197-
let outputArray = copy processor flag inputArray
197+
let outputArray = copy processor allocationMode inputArray
198198

199199
runIncludeInplace processor outputArray totalSum zero
200200

@@ -219,15 +219,15 @@ module ClArray =
219219

220220
let kernel = clContext.Compile(getUniqueBitmap)
221221

222-
fun (processor: MailboxProcessor<_>) flag (inputArray: ClArray<'a>) ->
222+
fun (processor: MailboxProcessor<_>) allocationMode (inputArray: ClArray<'a>) ->
223223

224224
let inputLength = inputArray.Length
225225

226226
let ndRange =
227227
Range1D.CreateValid(inputLength, workGroupSize)
228228

229229
let bitmap =
230-
clContext.CreateClArrayWithFlag(flag, inputLength)
230+
clContext.CreateClArrayWithFlag(allocationMode, inputLength)
231231

232232
let kernel = kernel.GetKernel()
233233

@@ -319,10 +319,10 @@ module ClArray =
319319

320320
let kernel = clContext.Compile map
321321

322-
fun (processor: MailboxProcessor<_>) flag (inputArray: ClArray<'a>) ->
322+
fun (processor: MailboxProcessor<_>) allocationMode (inputArray: ClArray<'a>) ->
323323

324324
let result =
325-
clContext.CreateClArrayWithFlag(flag, inputArray.Length)
325+
clContext.CreateClArrayWithFlag(allocationMode, inputArray.Length)
326326

327327
let ndRange =
328328
Range1D.CreateValid(inputArray.Length, workGroupSize)

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ module COOMatrix =
276276
let setPositions =
277277
Matrix.Common.setPositions<'c> clContext workGroupSize
278278

279-
fun (queue: MailboxProcessor<_>) flag (matrixLeft: ClMatrix.COO<'a>) (matrixRight: ClMatrix.COO<'b>) ->
279+
fun (queue: MailboxProcessor<_>) allocationMode (matrixLeft: ClMatrix.COO<'a>) (matrixRight: ClMatrix.COO<'b>) ->
280280

281281
let allRows, allColumns, leftMergedValues, rightMergedValues, isLeft =
282282
merge
@@ -294,8 +294,8 @@ module COOMatrix =
294294
queue.Post(Msg.CreateFreeMsg<_>(leftMergedValues))
295295
queue.Post(Msg.CreateFreeMsg<_>(rightMergedValues))
296296

297-
let resultRows, resultColumns, resultValues, resultLength =
298-
setPositions queue flag allRows allColumns allValues rawPositions
297+
let resultRows, resultColumns, resultValues, _ =
298+
setPositions queue allocationMode allRows allColumns allValues rawPositions
299299

300300
queue.Post(Msg.CreateFreeMsg<_>(isLeft))
301301
queue.Post(Msg.CreateFreeMsg<_>(rawPositions))
@@ -316,13 +316,13 @@ module COOMatrix =
316316

317317
let copyData = ClArray.copy clContext workGroupSize
318318

319-
fun (processor: MailboxProcessor<_>) flag (matrix: ClMatrix.COO<'a>) ->
319+
fun (processor: MailboxProcessor<_>) allocationMode (matrix: ClMatrix.COO<'a>) ->
320320

321-
let resultRows = copy processor flag matrix.Rows
321+
let resultRows = copy processor allocationMode matrix.Rows
322322

323-
let resultColumns = copy processor flag matrix.Columns
323+
let resultColumns = copy processor allocationMode matrix.Columns
324324

325-
let resultValues = copyData processor flag matrix.Values
325+
let resultValues = copyData processor allocationMode matrix.Values
326326

327327
{ Context = clContext
328328
RowIndices = resultRows
@@ -349,10 +349,10 @@ module COOMatrix =
349349
let scan =
350350
ClArray.prefixSumBackwardsIncludeInplace <@ min @> clContext workGroupSize
351351

352-
fun (processor: MailboxProcessor<_>) flag (rowIndices: ClArray<int>) rowCount ->
352+
fun (processor: MailboxProcessor<_>) allocationMode (rowIndices: ClArray<int>) rowCount ->
353353

354354
let nnz = rowIndices.Length
355-
let rowPointers = create processor flag (rowCount + 1) nnz
355+
let rowPointers = create processor allocationMode (rowCount + 1) nnz
356356

357357
let kernel = program.GetKernel()
358358

@@ -373,12 +373,12 @@ module COOMatrix =
373373

374374
let copyData = ClArray.copy clContext workGroupSize
375375

376-
fun (processor: MailboxProcessor<_>) flag (matrix: ClMatrix.COO<'a>) ->
376+
fun (processor: MailboxProcessor<_>) allocationMode (matrix: ClMatrix.COO<'a>) ->
377377
let rowPointers =
378-
prepare processor flag matrix.Rows matrix.RowCount
378+
prepare processor allocationMode matrix.Rows matrix.RowCount
379379

380-
let cols = copy processor flag matrix.Columns
381-
let vals = copyData processor flag matrix.Values
380+
let cols = copy processor allocationMode matrix.Columns
381+
let vals = copyData processor allocationMode matrix.Values
382382

383383
{ Context = clContext
384384
RowCount = matrix.RowCount
@@ -390,9 +390,9 @@ module COOMatrix =
390390
let toCSRInplace (clContext: ClContext) workGroupSize =
391391
let prepare = compressRows clContext workGroupSize
392392

393-
fun (processor: MailboxProcessor<_>) flag (matrix: ClMatrix.COO<'a>) ->
393+
fun (processor: MailboxProcessor<_>) allocationMode (matrix: ClMatrix.COO<'a>) ->
394394
let rowPointers =
395-
prepare processor flag matrix.Rows matrix.RowCount
395+
prepare processor allocationMode matrix.Rows matrix.RowCount
396396

397397
processor.Post(Msg.CreateFreeMsg(matrix.Rows))
398398

@@ -437,12 +437,12 @@ module COOMatrix =
437437

438438
let copyData = ClArray.copy clContext workGroupSize
439439

440-
fun (queue: MailboxProcessor<_>) flag (matrix: ClMatrix.COO<'a>) ->
440+
fun (queue: MailboxProcessor<_>) allocationMode (matrix: ClMatrix.COO<'a>) ->
441441

442442
{ Context = clContext
443443
RowCount = matrix.RowCount
444444
ColumnCount = matrix.ColumnCount
445-
Rows = copy queue flag matrix.Rows
446-
Columns = copy queue flag matrix.Columns
447-
Values = copyData queue flag matrix.Values }
445+
Rows = copy queue allocationMode matrix.Rows
446+
Columns = copy queue allocationMode matrix.Columns
447+
Values = copyData queue allocationMode matrix.Values }
448448
|> transposeInplace queue

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ module CSRMatrix =
3131
let scan =
3232
ClArray.prefixSumIncludeInplace <@ max @> clContext workGroupSize
3333

34-
fun (processor: MailboxProcessor<_>) flag (rowPointers: ClArray<int>) nnz rowCount ->
34+
fun (processor: MailboxProcessor<_>) allocationMode (rowPointers: ClArray<int>) nnz rowCount ->
3535

36-
let rows = create processor flag nnz 0
36+
let rows = create processor allocationMode nnz 0
3737

3838
let kernel = program.GetKernel()
3939

@@ -57,12 +57,12 @@ module CSRMatrix =
5757

5858
let copyData = ClArray.copy clContext workGroupSize
5959

60-
fun (processor: MailboxProcessor<_>) flag (matrix: ClMatrix.CSR<'a>) ->
60+
fun (processor: MailboxProcessor<_>) allocationMode (matrix: ClMatrix.CSR<'a>) ->
6161
let rows =
62-
prepare processor flag matrix.RowPointers matrix.Columns.Length matrix.RowCount
62+
prepare processor allocationMode matrix.RowPointers matrix.Columns.Length matrix.RowCount
6363

64-
let cols = copy processor flag matrix.Columns
65-
let vals = copyData processor flag matrix.Values
64+
let cols = copy processor allocationMode matrix.Columns
65+
let vals = copyData processor allocationMode matrix.Values
6666

6767
{ Context = clContext
6868
RowCount = matrix.RowCount
@@ -75,9 +75,9 @@ module CSRMatrix =
7575
let prepare =
7676
expandRowPointers clContext workGroupSize
7777

78-
fun (processor: MailboxProcessor<_>) flag (matrix: ClMatrix.CSR<'a>) ->
78+
fun (processor: MailboxProcessor<_>) allocationMode (matrix: ClMatrix.CSR<'a>) ->
7979
let rows =
80-
prepare processor flag matrix.RowPointers matrix.Columns.Length matrix.RowCount
80+
prepare processor allocationMode matrix.RowPointers matrix.Columns.Length matrix.RowCount
8181

8282
processor.Post(Msg.CreateFreeMsg(matrix.RowPointers))
8383

@@ -100,29 +100,29 @@ module CSRMatrix =
100100
let toCSRInplace =
101101
COOMatrix.toCSRInplace clContext workGroupSize
102102

103-
fun (processor: MailboxProcessor<_>) flag (m1: ClMatrix.CSR<'a>) (m2: ClMatrix.CSR<'b>) ->
103+
fun (processor: MailboxProcessor<_>) allocationMode (m1: ClMatrix.CSR<'a>) (m2: ClMatrix.CSR<'b>) ->
104104
let m1COO =
105105
{ Context = clContext
106106
RowCount = m1.RowCount
107107
ColumnCount = m1.ColumnCount
108-
Rows = prepareRows processor flag m1.RowPointers m1.Values.Length m1.RowCount
108+
Rows = prepareRows processor allocationMode m1.RowPointers m1.Values.Length m1.RowCount
109109
Columns = m1.Columns
110110
Values = m1.Values }
111111

112112
let m2COO =
113113
{ Context = clContext
114114
RowCount = m2.RowCount
115115
ColumnCount = m2.ColumnCount
116-
Rows = prepareRows processor flag m2.RowPointers m2.Values.Length m2.RowCount
116+
Rows = prepareRows processor allocationMode m2.RowPointers m2.Values.Length m2.RowCount
117117
Columns = m2.Columns
118118
Values = m2.Values }
119119

120-
let m3COO = eWiseCOO processor flag m1COO m2COO
120+
let m3COO = eWiseCOO processor allocationMode m1COO m2COO
121121

122122
processor.Post(Msg.CreateFreeMsg(m1COO.Rows))
123123
processor.Post(Msg.CreateFreeMsg(m2COO.Rows))
124124

125-
toCSRInplace processor flag m3COO
125+
toCSRInplace processor allocationMode m3COO
126126

127127
///<remarks>Old version</remarks>
128128
let elementwiseAtLeastOneWithCOO
@@ -143,10 +143,10 @@ module CSRMatrix =
143143
let toCSRInplace =
144144
COOMatrix.toCSRInplace clContext workGroupSize
145145

146-
fun (queue: MailboxProcessor<_>) flag (matrix: ClMatrix.CSR<'a>) ->
147-
toCOOInplace queue flag matrix
146+
fun (queue: MailboxProcessor<_>) allocationMode (matrix: ClMatrix.CSR<'a>) ->
147+
toCOOInplace queue allocationMode matrix
148148
|> transposeInplace queue
149-
|> toCSRInplace queue flag
149+
|> toCSRInplace queue allocationMode
150150

151151
let transpose (clContext: ClContext) workGroupSize =
152152

@@ -158,10 +158,10 @@ module CSRMatrix =
158158
let toCSRInplace =
159159
COOMatrix.toCSRInplace clContext workGroupSize
160160

161-
fun (queue: MailboxProcessor<_>) flag (matrix: ClMatrix.CSR<'a>) ->
162-
toCOO queue flag matrix
161+
fun (queue: MailboxProcessor<_>) allocationMode (matrix: ClMatrix.CSR<'a>) ->
162+
toCOO queue allocationMode matrix
163163
|> transposeInplace queue
164-
|> toCSRInplace queue flag
164+
|> toCSRInplace queue allocationMode
165165

166166
let elementwiseToCOO<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct and 'c: equality>
167167
(clContext: ClContext)
@@ -177,7 +177,7 @@ module CSRMatrix =
177177
let setPositions =
178178
Matrix.Common.setPositions<'c> clContext workGroupSize
179179

180-
fun (queue: MailboxProcessor<_>) flag (matrixLeft: ClMatrix.CSR<'a>) (matrixRight: ClMatrix.CSR<'b>) ->
180+
fun (queue: MailboxProcessor<_>) allocationMode (matrixLeft: ClMatrix.CSR<'a>) (matrixRight: ClMatrix.CSR<'b>) ->
181181

182182
let allRows, allColumns, leftMergedValues, rightMergedValues, isRowEnd, isLeft =
183183
merge
@@ -196,7 +196,7 @@ module CSRMatrix =
196196
queue.Post(Msg.CreateFreeMsg<_>(rightMergedValues))
197197

198198
let resultRows, resultColumns, resultValues, _ =
199-
setPositions queue flag allRows allColumns allValues positions
199+
setPositions queue allocationMode allRows allColumns allValues positions
200200

201201
queue.Post(Msg.CreateFreeMsg<_>(allRows))
202202
queue.Post(Msg.CreateFreeMsg<_>(isLeft))
@@ -224,9 +224,9 @@ module CSRMatrix =
224224
let toCSRInplace =
225225
COOMatrix.toCSRInplace clContext workGroupSize
226226

227-
fun (queue: MailboxProcessor<_>) flag (matrixLeft: ClMatrix.CSR<'a>) (matrixRight: ClMatrix.CSR<'b>) ->
228-
elementwiseToCOO queue flag matrixLeft matrixRight
229-
|> toCSRInplace queue flag
227+
fun (queue: MailboxProcessor<_>) allocationMode (matrixLeft: ClMatrix.CSR<'a>) (matrixRight: ClMatrix.CSR<'b>) ->
228+
elementwiseToCOO queue allocationMode matrixLeft matrixRight
229+
|> toCSRInplace queue allocationMode
230230

231231
let elementwiseAtLeastOneToCOO<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct and 'c: equality>
232232
(clContext: ClContext)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module Common =
2121

2222
let resultLength = Array.zeroCreate<int> 1
2323

24-
fun (processor: MailboxProcessor<_>) flag (allRows: ClArray<int>) (allColumns: ClArray<int>) (allValues: ClArray<'a>) (positions: ClArray<int>) ->
24+
fun (processor: MailboxProcessor<_>) allocationMode (allRows: ClArray<int>) (allColumns: ClArray<int>) (allValues: ClArray<'a>) (positions: ClArray<int>) ->
2525
let resultLengthGpu = clContext.CreateClCell 0
2626

2727
let _, r = sum processor positions resultLengthGpu
@@ -35,14 +35,14 @@ module Common =
3535
res.[0]
3636

3737
let resultRows =
38-
clContext.CreateClArrayWithFlag<int>(flag, resultLength)
38+
clContext.CreateClArrayWithFlag<int>(allocationMode, resultLength)
3939

4040

4141
let resultColumns =
42-
clContext.CreateClArrayWithFlag<int>(flag, resultLength)
42+
clContext.CreateClArrayWithFlag<int>(allocationMode, resultLength)
4343

4444
let resultValues =
45-
clContext.CreateClArrayWithFlag(flag, resultLength)
45+
clContext.CreateClArrayWithFlag(allocationMode, resultLength)
4646

4747
indicesScatter processor positions allRows resultRows
4848

0 commit comments

Comments
 (0)