Skip to content

F# quotation to OpenCL translator and respective runtime to utilize GPGPUs in F# applications.

License

Notifications You must be signed in to change notification settings

simpletonDL/Brahma.FSharp

 
 

Repository files navigation

Brahma.FSharp

FAKE Build NuGet Badge NuGet Badge License

Brahma.FSharp provides a way to utilize GPGPU in your F# programs. It is based on F# quotations to OpenCL translation.

Features

  • Utilization of OpenCL for communication with GPU. So, you can work not only with NVIDIA devices but with any device which supports OpenCL (e.g. with AMD ot Intel devices).
  • Not only primitive types, but also discriminated unions, structs, records are supported.
  • Pattern matching, mutable and immutable bindings, nested bindings are supported.
  • Custom atomics.
  • Fine-grained memory management and kernels compilation process.
  • Mailbox processor based interface for communication with devices.

More details are available here.

Installation

Install Brahma.FSharp by running:

dotnet add package Brahma.FSharp

Setup BRAHMA_OCL_PATH environment variable to opencl.dll location if it differs from default.

Quick Start

open Brahma.FSharp

let device = ClDevice.GetFirstAppropriateDevice()
let context = RuntimeContext(device)

let kernel =
    <@
        fun (range: Range1D) (buffer: int clarray) ->
            let gid = range.GlobalID0
            buffer.[gid] <- buffer.[gid] + 1
    @>

opencl {
    use! buffer = ClArray.alloc<int> 1024
    do! runCommand kernel <| fun kernel ->
        kernel
        <| Range1D(1024, 256)
        <| buffer

    return! ClArray.toHost buffer
}
|> ClTask.runSync context

Contributing

Contributions, issues and feature requests are welcome. Feel free to check issues page if you want to contribute.

Build

Make sure the following requirements are installed on your system:

  • dotnet SDK 5.0 or higher
  • OpenCL-compatible device and respective OpenCL driver

To build and run all tests:

  • on Windows
build.cmd 
  • on Linux/macOS
./build.sh 

To find more options look at MiniScaffold. We use it in our project.

License

This project licensed under EPL-1.0 License. License text can be found in the license file.

About

F# quotation to OpenCL translator and respective runtime to utilize GPGPUs in F# applications.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • F# 71.8%
  • C# 24.2%
  • C 2.4%
  • CSS 1.0%
  • JavaScript 0.6%
  • Dockerfile 0.0%