ixl-go

module
v0.0.0-...-9bd9f91 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: BSD-3-Clause

README

Intel Accelerators User Library for Go

The project is aimed to develop Go library of IAA/DSA to empower cloud native industry. IAA/DSA is introduced by 4th Gen Intel(R) Xeon(R) Scalable Processor which was launched on Jan'23.

Supported Hardware Accelerator Features

  • Compression/Decompression
    • Deflate
    • Gzip
  • CRC calculation
  • Data Filter (Bitpack / RLE format / Int Array):
    • Expand
    • Select
    • Scan
    • Extract
  • Data Move

Advantages

The library is designed to be a lightweight pure Go language implementation with zero dependencies.

  • Lower barriers to use for users, no need to install dependency libraries in advance.
  • No CGO performance overhead.
  • Easy to learn and start.

How to use

Installation

Use the following commands to add ixl-go as a dependency to your existing Go project.

go get github.com/intel/ixl-go

Quick Start

To use the accelerated functions you need IAA or DSA devices on your machine.

You can use Ready function to check if the devices are OK for ixl-go.

Notice:

we don't support non-svm environment for now.

We only support workqueues which enabled block_on_fault and SVM.

If you don't know about how to config IAA/DSA workqueues, you can follow this simple recipe.

Example1: Compress/Decompress
package main

import (
	"bytes"
	"flag"
	"io"
	"log"
	"os"

	"github.com/intel/ixl-go/compress"
)

var f = flag.String("f", "", "file to compress")

func main() {
	flag.Parse()
	if !compress.Ready() {
		log.Fatalln("IAA workqueue not found")
		return
	}
	if *f == "" {
		log.Fatalln("must give a file to compress")
	}
	// gzip example:
	file, err := os.Open(*f)
	if err != nil {
		log.Fatalln("open file failed:", err)
	}
	output, err := os.Create(*f + ".gz")
	if err != nil {
		log.Fatalln("create file failed:", err)
	}
	w := compress.NewGzip(output)
	w.ReadFrom(file)
	w.Close()
	file.Close()
	output.Close()

	// deflate example:
	file, err = os.Open(*f)
	if err != nil {
		log.Fatalln("open file failed:", err)
	}
	buf := bytes.NewBuffer(nil)
	d, err := compress.NewDeflate(buf)
	if err != nil {
		log.Fatalln("NewDeflate failed:", err)
	}
	d.ReadFrom(file)
	d.Close()

	// inflate example
	i, err := compress.NewInflate(buf)
	if err != nil {
		log.Fatalln("NewInflate failed:", err)
	}
	block := make([]byte, 1024)
	for {
		_, err := i.Read(block)
		if err != nil {
			if err != io.EOF {
				log.Fatalln("error:", err)
			}
			break
		}
	}
}

Example2: CRC Calculation
c, err := crc.NewCalculator()
if err != nil{
	return err
}
result, err := c.CheckSum64(data, crc64.ISO)
Example3: Data Copy
datamove.Copy(output, input)

Documentation

module doc accelerator
compress compress IAA
crc crc IAA/DSA
filter filter IAA
datamove datamove DSA
util/mem util/mem _

FAQ

Why is the compression API not the same as compress/flate or compress/gzip?

There are several reasons for this:

  1. flate and gzip packages provide a parameter called level to tune the compression speed. IAA compression is different from software, it doesn't have a tuning "button" to set the compression level.

  2. Compress.Deflate does not implement an io.Writer interface, instead it provides a ReadFrom method. The main reason is that ReadFrom does not need to copy the data everytime and maintain a 64k+ buffer. If you want an io.Writer, you can wrap it using the compress.BufWriter:

     d, err := compress.NewDeflate(underWriter)
     if err != nil {
     	log.Fatalln("NewDeflate failed:", err)
     }
     w := compress.NewWriter(d)
     // or using new API
     w = compress.NewDeflateWriter(underWriter)
    
    

    Be aware of the data copy overhead and the memory overhead.

Why I got a "no DSA device detected" or "no hardware device detected" error?

First, please check your CPU platform, make sure you have IAA or DSA devices.

ls -df /sys/bus/dsa/devices/dsa* # lists all DSA devices if present. Only <path>/dsa<id> are devices.
ls -df /sys/bus/dsa/devices/iax* # lists all IAA devices if present.

Then, use the command below to check whether the workqueues have been configured.

accel-config list

And the most common reason for the problem is that the application is not running as root, try again with sudo.

By default, DSA and IAA workqueues must be used under root permission.

If you want to use the hardware under a non-privileged account, for example, grant IAA/wq1.0 permission to your foo account, try this:

sudo setfacl -m u:foo:rw /dev/iax/wq1.0

Directories

Path Synopsis
Package compress provides hardware compression ability (IAA).
Package compress provides hardware compression ability (IAA).
internal/codelencode
Package codelencode provides a function to prepare the code len code.
Package codelencode provides a function to prepare the code len code.
internal/codelencode/avx2
Package avx2 provides avx2 version PrepareForCodeLenCode
Package avx2 provides avx2 version PrepareForCodeLenCode
internal/codelencode/avx512
Package avx512 provides avx512 version PrepareForCodeLenCode
Package avx512 provides avx512 version PrepareForCodeLenCode
internal/codelencode/sse2
Package sse2 provides sse2 version PrepareForCodeLenCode
Package sse2 provides sse2 version PrepareForCodeLenCode
internal/huffman
Package huffman provices some implementations of different algorithms for generating Huffman trees.
Package huffman provices some implementations of different algorithms for generating Huffman trees.
Package crc provides CRC calculation functions which leverage IAA hardware.
Package crc provides CRC calculation functions which leverage IAA hardware.
Package datamove provides functions which leverages DSA hardware abilities to copy memory.
Package datamove provides functions which leverages DSA hardware abilities to copy memory.
Package errors provides detailed error types for ixl-go.
Package errors provides detailed error types for ixl-go.
examples
Package filter provides some functions for processing parquet RLE or bitpacked data or uint array.
Package filter provides some functions for processing parquet RLE or bitpacked data or uint array.
internal
config
Package config is used to collect the devices configurations on the machine.
Package config is used to collect the devices configurations on the machine.
device
Package device provides an interface for interacting with DSA/IAA devices.
Package device provides an interface for interacting with DSA/IAA devices.
dsa
Package dsa provides some useful types and functions for enable Intel DSA Engine.
Package dsa provides some useful types and functions for enable Intel DSA Engine.
errors
Package errors provides detailed error types for ixl-go, should be used by internal packages.
Package errors provides detailed error types for ixl-go, should be used by internal packages.
iaa
Package iaa provides utils for using IAA abilities.
Package iaa provides utils for using IAA abilities.
log
Package log provides internal used log function like Debug and Info.
Package log provides internal used log function like Debug and Info.
software/filter
Package filter provides some useful function for test filter.
Package filter provides some useful function for test filter.
testutil
Package testutil provides some useful functions for test.
Package testutil provides some useful functions for test.
util
mem
Package mem declares functions for allocating memory that is aligned to specific byte boundaries.
Package mem declares functions for allocating memory that is aligned to specific byte boundaries.

Jump to

Keyboard shortcuts

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