LLVM OpenMP
20.0.0git
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
c
d
e
g
h
i
m
n
p
r
s
t
u
Functions
c
d
e
g
i
m
n
p
r
s
u
Variables
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
w
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
Enumerations
Enumerator
Related Functions
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Typedefs
_
a
b
c
d
e
i
k
l
m
n
o
p
r
t
u
Enumerations
_
b
c
d
f
k
l
n
o
s
t
Enumerator
_
a
b
c
d
e
f
k
l
n
o
p
r
s
t
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
tools
archer
tests
reduction
parallel-reduction-nowait.c
Go to the documentation of this file.
1
/*
2
* parallel-reduction-nowait.c -- Archer testcase
3
*/
4
5
//===----------------------------------------------------------------------===//
6
//
7
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8
//
9
// See tools/archer/LICENSE.txt for details.
10
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11
//
12
//===----------------------------------------------------------------------===//
13
14
15
// RUN: %libarcher-compile-and-run | FileCheck %s
16
// REQUIRES: tsan
17
#include <omp.h>
18
#include <stdio.h>
19
20
int
main
(
int
argc,
char
*argv[]) {
21
int
var = 0,
i
;
22
int
sum1
= 0;
23
int
sum2 = 0;
24
25
// Number of threads is empirical: We need enough threads so that
26
// the reduction is really performed hierarchically in the barrier!
27
#pragma omp parallel num_threads(5) reduction(+ : var)
28
{
29
#pragma omp for schedule(static) nowait reduction(+ : sum1)
30
for
(
i
= 0;
i
< 5;
i
++)
31
sum1
+=
i
;
32
#pragma omp for schedule(static) reduction(+ : sum2)
33
for
(
i
= 0;
i
< 5;
i
++)
34
sum2 +=
i
;
35
36
var =
sum1
+ sum2;
37
}
38
39
fprintf(stderr,
"DONE\n"
);
40
int
error = (var != 100);
41
return
error;
42
}
43
44
// CHECK-NOT: ThreadSanitizer: data race
45
// CHECK-NOT: ThreadSanitizer: reported
46
// CHECK: DONE
i
#define i
Definition:
kmp_stub.cpp:87
sum1
static int sum1
Definition:
omp_parallel_copyin.c:6
main
int main()
Definition:
test-touch.c:21
Generated on Tue Jun 10 2025 14:23:51 for LLVM OpenMP by
1.9.6