]> git.ipfire.org Git - thirdparty/gcc.git/blob
cfda2a875b9b821cb024d61cd6ec34c97edf886d
[thirdparty/gcc.git] /
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. _implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses:
7
8 Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses
9 ********************************************************************
10
11 This seems simple enough for PARALLEL blocks. Create a private
12 struct for communicating between the parent and subfunction.
13 In the parent, copy in values for scalar and "small" structs;
14 copy in addresses for others TREE_ADDRESSABLE types. In the
15 subfunction, copy the value into the local variable.
16
17 It is not clear what to do with bare FOR or SECTION blocks.
18 The only thing I can figure is that we do something like:
19
20 .. code-block:: c++
21
22 #pragma omp for firstprivate(x) lastprivate(y)
23 for (int i = 0; i < n; ++i)
24 body;
25
26 which becomes
27
28 .. code-block:: c++
29
30 {
31 int x = x, y;
32
33 // for stuff
34
35 if (i == n)
36 y = y;
37 }
38
39 where the "x=x" and "y=y" assignments actually have different
40 uids for the two variables, i.e. not something you could write
41 directly in C. Presumably this only makes sense if the "outer"
42 x and y are global variables.
43
44 COPYPRIVATE would work the same way, except the structure
45 broadcast would have to happen via SINGLE machinery instead.