In [1]:
#load "Paket.fsx"
Paket.Dependencies.Install """ 
frameworks: net45
source https://nuget.org/api/v2
nuget Alea
"""
Paket.LoadingScripts.ScriptGeneration.generateScriptsForRootFolder
   Paket.LoadingScripts.ScriptGeneration.FSharp
   (Paket.FrameworkIdentifier.DotNetFramework Paket.FrameworkVersion.V4_5)
   (System.IO.DirectoryInfo __SOURCE_DIRECTORY__)

#load "paket-files/include-scripts/net45/include.main.group.fsx"
#load "packages/Alea/Alea.fsx"

In [2]:
open Alea
open Alea.Parallel
Gpu.Default


Out[2]:
[0|3.5|GeForce GTX TITAN]

In [9]:
[<GpuManaged>]
let scanit () = 
    
    let len = 100 * 100
    let arr = [|0..len - 1|]
    let arrOut = Array.zeroCreate len
    let gpu = Gpu.Default;
    use session = new Session(gpu)

    GpuExtension.Scan(session, arrOut, arr, 0, (fun x y -> x + y), 0)
    printfn "%A" arrOut

In [10]:
scanit()


System.Exception: Object reference not set to an instance of an object.
Loading method as kernel:
-> Method: Alea.Parallel.Device.DeviceScan.[Void KernelUpsweep[Int32](Alea.Constant`1[System.Int32], Alea.Constant`1[System.Int32], System.Func`3[System.Int32,System.Int32,System.Int32], Alea.deviceptr`1[System.Int32], Alea.deviceptr`1[System.Int32], Int32)]
-> InstanceOpt: <None>
-> Argument.#0: 512
-> Argument.#1: 2
-> Argument.#2: System.Func`3[System.Int32,System.Int32,System.Int32]
-> Argument.#3: deviceptr(704140200)
-> Argument.#4: deviceptr(70405DA00)
-> Argument.#5: 10000
Getting or loading method as kernel:
-> Method: Alea.Parallel.Device.DeviceScan.[Void KernelUpsweep[Int32](Alea.Constant`1[System.Int32], Alea.Constant`1[System.Int32], System.Func`3[System.Int32,System.Int32,System.Int32], Alea.deviceptr`1[System.Int32], Alea.deviceptr`1[System.Int32], Int32)]
-> InstanceOpt: <None>
-> Argument.#0: 512
-> Argument.#1: 2
-> Argument.#2: System.Func`3[System.Int32,System.Int32,System.Int32]
-> Argument.#3: deviceptr(704140200)
-> Argument.#4: deviceptr(70405DA00)
-> Argument.#5: 10000

   at Alea.Gpu.GetOrLoad(MethodInfo kernelMethodInfo, FSharpOption`1 instanceOpt, FSharpList`1 arguments)
   at Alea.CSharp.GpuExtensions.Launch[T1,T2,T3,T4,T5,T6](Gpu this, Action`6 kernel, LaunchParam lp, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
   at Alea.Parallel.Device.DeviceScan.Scan[T](Session session, Constant`1 constNT, Constant`1 constVT, Func`3 op, T identity, deviceptr`1 outputs, deviceptr`1 inputs, deviceptr`1 partials, T init, Int32 count, Int32[] passes, Int32 pass)
   at Alea.Parallel.Device.DeviceScan.Scan[T](Session session, Int32 nt, Int32 vt, Func`3 op, T identity, deviceptr`1 outputs, deviceptr`1 inputs, T init, Int32 count)
   at Alea.Parallel.GpuExtension.Scan[T](Session session, T[] outputs, T[] inputs, T init, Func`3 op, T identity)
   at FSI_0016.scanit() in c:\Git\BioSandbox\Notebooks\input.fsx:line 11
   at <StartupCode$FSI_0017>.$FSI_0017.main@()
Stopped due to error

In [7]:
arrOut <- Gpu.CopyToHost(devOut)
printfn "%A" arrOut
    
let arrScan = arr |> Array.scan(fun st y -> st + y) 0
printfn "%b" (arrOut = arrScan.[1..])


System.Exception: Object reference not set to an instance of an object.
Loading method as kernel:
-> Method: Alea.Parallel.Device.DeviceScan.[Void KernelUpsweep[Int32](Alea.Constant`1[System.Int32], Alea.Constant`1[System.Int32], System.Func`3[System.Int32,System.Int32,System.Int32], Alea.deviceptr`1[System.Int32], Alea.deviceptr`1[System.Int32], Int32)]
-> InstanceOpt: <None>
-> Argument.#0: 512
-> Argument.#1: 2
-> Argument.#2: System.Func`3[System.Int32,System.Int32,System.Int32]
-> Argument.#3: deviceptr(704140400)
-> Argument.#4: deviceptr(704067800)
-> Argument.#5: 10000
Getting or loading method as kernel:
-> Method: Alea.Parallel.Device.DeviceScan.[Void KernelUpsweep[Int32](Alea.Constant`1[System.Int32], Alea.Constant`1[System.Int32], System.Func`3[System.Int32,System.Int32,System.Int32], Alea.deviceptr`1[System.Int32], Alea.deviceptr`1[System.Int32], Int32)]
-> InstanceOpt: <None>
-> Argument.#0: 512
-> Argument.#1: 2
-> Argument.#2: System.Func`3[System.Int32,System.Int32,System.Int32]
-> Argument.#3: deviceptr(704140400)
-> Argument.#4: deviceptr(704067800)
-> Argument.#5: 10000

   at Alea.Gpu.GetOrLoad(MethodInfo kernelMethodInfo, FSharpOption`1 instanceOpt, FSharpList`1 arguments)
   at Alea.CSharp.GpuExtensions.Launch[T1,T2,T3,T4,T5,T6](Gpu this, Action`6 kernel, LaunchParam lp, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
   at Alea.Parallel.Device.DeviceScan.Scan[T](Session session, Constant`1 constNT, Constant`1 constVT, Func`3 op, T identity, deviceptr`1 outputs, deviceptr`1 inputs, deviceptr`1 partials, T init, Int32 count, Int32[] passes, Int32 pass)
   at Alea.Parallel.Device.DeviceScan.Scan[T](Session session, Int32 nt, Int32 vt, Func`3 op, T identity, deviceptr`1 outputs, deviceptr`1 inputs, T init, Int32 count)
   at <StartupCode$FSI_0018>.$FSI_0018.main@() in c:\Git\BioSandbox\Notebooks\input.fsx:line 9
Stopped due to error

In [ ]: