fpga

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package fpga provides zero-CGo bindings to FPGA runtime libraries via purego/dlopen. It supports Intel FPGA OpenCL Runtime (libintel_fpga_opencl) and Xilinx XRT (libxrt_coreutil) for accelerating ML inference on FPGAs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available() bool

Available returns true if an FPGA runtime is available on this machine.

func GetDeviceCount

func GetDeviceCount() (int, error)

GetDeviceCount returns the number of FPGA accelerator devices.

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context holds an FPGA device context, command queue, and related state.

func NewContext

func NewContext(deviceID int) (*Context, error)

NewContext creates an FPGA context on the specified device.

func (*Context) CreateStream

func (c *Context) CreateStream() (*Stream, error)

CreateStream creates a new command queue.

func (*Context) Destroy

func (c *Context) Destroy() error

Destroy releases the FPGA context resources.

func (*Context) DeviceID

func (c *Context) DeviceID() int

DeviceID returns the device ordinal.

func (*Context) Free

func (c *Context) Free(ptr unsafe.Pointer) error

Free releases FPGA device memory.

func (*Context) Malloc

func (c *Context) Malloc(size int) (unsafe.Pointer, error)

Malloc allocates device memory on the FPGA.

func (*Context) Memcpy

func (c *Context) Memcpy(dst, src unsafe.Pointer, count int, kind MemcpyKind) error

Memcpy copies data between host and FPGA device memory.

type FPGALib

type FPGALib struct {
	// contains filtered or unexported fields
}

FPGALib holds dlopen handles and resolved function pointers for the FPGA runtime. Currently supports Intel FPGA OpenCL Runtime and Xilinx XRT. Function pointers are resolved at Open() time via dlsym.

func Lib

func Lib() *FPGALib

Lib returns the global FPGALib instance, or nil if not available.

func Open

func Open() (*FPGALib, error)

Open loads the FPGA runtime library via dlopen and resolves required function pointers. It tries OpenCL (which both Intel and Xilinx runtimes expose) first.

type MemcpyKind

type MemcpyKind int

MemcpyKind specifies the direction of a memory copy.

const (
	MemcpyHostToDevice MemcpyKind = iota
	MemcpyDeviceToHost
	MemcpyDeviceToDevice
)

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

Stream wraps an FPGA command queue for stream-like semantics.

func (*Stream) Destroy

func (s *Stream) Destroy() error

Destroy releases the command queue.

func (*Stream) Ptr

func (s *Stream) Ptr() unsafe.Pointer

Ptr returns the underlying command queue handle as unsafe.Pointer.

func (*Stream) Synchronize

func (s *Stream) Synchronize() error

Synchronize waits for all commands in the queue to complete.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL