989 B
989 B
What did work:
Removing a double calculation when step
I changed config[i] = 0.5*previous[i] + 0.25*previous[(i-1) % size]+ 0.25*previous[(i+1) % size];
to config[i] = 0.5*previous[i] + 0.25*previous[(i-1) % size]*2;
in step
This made all the improvement as far as i can tell
In shift_centre_to_origin compute the ratio before the for loop
const float ratio = sum/size;
for(long i = 0; i < size; i++) config[i] -= ratio;
This did not make a noticable difference
What did not work and actually made it slower:
- Trying to find a fancy way to get a random bool in stochastic_unit_step
- Using the std::minmax_element function in elongation
- Changing the step function to be a void that changed the array directly made it about 8 secounds slower
Compiler optimizations
I treid these flags: -Ofast -march=native -flto -fno-signed-zeros -fno-trapping-math The improvements were in the margin of error
Speedup
I got at best a 1.1 times speedup. See 12_speedup.png