Supported Features.
Translator supports only subset of F# language and this subset is described here.
Basic constructions
Array access
Array "by index" access is supported.
1: 2: 3: 4: |
|
Binding
Basic "let" binding is supported. Note, that now we support only "variable bindings". Nested functions, closures are not supported.
1: 2: 3: 4: 5: 6: |
|
Mutable binding
Mutability is available by using of "let mutable" binding.
1: 2: 3: 4: 5: |
|
Note, that scopes are supported. So, you can "rebind" any name and "F#-style" visibility will be emuleted in target code. For example, next code will be translated correctly.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: |
|
Local funtions
You can also use local funtions inside kernel. When compiled, they will be converted to OpenCL C functions.
1: 2: 3: 4: 5: 6: |
|
Expression ignore by |> ignore
1: 2: 3: 4: 5: |
|
Control flow
Almost all basic control flow operators are supported.
Sequential operations
1: 2: 3: 4: 5: |
|
WHILE loop
1: 2: 3: 4: 5: |
|
FOR integer range loop
1: 2: 3: 4: 5: |
|
Quotations injection
You can use "quotations injection" for code reusing or parameterization. For example, you can write something like this:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: |
|
Data types
Both host-kernel transferring and processing in kernels are supporeted for the following types. - Primitive types - Booleans - Custom structs - Records - Tuples - Discriminated unions
Structs
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: |
|
Tuples
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: |
|
Math operations
Supported functions from System.Math and Microsoft.FSharp.Core.Operators: abs acos asin atan cos cosh exp floor log log10 pow sin sinh sqrt tan tanh
OpenCL specific extensions
Global and local memory space
Use clarray
and clcell
types to use data located in global memory inside the kernel.
Use localArray
and local
to allocate data in local memory inside the kernel.
1: 2: 3: 4: 5: 6: 7: |
|
Synchronization barriers
barrierLocal
corresponds tobarrier(CLK_LOCAL_MEM_FENCE)
barrierGlobal
corresponds tobarrier(CLK_GLOBAL_MEM_FENCE)
barrierFull
corresponds tobarrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE)
Atomic functions
Use atomic
for atomic function call.
1: 2: 3: 4: |
|
namespace FSharp
--------------------
namespace Microsoft.FSharp
namespace FSharp.Quotations
--------------------
namespace Microsoft.FSharp.Quotations
type Range1D =
interface INDRange
new : globalWorkSize:int -> Range1D
new : globalWorkSize:int * localWorkSize:int -> Range1D
private new : globalWorkSize:int * localWorkSize:int * __:unit -> Range1D
member GlobalID0 : int
member GlobalWorkSize : int
member LocalID0 : int
member LocalWorkSize : int
static member CreateValid : neededSize:int * localWorkSize:int -> Range1D
--------------------
new : globalWorkSize:int -> Range1D
new : globalWorkSize:int * localWorkSize:int -> Range1D
module ClArray
from Brahma.FSharp
--------------------
type ClArray<'a> =
interface IBuffer<'a>
interface IClMem
interface IDisposable
private new : buffer:ClBuffer<'a> -> ClArray<'a>
member Dispose : unit -> unit
override ToString : unit -> string
member private Buffer : ClBuffer<'a>
member Item : idx:int -> 'a with get
member Length : int
member Item : idx:int -> 'a with set
val int : value:'T -> int (requires member op_Explicit)
--------------------
type int = int32
--------------------
type int<'Measure> = int
type StructAttribute =
inherit Attribute
new : unit -> StructAttribute
--------------------
new : unit -> StructAttribute
type MyStruct =
struct
new : x:int -> MyStruct
new : x:int * y:int -> MyStruct
val X: int
val Y: int
end
--------------------
MyStruct ()
new : x:int -> MyStruct
new : x:int * y:int -> MyStruct
val int64 : value:'T -> int64 (requires member op_Explicit)
--------------------
type int64 = System.Int64
--------------------
type int64<'Measure> = int64
type StructOfIntInt64 =
struct
new : x:int * y:int64 -> StructOfIntInt64
val mutable X: int
val mutable Y: int64
end
--------------------
StructOfIntInt64 ()
new : x:int * y:int64 -> StructOfIntInt64
val byte : value:'T -> byte (requires member op_Explicit)
--------------------
type byte = System.Byte
--------------------
type byte<'Measure> = byte
val float32 : value:'T -> float32 (requires member op_Explicit)
--------------------
type float32 = System.Single
--------------------
type float32<'Measure> = float32