Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ymd-h/veclib-zig

SIMD based Vector Library for Zig
https://github.com/ymd-h/veclib-zig

simd zig

Last synced: 2 months ago
JSON representation

SIMD based Vector Library for Zig

Awesome Lists containing this project

README

        

# veclib.zig: SIMD based Vector Computing Library

> [!WARNING]
> This project is still under development.

veclib utilizes Zig standard SIMD vector calculation.
Aside from the standard, veclib supports scalar-vector mixed calculation
and runtime-known length slice handling.

## Features

- Nullary Function
- `iota`
- Element-wise Unary Function (`f(comptime T: type, arg: anytype, out: []T) void`)
- `copy`
- `sqrt`
- `sin`, `cos`, `tan`
- `exp`, `exp2`, `exp1m`
- `log`, `log2`, `log10`, `log1p`
- `abs`
- `floor`, `ceil`, `trunc`, `round`
- `byteSwap`, `bitReverse`
- `countLeadingZeros`, `countTrailingZeros`, `popCount`
- Element-wise Binary Function (`f(comptime T: type, arg1: anytype, arg2: anytype, out: []T) void`)
- `add`, `wrapAdd`, `saturateAdd`
- `sub`, `wrapSub`, `saturateSub`
- `mul`, `wrapMul`, `saturateMul`,
- `div`, `divFloor`, `divTrunc`, `rem`, `mod`
- `bitAnd`, `bitOr`, `bitXor`
- `min`, `max`
- Element-wise Binary Comparison (`f(comptime T: type, arg1: anytype, arg2: anytype, out: [] bool) void`)
- `eq`, `neq`, `gt`, `gte`, `lt`, `lte`,
- Ternary Function (`f(comptime T: type, arg1: anytype, arg2: anytype, arg3: anytype, out: []T)`)
- `mulAdd`
- `clip`
- Reduction Function (`f(comptime T: type, arg: []const T) T`)
- `sum`, `wrapSum`, `saturateSum`,
- `prod`, `wrapProd`, `saturateProd`,
- `smallest`, `largest`,
- `all`, `any`

We use `anytype` for type inference, however, there some limitations.
- `arg` at element-wise functions can be scalar or slice.
- scalar value will be broadcsted (not to slice size, but to SIMD vector size)
- Not all types are supported at some functions.
- e.g. Bit-wise operations are only supported for integer types.