|
| 1 | +open System |
| 2 | + |
| 3 | +open Brahma.OpenCL |
| 4 | +open Brahma.FSharp.OpenCL.WorkflowBuilder.Basic |
| 5 | + |
| 6 | +open System |
| 7 | +open GraphBLAS.FSharp |
| 8 | +open Microsoft.FSharp.Reflection |
| 9 | +open Brahma.FSharp.OpenCL.WorkflowBuilder.Evaluation |
| 10 | +open GraphBLAS.FSharp.Predefined |
| 11 | + |
| 12 | +open GraphBLAS.FSharp |
| 13 | + |
| 14 | +[<EntryPoint>] |
| 15 | +let main argv = |
| 16 | + |
| 17 | + // let mutable oclContext = OpenCLEvaluationContext() |
| 18 | + |
| 19 | + // let xs = [||] |
| 20 | + // let command = |
| 21 | + // <@ |
| 22 | + // fun (ndRange: _1D) |
| 23 | + // (xs: int[]) -> |
| 24 | + |
| 25 | + // xs.[ndRange.GlobalID0] <- 42 |
| 26 | + // @> |
| 27 | + // let wf = |
| 28 | + // opencl { |
| 29 | + // let binder k = |
| 30 | + // let ndRange = _1D(xs.Length) |
| 31 | + // k ndRange xs |
| 32 | + // do! RunCommand command binder |
| 33 | + // return! ToHost xs |
| 34 | + // } |
| 35 | + |
| 36 | + // let res = oclContext.RunSync wf |
| 37 | + // printfn "%A" res |
| 38 | + |
| 39 | + let mutable oclContext = OpenCLEvaluationContext() |
| 40 | + |
| 41 | + let workGroupSize = 256 |
| 42 | + let workSize n = |
| 43 | + let m = n - 1 |
| 44 | + m - m % workGroupSize + workGroupSize |
| 45 | + |
| 46 | + //let leftMatrix = COOMatrix(100, 100, [|0;1;2;3;4;7|], [|1;7;5;6;0;1|], [|1.;2.;-4.;4.;5.;6.|]) |
| 47 | + //let rightMatrix = COOMatrix(100, 100, [|0;0;1;2;3;4;7|], [|1;5;4;5;7;0;1|], [|1.;2.;-4.;4.;5.;6.;7.|]) |
| 48 | + let leftMatrix = COOMatrix(100, 100, [||], [||], [||]) |
| 49 | + let rightMatrix = COOMatrix(100, 100, [||], [||], [||]) |
| 50 | + |
| 51 | + let workflow = |
| 52 | + opencl { |
| 53 | + let! resultMatrix = leftMatrix.EWiseAdd rightMatrix None FloatSemiring.addMult |
| 54 | + let! tuples = resultMatrix.GetTuples() |
| 55 | + return! tuples.ToHost() |
| 56 | + //return! resultMatrix.ToHost() |
| 57 | + } |
| 58 | + |
| 59 | + // let resultMatrix : COOMatrix<float> = downcast oclContext.RunSync workflow |
| 60 | + // printfn "%O" resultMatrix |
| 61 | + let res = oclContext.RunSync workflow |
| 62 | + printfn "%A" res.RowIndices |
| 63 | + printfn "%A" res.ColumnIndices |
| 64 | + printfn "%A" res.Values |
| 65 | + |
| 66 | + 0 |
0 commit comments