Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Algol68
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C with Coccinelle
C++ with Coccinelle
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Mojo
Nim
Numba
Nix
Objective-C
Objective-C++
OCaml
Odin
OpenCL C
Pascal
Pony
PTX
Python
Racket
Raku
Ruby
Rust
Sail
Snowball
Scala
Slang
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
Triton
TypeScript Native
V
Vala
Visual Basic
Vyper
WASM
Zig
Javascript
GIMPLE
Ygen
sway
ispc source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
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.19.0
ispc 1.20.0
ispc 1.21.0
ispc 1.22.0
ispc 1.23.0
ispc 1.24.0
ispc 1.25.0
ispc 1.25.3
ispc 1.26.0
ispc 1.27.0
ispc 1.28.0
ispc 1.28.1
ispc 1.9.1
ispc 1.9.2
Options
Source code
struct float2_SoA { float* x; float* y; }; typedef float<3> float3; static uint seed = 0x12345678; inline uint RandomUInt() { seed ^= seed << 13; seed ^= seed >> 17; seed ^= seed << 5; return seed; } #pragma ignore warning //uint to float is slow inline float RandomFloat() { return RandomUInt() * 2.3283064365387e-10f; } unmasked void ParticleSystem_Tick( const uniform int32 count, uniform float2_SoA &pos, uniform float2_SoA &dir, uniform uint32 frame[], const uniform int32 frameChange[], const uniform int32 mapWidth, const uniform int32 mapHeight, const uniform float3 peaks[], const uniform int32 peaksSize ) { float mapWidthMinusOnef = (float) (mapWidth-1); float mapHeightf = (float) mapHeight; for (uniform int32 p = 0; p < peaksSize; p++) { varying float peakX = peaks[p].x; varying float peakY = peaks[p].y; varying float peakZ = peaks[p].z; // multiply by 0.02f could be hoisted here foreach(i = 0 ... count) { // these operations don't need to be masked. pos.x[i] += dir.x[i]; pos.y[i] += dir.y[i]; dir.y[i] *= 0.95f; // inside this scope should be masked if ( pos.x[i] < 0.0f ) { pos.x[i] = (varying float) mapWidthMinusOnef; #pragma ignore warning // modulus/integer division is slow pos.y[i] = RandomFloat() * mapHeight; dir.x[i] = -1.0f - RandomFloat() * 2.0f; dir.y[i] = 0.0f; } // and this bit here does not need be masked. float toPeak_x = peakX - pos.x[i]; float toPeak_y = peakY - pos.y[i]; float toPeak_dot = toPeak_x * toPeak_x + toPeak_y * toPeak_y; float toPeak_len = sqrt(toPeak_dot); float g = peakZ * 0.02f / toPeak_len; // this scalar should be able to be applied to line 32 float invLen = 1.0 / toPeak_len; // this would be beneficical to reorder above the previous statement and save the divide toPeak_y *= invLen; dir.y[i] -= toPeak_y * g; dir.y[i] += RandomFloat() * 0.05f - 0.025f; frame[i] = (frame[i] + frameChange[i] + 256) & 256; } } }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Compiler Explorer Shop
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
CE on Bluesky
Statistics
Changelog
Version tree