1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
///
/// @file RelaxedAtomic.hpp
/// LLVM/OpenMP dynamic scheduling caused a severe scaling issue
/// in primecount: https://bugs.llvm.org/show_bug.cgi?id=49588
/// By default OpenMP dynamic scheduling may process iterations
/// in random order, it is likely that this causes many cache
/// misses when computing the easy special leaves in primecount.
/// It is possible to use schedule(monotonic:dynamic) to ensure
/// that iterations are processed in sequential order. This
/// seems to fix primecount's scaling issue.
///
/// However as a precaution measure we try to avoid OpenMP
/// dynamic scheduling in primecount and instead implement
/// schedule(monotonic:dynamic, 1) ourselves using relaxed
/// atomics.
///
/// Copyright (C) 2021 Kim Walisch, <kim.walisch@gmail.com>
///
/// This file is distributed under the BSD License. See the COPYING
/// file in the top level directory.
///
// namespace