created two passes

Pass1: compute all forces
Pass2: integrate the forces and do the updates

If we dont separate it, we will have some inter pedestrian forces calculated on a mix of new and updated   values
This commit is contained in:
lbaumberger
2026-04-25 20:57:50 +02:00
parent 3d217e7840
commit 49e96e85a1
+7 -4
View File
@@ -58,7 +58,7 @@ int main(int argc, const char *argv[]) {
// # (8 + 55N - 55 + 144 + 4 + 8 + 4 + 10)*n_p*n_iter
for (int t = 0; t < n_iter; t++) {
// Pass1: conmpute all forces from the current state
for (int i = 0; i < n_p; i++) {
Pedestrian &p = pedestrians[i];
@@ -73,7 +73,10 @@ int main(int argc, const char *argv[]) {
// # 144 flops
compute_repulsive_effects_from_borders(board, &p);
}
// Pass2: integrate the forces and update the current state
for (int i = 0; i < n_p; i++) {
Pedestrian &p = pedestrians[i];
// # 4 flops = 2 ADDs, 2 MULTs
Vector2d w_alpha = p.curr_vel + p.f_i * dt;
@@ -97,12 +100,12 @@ int main(int argc, const char *argv[]) {
std::cout << T;
std::cout << " cycles\n";
double P = W/T;
double P = W / T;
std::cout << "P(n): ";
std::cout << P;
std::cout << " flops/cycle\n";
delete []pedestrians;
delete[] pedestrians;
return 0;
}