Code Monkey home page Code Monkey logo

fscl.compiler's Introduction

FSharp to OpenCL Compiler

NuGet Status

FSCL.Compiler is an F# to OpenCL C99 compiler to enhance GPGPU and raise abstraction over heterogeneous programming, allowing programmers to develop and compose OpenCL kernels inside .NET, with all the benefits of code-completion, type-checking and many other facilities provided by the .NET visual machine environment. FSCL.Compiler currently supports all the features of OpenCL Specification v1.2 except for the image-related processing, which is under development.

The FSCL framework (Compiler and Runtime) is part of a Ph.D. Thesis: FSCL: homogeneous programming and execution on heterogeneous platforms

Resources

fscl.compiler's People

Contributors

cloudroutine avatar gabrielecocco avatar quezlatch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fscl.compiler's Issues

Array.map not automatically translated within a kernel?

Is it possible to use Array.map within a kernel, like the accelerated collection support?
This code:

[<ReflectedDefinition>]
let Distance (p1 : int2) (p2:int2) =
    let d = p1 - p2
    let d2 = d * d
    sqrt(float32 (d2.x + d2.y))    

[<ReflectedDefinition>]
let SumDistances(xy : int2, points : int2[]) = 
    let dist = points |> Array.map (fun p -> Distance xy p)
                      |> Array.sum
    dist

Throws the exception

Unrecognized construct in kernel body Lambda (array,
Call (None, Map, [Lambda (p, Call (None, Distance, [xy, p])), array]))

I also tried Array.map (Distance xy) or a tupled function Distance(p1, p2)

Support fp64 opencl

Most of the examples on your wiki and unit tests use float32. My use case requires the use of the 'float' f# data type. This of course compiles OK but doesn't run due to the missing OpenCL preprocessor directive. See https://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/cl_khr_fp64.html.

Is there a way to add this to the compile step myself? Or have it as a feature that when it detects the use of the float type it automatically puts this in the generated code? Documentation provided doesn't tell me how to do it. Thanks.

Invalid code generated, missing ;

#r "src/FSCL.Compiler/bin/Release/FSCL.Compiler.Core.dll" 
#r "src/FSCL.Compiler/bin/Release/FSCL.Compiler.Language.dll" 
#r "src/FSCL.Compiler/bin/Release/FSCL.Compiler.dll" 
#r "src/FSCL.Compiler/bin/Release/FSCL.Compiler.Util.dll" 
#r "src/FSCL.Compiler/bin/Release/FSCL.Compiler.NativeComponents.dll" 

open FSCL.Language
open FSCL.Compiler

type Point =
  struct
   
  end

[<ReflectedDefinition;Kernel>]
let computePattern (point: Point) = ()

[<ReflectedDefinition;Kernel>]
let populateValues (valueArray: float32 [,]) (points: Point array) (wi: FSCL.Compiler.WorkItemInfo) =
  let gid = wi.GlobalID(0)
  do
    let point = points.[gid]
    
    let maxX = 100
    let maxY = 100

    computePattern point
      
    wi.LocalBarrier()
    for x in 0 .. maxX - 1 do
      for y in 0 .. maxY - 1 do
        let xx = x 
        let yy = y
        let v = 0.f
        valueArray.[xx, yy] <- valueArray.[xx, yy] + v
    wi.LocalBarrier()
   
let valueArray = Array2D.create 1000 1000 0.f
let points = Array.create 1000 Unchecked.defaultof<Point>

let worksize = WorkSize(4096L, 64L)
let compiler = new Compiler()
let compiled = compiler.Compile(<@ populateValues valueArray points worksize @>, Map.empty)

(compiled :?> KernelExpression).KernelNodes.[0].Module.Code

(<@ populateValues valueArray points worksize @>).Run()

this results in this generated code:

struct Point {
};






kernel void populateValues(global float* valueArray, global struct Point* points, private int valueArray_length_0, private int valueArray_length_1, private int points_length_0){
int gid = get_global_id(0);
struct Point point = points[gid];
int maxX = 100;
int maxY = 100;
computePattern(point)
barrier(CLK_LOCAL_MEM_FENCE);
for(int x = 0; x <= (maxX) - (1);x++) {
for(int y = 0; y <= (maxY) - (1);y++) {
int xx = x;
int yy = y;
float v = 0;
valueArray[((xx) * (valueArray_length_1)) + (yy)] = (valueArray[((xx) * (valueArray_length_1)) + (yy)]) + (v);

}

}

barrier(CLK_LOCAL_MEM_FENCE);;
}

Notice the missing ; after computePattern(point), I believe this is a bug.

Build fails on OSX

Hello,

I just checked out this project, and tried to build it (build.sh) and I'm getting a lot of build errors. This weekend, I may be able to try and look into more why this is happening, but I figured it worth giving what I ran into now.

wireless-nat-inside:FSCL.Compiler dthole$ fsharpc --version
F# Compiler for F# 4.0 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License

The build errors I'm getting are:

/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(101,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(104,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(118,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(121,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(136,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(144,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(156,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(159,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(174,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(177,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(192,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(195,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(210,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(213,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(228,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(231,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(246,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/KernelContextTest.fs(249,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(171,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(174,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(188,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(191,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(205,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(208,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(222,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(225,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(239,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(250,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(261,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(264,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(278,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(281,12): error FS0039: The field, constructor or member 'NotNull' is not defined
/Users/dthole/Programming/FSCL.Compiler/tests/FSCL.Compiler.Tests/FunctionContextTest.fs(295,12): error FS0039: The field, constructor or member 'NotNull' is not defined

Implement OpenCL image processing

OpenCL allows to work on images (e.g. image2d). There's need to map this subsystem to FSCL, managing compilation of kernels working on images. High level type for images could be .NET System.Drawing Bitmap:https://msdn.microsoft.com/it-it/library/system.drawing.bitmap(v=vs.110).aspx.

High level image types must map to OpenCL image types properly, while .NET access to bitmaps (e.g. GetPixel()) must map accordingly to OpenCL functions.

Also, FSCL runtime must be extended to handle bitmap data transfer efficiently (LockBits?)

Marshalling Exception when running Computation Sample

Getting Marshalling Exception when running computation sample. Exception is occuring in call to new HostSideDataHandle(array) in BufferPoolManager.EndOperationOnBuffer as the data field is seen to be an object. With a little instrumentation of the code and adding a try when statement I got the following output at the console which may help you resolve the situation.

Testing [ Accelerated Record Vector Reduce With Utility Function ]

Using HostSideDataHandle in CreateTrackedBuffer
Using HostSideDataHandle in Constructor of BufferPoolItem
Using HostSideDataHandle in Constructor of BufferPoolItem
Using Host Side Data Handle in PromoteUntrackedToTracked
Using HostSideDataHandle in EndOperationOnBuffer
Type 'System.Object' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
at System.Runtime.InteropServices.Marshal.SizeOfHelper(Type t, Boolean throwIfNotMarshalable)
at System.Runtime.InteropServices.Marshal.SizeOf(Type t)
at FSCL.Runtime.Managers.HostSideDataHandle.BeforeTransferToDevice() in C:\WEDEV\FSCL.Runtime\src\FSCL.Runtime.Execution\BufferPoolManager.fs:line 60
[ Accelerated Record Vector Reduce With Utility Function ] returned a wrong result!

Testing [ Accelerated Record Vector Reduce With Lambda ]

Using HostSideDataHandle in CreateTrackedBuffer
Using HostSideDataHandle in Constructor of BufferPoolItem
Using HostSideDataHandle in Constructor of BufferPoolItem
Using Host Side Data Handle in PromoteUntrackedToTracked
Using HostSideDataHandle in EndOperationOnBuffer
Type 'System.Object' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
at System.Runtime.InteropServices.Marshal.SizeOfHelper(Type t, Boolean throwIfNotMarshalable)
at System.Runtime.InteropServices.Marshal.SizeOf(Type t)
at FSCL.Runtime.Managers.HostSideDataHandle.BeforeTransferToDevice() in C:\WEDEV\FSCL.Runtime\src\FSCL.Runtime.Execution\BufferPoolManager.fs:line 60
[ Accelerated Record Vector Reduce With Lambda ] returned a wrong result!
::::::::::::::::::::::::::::::::::::::::::::::::::::

I have just started looking into your library for use in our system and it looks pretty good

Cannot determine the parameter referred by the kernel body X

I'm trying to make this code compile, this is put in a .fsx file at the root of this project for quick testing:

#r "src/FSCL.Compiler/bin/Release/FSCL.Compiler.Core.dll" 
#r "src/FSCL.Compiler/bin/Release/FSCL.Compiler.Language.dll" 
#r "src/FSCL.Compiler/bin/Release/FSCL.Compiler.dll" 
#r "src/FSCL.Compiler/bin/Release/FSCL.Compiler.Util.dll" 
#r "src/FSCL.Compiler/bin/Release/FSCL.Compiler.NativeComponents.dll" 

open FSCL.Language
open FSCL.Compiler

type Point =
  struct
   
  end

[<ReflectedDefinition;Kernel>]
let computePattern (point: Point) = ()

[<ReflectedDefinition;Kernel>]
let populateValues (valueArray: float32 [,]) (points: Point array) (wi: FSCL.Compiler.WorkItemInfo) =
  let gid = wi.GlobalID(0)
  do
    let point = points.[gid]
    
    let maxX = 100
    let maxY = 100

    let vA = Array2D.create maxX maxY 0.f
    computePattern point
      
    wi.LocalBarrier()
    for x in 0 .. maxX - 1 do
      for y in 0 .. maxY - 1 do
        let xx = x 
        let yy = y
        let v = vA.[x,y]
        valueArray.[xx, yy] <- valueArray.[xx, yy] + v
    wi.LocalBarrier()
   
let valueArray = Array2D.create 1000 1000 0.f
let points = Array.create 1000 Unchecked.defaultof<Point>

let worksize = WorkSize(4096L, 64L)
let compiler = new Compiler()
let compiled = compiler.Compile(<@ populateValues valueArray points worksize @>, Map.empty)

this gives

FSCL.Compiler.CompilerException: Cannot determine the parameter referred by the kernel body vA
   at FSCL.Compiler.FunctionTransformation.ArrayAccessTransformation.GetPlaceholderVar(FSharpVar var, FunctionTransformationStep engine) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\ArrayAccessFlattening.fs:line 59
   at FSCL.Compiler.FunctionTransformation.ArrayAccessTransformation.Run(Tuple`3 _arg1, ICompilerStep en, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\ArrayAccessFlattening.fs:line 92
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 38
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 38
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 38
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 38
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 38
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 38
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 38
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
>    at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 38
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 38
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at <StartupCode$FSCL-Compiler-NativeComponents>[email protected](FSharpExpr el) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Default(ICompilerStepProcessor proc, FSharpMap`2 opts, FSharpExpr expression) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 43
   at FSCL.Compiler.CompilerStepProcessor`2.Execute(Object obj, ICompilerStep step, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.Core\CompilerStep.fs:line 100
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Process(FunctionInfo f, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 53
   at FSCL.Compiler.FunctionTransformation.FunctionTransformationStep.Run(KernelExpression cem, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler.NativeComponents\FunctionTransformation\FunctionTransformationStep.fs:line 59
   at FSCL.Compiler.Configuration.Pipeline.Run(Object input, FSharpMap`2 opts) in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\src\FSCL.Compiler\Pipeline.fs:line 171
   at <StartupCode$FSI_0003>.$FSI_0003.main@() in C:\dev\src\projects\github.com\fscl\FSCL.Compiler\sample.fsx:line 44

I'm not able to find a work around (in my code) so any help would be apreciated.

I haven't looked at the compiler code itself, but any guidance would be helpful as well ๐Ÿ˜ƒ

KernelExpressionSample crashes

In the May 30th changeset
The KernelExpressionSample crashes constructing a FunctionInfo while compiling MatrixAddOver.
It happens because signature.GetParameters() has 3 entries, but parameters only has 2 entries (this and a 3-tuple).

Perform extensive testing on kernel composition

In FSCL, kernels can be composed using the pipe operators and high order collection functions.
Kernel composition by pipelining:

<@ input |> myKernel1 |> myKernel2 @>.Run()

Kernel composition by high order collection functions:

<@ Array.map(fun x -> myKernel1(x)) @>.Run()

Kernel composition using higher order functions -and- pipelining:

<@ Array.map(fun x -> x |> myKernel1 |> myKernel2) |> myKernel3 @>.Run()

There's need to extensively test all the cases above to ensure compilation is correct.

Port to C#

Hi,

first I wanted to tank you for the awesome library!
I have a bare-bones image platform written in C# DotImaging that could benefit from OpenCL (its primitive is .NET array).

I was wondering how much effort is needed to convert/enable this library for C# ?

Thanks!

Implement OpenCL 2.x kernel side scheduling

In OpenCL 2.x, kernels can schedule other kernels for execution. For this reason, the restriction imposed by FSCL for which a function that calls a kernel cannot map to a kernel (it's instead executed on the host) is not needed anymore.
The compiler must be able to check the OpenCL version available (could be passed as a compiler option by the runtime, alternatively) and, in case of 2.0+, generate kernel code even for functions that call kernels.

The KFG (Kernel Flow Graph, which is the representation of the structure of an FSCL computation) must be extended. Now it contains "before-after" relationship (e.g. a |> b), sub-expression coordination (e.g. Array.reduce(fun) where fun is a kernel or composition of kernels) and kernel/sequential function nodes.
In OpenCL 2.x, the relationship "kernel A calling kernel B" might need modeling in order to provide enough information to the runtime for the execution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.