FSCL Compiler
FSCL Compiler is a source-to-source compiler that translates quoted F# function calls and other contructs into valid C99 OpenCL kernel sources, enabling programming OpenCL-enabled parallel devices from within F#.
FSCL Repocontribute to FSCL on GitHub
FSCL Blogthe FSCL website where tutorials, benchmarks, ideas, updates are continuosly posted
FSCL on Twitterkeep up to date with all the FSCL news
How to get FSCL Compiler
Getting started with FSCL.Compiler
FSCL Compiler is able to produce valid OpenCL source code from quoted expressions containing:
- The name (ref) or call to an FSCL kernel
- The name (ref) or call to a Array collection function (e.g. Array.reverse, Array.map2)
- The name (ref) or call to a "regular" function or static/instance method
An FSCL kernel is an F# function or static/instance method marked with [
__kernel void vectorAdd(__global float * a, __global const float * b, __global float * c) { int myId = get_global_id(0); c[myId] = a[myId] + b[myId]; }
In FSCL, the same kernel can be coded as follows:
1: 2: 3: 4: 5: 6: 7: 8: |
|
The major difference between an OpenCL kernel written in C and the equivalent in FSCL is the additional parameter of type WorkItemInfo, which contains all the functions related to the work items domain (including barrier). Whereas in OpenCL C programmers you use global functions like getglobalid() and getlocalsize(), in FSCL you invoke matching functions exposed by the additional parameter (wi.GlobalId(), wi.LocalSize()).
To compile an FSCL kernel to OpenCL, you need to instantiate the FSCL Compiler and to pass the quoted kernel call or reference to the Compile method.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: |
|
Tutorials and Documentation
The FSCL Compiler API documentation is under development and will be available soon. In the meantime, take a look to the following tutorials.
Kernel Programming Tutorialprogram parallel kernels in F#.
Compiler Interface Tutorialturn F# computations into OpenCL kernel sources.
Dynamic Metadata Tutorialuse the Dynamic Metadata Infrastructure to drive kernels compilation.
Compiler Configuration Tutorialconfigure the FSCL Compiler in prototyping, testing and production environments.
Compiler Customisation and Extension Tutorialcustomise and extend the FSCL Compiler pipeline via plugins.
Contributing and copyright
The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding new public API, please also consider adding samples that can be turned into a documentation. You might also want to read library design notes to understand how it works.
The library is available under Apache 2.0 license. For more information see the License file in the GitHub repository.
type ReflectedDefinitionAttribute =
inherit Attribute
new : unit -> ReflectedDefinitionAttribute
Full name: Microsoft.FSharp.Core.ReflectedDefinitionAttribute
--------------------
new : unit -> ReflectedDefinitionAttribute
Full name: Index.VectorAdd
val float32 : value:'T -> float32 (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.float32
--------------------
type float32 = System.Single
Full name: Microsoft.FSharp.Core.float32
--------------------
type float32<'Measure> = float32
Full name: Microsoft.FSharp.Core.float32<_>
Full name: Index.compiler
Full name: Index.resultCompilingRef
Full name: Index.a
from Microsoft.FSharp.Collections
Full name: Microsoft.FSharp.Collections.Array.create
Full name: Index.b
Full name: Index.c
Full name: Microsoft.FSharp.Collections.Array.zeroCreate
Full name: Index.size
Full name: Index.resultCompilingCall