• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

tests/H03-May-2022-1,532703

README.mdH A D28-Jun-20216.2 KiB223159

ompt-tsan.cppH A D28-Jun-202133.7 KiB1,041732

README.md

1<div id="table-of-contents">
2<h2>Table of Contents</h2>
3<div id="text-table-of-contents">
4<ul>
5<li><a href="#org8ca70b5">1. License</a></li>
6<li><a href="#orgc6a2b10">2. Introduction</a></li>
7<li><a href="#org9a459f1">3. Installation</a></li>
8<li><a href="#orgb820ad0">4. Usage</a>
9<ul>
10<li><a href="#org213ff1a">4.1. How to compile</a></li>
11<li><a href="#org110062c">4.2. Runtime Flags</a></li>
12</ul>
13</li>
14<li><a href="#org73e58a9">5. Example</a></li>
15<li><a href="#orgcc38a36">6. Contacts and Support</a></li>
16</ul>
17</div>
18</div>
19
20
21<a id="org8ca70b5"></a>
22
23# License
24
25Archer is distributed under the terms of the Apache License.
26
27Please see LICENSE.txt for usage terms.
28
29LLNL-CODE-773957
30
31<a id="orgc6a2b10"></a>
32
33# Introduction
34
35**Archer** is an OMPT tool which annotates OpenMP synchronization semantics for data race
36detection.
37This avoids false alerts in data race detection.
38Archer is automatically loaded for OpenMP applications which are compiled
39with ThreadSanitizer option.
40
41<a id="org9a459f1"></a>
42
43# Build Archer within Clang/LLVM
44
45This distribution of Archer is automatically built with the OpenMP runtime
46and automatically loaded by the OpenMP runtime.
47
48<a id="orgb820ad0"></a>
49
50# Usage
51
52
53<a id="org213ff1a"></a>
54
55## How to compile
56
57To use archer, compile the application with the extra flag
58`-fsanitize=thread`:
59
60    clang -O3 -g -fopenmp -fsanitize=thread app.c
61    clang++ -O3 -g -fopenmp -fsanitize=thread app.cpp
62
63To compile Fortran applications, compile with gfortran, link with clang:
64
65    gfortran -g -c -fopenmp -fsanitize=thread app.f
66    clang -fopenmp -fsanitize=thread app.o -lgfortran
67
68
69<a id="org110062c"></a>
70
71## Runtime Flags
72
73TSan runtime flags are passed via **TSAN&#95;OPTIONS** environment variable,
74we highly recommend the following option to avoid false alerts for the
75OpenMP or MPI runtime implementation:
76
77    export TSAN_OPTIONS="ignore_noninstrumented_modules=1"
78
79
80Runtime flags are passed via **ARCHER&#95;OPTIONS** environment variable,
81different flags are separated by spaces, e.g.:
82
83    ARCHER_OPTIONS="flush_shadow=1" ./myprogram
84
85<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
86
87
88<colgroup>
89<col  class="org-left" />
90
91<col  class="org-right" />
92
93<col  class="org-left" />
94</colgroup>
95<thead>
96<tr>
97<th scope="col" class="org-left">Flag Name</th>
98<th scope="col" class="org-right">Default value</th>
99<th scope="col" class="org-left">Description</th>
100</tr>
101</thead>
102
103<tbody>
104<tr>
105<td class="org-left">flush&#95;shadow</td>
106<td class="org-right">0</td>
107<td class="org-left">Flush shadow memory at the end of an outer OpenMP
108parallel region. Our experiments show that this can reduce memory overhead
109by ~30% and runtime overhead by ~10%. This flag is useful for large OpenMP
110applications that typically require large amounts of memory, causing
111out-of-memory exceptions when checked by Archer.</td>
112</tr>
113</tbody>
114
115<tbody>
116<tr>
117<td class="org-left">print&#95;max&#95;rss</td>
118<td class="org-right">0</td>
119<td class="org-left">Print the RSS memory peak at the end of the execution.</td>
120</tr>
121</tbody>
122
123<tbody>
124<tr>
125<td class="org-left">ignore&#95;serial</td>
126<td class="org-right">0</td>
127<td class="org-left">Turn off tracking and analysis of memory accesses in
128the sequential part of an OpenMP program. (Only effective when OpenMP
129runtime is initialized. In doubt, insert omp_get_max_threads() as first
130statement in main!)</td>
131</tr>
132</tbody>
133
134<tbody>
135<tr>
136<td class="org-left">verbose</td>
137<td class="org-right">0</td>
138<td class="org-left">Print startup information.</td>
139</tr>
140</tbody>
141
142<tbody>
143<tr>
144<td class="org-left">enable</td>
145<td class="org-right">1</td>
146<td class="org-left">Use Archer runtime library during execution.</td>
147</tr>
148</tbody>
149</table>
150
151
152<a id="org73e58a9"></a>
153
154# Example
155
156Let us take the program below and follow the steps to compile and
157check the program for data races.
158
159Suppose our program is called *myprogram.c*:
160
161     1  #include <stdio.h>
162     2
163     3  #define N 1000
164     4
165     5  int main (int argc, char **argv)
166     6  {
167     7    int a[N];
168     8
169     9  #pragma omp parallel for
170    10    for (int i = 0; i < N - 1; i++) {
171    11      a[i] = a[i + 1];
172    12    }
173    13  }
174
175We compile the program as follow:
176
177    clang -fsanitize=thread -fopenmp -g myprogram.c -o myprogram
178
179Now we can run the program with the following commands:
180
181    export OMP_NUM_THREADS=2
182    ./myprogram
183
184Archer will output a report in case it finds data races. In our case
185the report will look as follow:
186
187    ==================
188    WARNING: ThreadSanitizer: data race (pid=13641)
189      Read of size 4 at 0x7fff79a01170 by main thread:
190        #0 .omp_outlined. myprogram.c:11:12 (myprogram+0x00000049b5a2)
191        #1 __kmp_invoke_microtask <null> (libomp.so+0x000000077842)
192        #2 __libc_start_main /build/glibc-t3gR2i/glibc-2.23/csu/../csu/libc-start.c:291 (libc.so.6+0x00000002082f)
193
194      Previous write of size 4 at 0x7fff79a01170 by thread T1:
195        #0 .omp_outlined. myprogram.c:11:10 (myprogram+0x00000049b5d6)
196        #1 __kmp_invoke_microtask <null> (libomp.so+0x000000077842)
197
198      Location is stack of main thread.
199
200      Thread T1 (tid=13643, running) created by main thread at:
201        #0 pthread_create tsan_interceptors.cc:902:3 (myprogram+0x00000043db75)
202        #1 __kmp_create_worker <null> (libomp.so+0x00000006c364)
203        #2 __libc_start_main /build/glibc-t3gR2i/glibc-2.23/csu/../csu/libc-start.c:291 (libc.so.6+0x00000002082f)
204
205    SUMMARY: ThreadSanitizer: data race myprogram.c:11:12 in .omp_outlined.
206    ==================
207    ThreadSanitizer: reported 1 warnings
208
209
210<a id="orgcc38a36"></a>
211
212# Contacts and Support
213
214-   [Google group](https://groups.google.com/forum/#!forum/archer-pruner)
215-   [Slack Channel](https://pruners.slack.com)
216
217    <ul style="list-style-type:circle"> <li> For an invitation please write an email to <a href="mailto:simone@cs.utah.edu?Subject=[archer-slack] Slack Invitation" target="_top">Simone Atzeni</a> with a reason why you want to be part of the PRUNERS Slack Team. </li> </ul>
218-   E-Mail Contacts:
219
220    <ul style="list-style-type:circle"> <li> <a href="mailto:simone@cs.utah.edu?Subject=[archer-dev]%20" target="_top">Simone Atzeni</a> </li> <li> <a href="mailto:protze@itc.rwth-aachen.de?Subject=[archer-dev]%20" target="_top">Joachim Protze</a> </li> </ul>
221
222
223