Skip to content

Commit

Permalink
Switch from atomic to critical in grouped allele counts coverage
Browse files Browse the repository at this point in the history
recording.

Atomic was not thread-safe, causing concurrent writes to unordered_map
(seg faults).
Note: all threads are synchronised even if they are updating coverage on
different sites this way. A per site synchronisation/locking would be
finer.
  • Loading branch information
bricoletc committed May 8, 2019
1 parent 04ff58e commit e66865e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void coverage::record::grouped_allele_counts(Coverage &coverage,

// Get the map between allele Ids and counts.
auto &site_coverage = coverage.grouped_allele_counts[site_coverage_index];
#pragma omp atomic
#pragma omp critical
// Note: if the key does not already exists, creates a key value pair **and** initialises the value to 0.
site_coverage[allele_ids] += 1;
}
Expand Down

0 comments on commit e66865e

Please sign in to comment.