POSIX Shared Memory Data Structures 1.0
High-performance lock-free data structures for inter-process communication
Loading...
Searching...
No Matches
simd_simulation.cpp File Reference

Example of SIMD-optimized particle simulation using shared memory. More...

#include <iostream>
#include <chrono>
#include <random>
#include <iomanip>
#include "posix_shm.h"
#include "shm_array.h"
#include "shm_simd_utils.h"
+ Include dependency graph for simd_simulation.cpp:

Go to the source code of this file.

Classes

struct  ParticleSystemSoA
 

Functions

void initialize_particles (ParticleSystemSoA &particles)
 
void update_physics_scalar (ParticleSystemSoA &particles, float dt)
 
void update_physics_simd (ParticleSystemSoA &particles, float dt)
 
float calculate_kinetic_energy_scalar (ParticleSystemSoA &particles)
 
float calculate_kinetic_energy_simd (ParticleSystemSoA &particles)
 
int main ()
 

Variables

constexpr size_t NUM_PARTICLES = 100000
 
constexpr size_t ITERATIONS = 100
 

Detailed Description

Example of SIMD-optimized particle simulation using shared memory.

Author
Alex Towell

Demonstrates:

  • SIMD operations on shared memory arrays
  • Structure of Arrays (SoA) layout for better vectorization
  • Cache-friendly access patterns
  • Performance comparison vs scalar operations

Definition in file simd_simulation.cpp.

Function Documentation

◆ calculate_kinetic_energy_scalar()

float calculate_kinetic_energy_scalar ( ParticleSystemSoA particles)

◆ calculate_kinetic_energy_simd()

◆ initialize_particles()

◆ main()

◆ update_physics_scalar()

◆ update_physics_simd()

Variable Documentation

◆ ITERATIONS

constexpr size_t ITERATIONS = 100
constexpr

Definition at line 25 of file simd_simulation.cpp.

Referenced by main().

◆ NUM_PARTICLES

constexpr size_t NUM_PARTICLES = 100000
constexpr