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

Compilation error on DU case construction inside kernel #148

Open
dpanfilyonok opened this issue Nov 14, 2022 · 0 comments
Open

Compilation error on DU case construction inside kernel #148

dpanfilyonok opened this issue Nov 14, 2022 · 0 comments

Comments

@dpanfilyonok
Copy link

Describe the bug

Unhandled exception. System.Exception: Program compilation failed: BuildProgramFailure
   BUILD LOG:
 <kernel>:17:55: error: passing '__global float' to parameter of incompatible type 'du0' (aka 'struct du0')
 tuple1 matchValue = matchValueUnitFunc ((du0) { 0 }, leftValues [gid]) ;
                                                      ^~~~~~~~~~~~~~~~

   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1433.Invoke(String message) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1433
   at Microsoft.FSharp.Core.PrintfModule.gprintf[a,TState,TResidue,TResult,TPrinter](FSharpFunc`2 envf, PrintfFormat`4 format) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1385
   at Brahma.FSharp.ClProgram`2..ctor(ClContext ctx, FSharpExpr`1 srcLambda)
   at Brahma.FSharp.ClContextExtensions.ClContext.Compile[TRange,a](ClContext this, FSharpExpr`1 srcLambda)

To Reproduce

let left (opAdd: Expr<'a option -> 'b option -> 'c option>) =
    <@
        fun (leftItem: 'a) ->
             (%opAdd) (Some leftItem) None
    @>

let preparePositionsGeneral (leftRead: Expr<'a -> 'c option>) =
    <@
        fun (ndRange: Range1D)
            (length: int)
            (leftValues: ClArray<'a>) ->

        let gid = ndRange.GlobalID0

        if gid < length  then
            let a = (%leftRead) leftValues.[gid]
            ()
    @>

let preparePositions opAdd =
    preparePositionsGeneral (left opAdd)

let ctx = ClContext(ClDevice.GetFirstAppropriateDevice())
ctx.Compile(preparePositions StandardOperations.float32Sum)
|> printfn "%A"

Workarounds
To use following function instead

let left (opAdd: Expr<'a option -> 'b option -> 'c option>) =
    <@
        fun (leftItem: 'a) ->
            let tmp = Some leftItem
            (%opAdd) tmp None
    @>

Additional context

  • OS: Windows 11
  • Brahma.FSharp: 2.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant