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

https://github.com/jackmott/nim_simd

Nim experiment for a write once run optimum simd anywhere *at runtime* library
https://github.com/jackmott/nim_simd

Last synced: about 1 year ago
JSON representation

Nim experiment for a write once run optimum simd anywhere *at runtime* library

Awesome Lists containing this project

README

          

# nim_simd

This is an experiment / proof of concept to use Nim's metaprogramming to provide an easy to use SIMD abstraction layer.
The goal is for users of the library to be able to write blocks of code containing SIMD intrinsics *one time* and end up with optimum
or near optimum SIMD instructions being used at runtime according to the users hardware. If you are interested in this, you may be interested in my other Rust library, which is a more complete version of the same idea: [SIMDeez](https://github.com/jackmott/simdeez)

How this will work:

* The user will write a block of code containing SIMD intrinsics using the `simd:` macro
* At *compile time* the macro will produce all desired simd versions of the block. sse, sse2, avx, and so on
* At *run time* the simd instructions available on the computer will be detected, and the appropriate version of the code block will be executed

# Progress So Far:

See simd.nim for the proof of concept so far. Already you can write code like this successfully:

```nim
var
a = newSeq[float32](12)
b = newSeq[float32](12)
r = newSeq[float32](12)

for i,v in a:
a[i] = float32(i)
b[i] = 2.0'f32

SIMD:
for i in countup(0,