Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Обработка транслятором функций типа void #26

Closed
LuninaPolina opened this issue May 23, 2016 · 1 comment

Comments

@LuninaPolina
Copy link

LuninaPolina commented May 23, 2016

Проблема: невозможность обработки транслятором функций типа void.
При попытке передачи на компиляцию методу ComputeProvider.Compile цитированной функции, имеющей тип Expr<_ - >unit>, возникает исключение:
System.Exception : Printer. Unsupported statement: Brahma.FSharp.OpenCL.AST.Const`1[Brahma.FSharp.OpenCL.Translator.Common+Lang]
Пример кода:

let Iter func (inArr: int array) = 
    let platformName = "*"
    let localWorkSize = 100
    let deviceType = DeviceType.Default
    let length = inArr.Length
    let provider = 
        try ComputeProvider.Create(platformName, deviceType)
        with
        | ex -> failwith ex.Message
    let mutable commandQueue = new CommandQueue(provider, provider.Devices |> Seq.head)
    let command = 
        <@
            fun (rng: _1D) (a: array<_>) ->
                let r = rng.GlobalID0            
                (%func) a.[r]               
        @>
    let kernel, kernelPrepare, kernelRun = provider.Compile command
    let d = new _1D(length, localWorkSize)
    kernelPrepare d inArr
    let _ = commandQueue.Add(kernelRun()).Finish()
    commandQueue.Dispose()
    provider.Dispose()
    provider.CloseAllBuffers()
let arr = [|for i in 1..1000 -> i|]
Iter <@ fun x -> () @> arr
@gsvgit
Copy link
Member

gsvgit commented May 24, 2016

@LuninaPolina Приведите пример кода, пожалуйста.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants