Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Assembly
C
Carbon
C++ (Circle)
CIRCT
Clean
CMake
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Crystal
C#
CUDA C++
D
Dart
Erlang
Fortran
F#
Go
Haskell
HLSL
ispc
Java
Kotlin
LLVM IR
Nim
OCaml
OpenCL C
Pascal
Pony
Python
Ruby
Rust
Scala
Solidity
Swift
Toit
TypeScript Native
Visual Basic
Zig
ispc source #1
Output
Compile to binary
Execute the code
Intel asm syntax
Demangle identifiers
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Compiler
ispc (trunk)
ispc 1.10.0
ispc 1.11.0
ispc 1.12.0
ispc 1.13.0
ispc 1.14.0
ispc 1.14.1
ispc 1.15.0
ispc 1.16.0
ispc 1.16.1
ispc 1.17.0
ispc 1.18.0
ispc 1.9.1
ispc 1.9.2
Options
Source code
export uniform float dot_product(const float* uniform a, const float* uniform b, uniform size_t size) { varying float acc = 0.0f; size = size & ~31; // let the compiler know size is multiple of 32 foreach(i = 0...size) { varying float suba = a[i]; varying float subb = b[i]; acc += suba * subb; } return reduce_add(acc); } export uniform float dot_product_multiple_acc(const float* uniform a, const float* uniform b, uniform size_t size) { varying float acc1 = 0.0f; varying float acc2 = 0.0f; size = size & ~31; // let the compiler know size is multiple of 32 for (uniform size_t base = 0; base < size; base += programCount * 2) { varying size_t i1 = base + programIndex; varying size_t i2 = base + programCount + programIndex; varying float suba1 = a[i1]; varying float subb1 = b[i1]; varying float suba2 = a[i2]; varying float subb2 = b[i2]; acc1 += suba1 * subb1; acc2 += suba2 * subb2; } return reduce_add(acc1 + acc2); }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
About the author
Changelog
Version tree