From dd6b179a9ecfbb7acd8c4012a3d8a7cc46c91472 Mon Sep 17 00:00:00 2001 From: Amin Farajian Date: Wed, 14 Nov 2018 20:20:00 +0000 Subject: [PATCH] Fixing the non-deterministic behaviour of multi-thread FA. --- src/ttables.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ttables.h b/src/ttables.h index 7dc43b3..f915d61 100644 --- a/src/ttables.h +++ b/src/ttables.h @@ -78,7 +78,9 @@ class TTable { } inline void Increment(const unsigned e, const unsigned f, const double x) { - counts[e].find(f)->second += x; // Ignore race conditions here. +// Each thread locks only the part of the table which is writing on. Other threads have access to the rest of the table to update! +#pragma omp atomic + counts[e].find(f)->second += x;. } void NormalizeVB(const double alpha) {