Skip to main content

futhark-ffi

Test

Python library using the Futhark C backend via CFFI

Futhark provides several compiler backends, for example futhark opencl which is a C backend, and futhark pyopencl which is a Python backend based on PyOpenCL. However, the host-side code of the Python backend is quite slow, leading to a lot of overhead when small, frequent kernels are used.

A solution to reduce this overhead is to use CFFI to used the C backend from Python, greatly reducing the calling overhead. The OpenCL code is the same, so this is not interesting for long-running kernels.

This library supports the following Futhark backends: c, opencl, multicore, and cuda.

Futhark arrays are mapped to and from Numpy arrays. Multiple outputs and multi-dimensional arrays are supported.

Installation

Install Futhark, then simply

pip install futhark-ffi

Usage

Generate a C library, and build a Python binding for it

futhark opencl --library test.fut
build_futhark_ffi test

Use the Python wrapper

import numpy as np
import _test
from futhark_ffi import Futhark

test = Futhark(_test)
res = test.test3(np.arange(10))
test.from_futhark(res)

Example usage

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

futhark_ffi-0.16.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

futhark_ffi-0.16.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file futhark_ffi-0.16.0.tar.gz.

File metadata

  • Download URL: futhark_ffi-0.16.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for futhark_ffi-0.16.0.tar.gz
Algorithm Hash digest
SHA256 6a467d9982f47f000c062726eb7d0821fbc669b0d75d318e03814e81fad6c286
MD5 784e47a308aff4f944153e97331e5571
BLAKE2b-256 5f7c448184476f0aa2b30ac07ba03f730340fdc15defaf6cb8ef1888ba1ea161

See more details on using hashes here.

File details

Details for the file futhark_ffi-0.16.0-py3-none-any.whl.

File metadata

  • Download URL: futhark_ffi-0.16.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for futhark_ffi-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8cb9c4912d14886fc555d2a59ec780e2b4d1fc32739ff1f89f667b09ca8c0ba7
MD5 e7866b2eeabc09005d071000806ae7af
BLAKE2b-256 fa0fb53647f50086be973205d9d340fca5cd938be86497ac60c363863dccffa2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.16.0 This release

2 files

0.15.0

2 files

0.14.2

2 files

0.14.1

2 files

0.14.0

2 files

0.13.0

2 files

0.12.0

2 files

0.11.0

2 files

0.10.2

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page