Send Feedback
Skip to content

Fusionx for KDB-X

This page introduces the Fusionx module for KDB-X. Learn what Fusionx is in KDB-X and how to use it.

Overview

Fusionx is a lightweight and extensible module for KDB-X that simplifies the use of native libraries within your q environment.

It provides pre-built wrappers around common C libraries (e.g., BLAS, PCRE2), so you can call high-performance native functions directly from q without recompiling or managing dependencies manually.

Fusionx is designed for portability, performance, and flexibility. It works across all major Linux distributions and library versions. You only need to build it once, and it supports any compatible environment out of the box.

Getting started

  1. Environment setup

    Before using Fusionx, extract the appropriate .so file from the Fusionx Github repo and copy it to the mod directory of your KDB-X installation. For example:

    unzip fusion.zip
    cp fusion.li64.so $HOME/.kx/mod/kx
    

    This allows q to locate and load the Fusionx library.

  2. Listing available modules

    To list the Fusionx available modules, run the following in q:

    q)fusion:use`kx.fusion
    q)fusion.libs[]
    ``blas`pcre2`
    

    Each entry corresponds to a native module that Fusionx can load.

  3. Using a module

    Modules in Fusionx are organized as dictionaries of functions. You can load a specific module and inspect its functions as follows:

    q)use`kx.fusion:pcre
    version| `.m.fusion.pcre2.export.version[]
    match  | `.m.fusion.pcre2.export.match[]
    replace| `.m.fusion.pcre2.export.replace[]
    

    This exposes the functions available in the selected module.

Namespace flexibility

Fusionx is intentionally designed not to modify q namespaces automatically. You have full control over how and where to load modules and functions.

For example:

q).pcre2   :use`kx.fusion:pcre2 /namespace 
q)pcre2    :use`kx.fusion:pcre2 /directory
q)([match]):use`kx.fusion:pcre2 /one function

This flexibility makes it easy to integrate Fusionx into existing workflows or libraries without namespace conflicts.

Building and extending Fusionx

Fusionx is built once and works with all distributions and library versions, eliminating the need for repeated compilation. Testing across different environments is managed using docker.q.

To add new modules:

  1. Create a new directory for your module.

  2. Define the module in the Makefile under modules :=.

  3. Implement the C wrapper (see pcre2/pcre2.c for an example).

Fusionx automatically detects and exposes new modules, making it simple to extend.

Next steps

Learn more about: