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
- Host: GitHub
- URL: https://github.com/jackmott/nim_simd
- Owner: jackmott
- License: mit
- Created: 2017-12-12T15:13:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-30T16:59:25.000Z (almost 8 years ago)
- Last Synced: 2025-02-10T04:41:43.487Z (over 1 year ago)
- Language: Nim
- Size: 376 KB
- Stars: 30
- Watchers: 6
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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,