New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
do_loop_substitute.h90 in NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE – NEMO

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/do_loop_substitute.h90 @ 12340

Last change on this file since 12340 was 12340, checked in by acc, 2 years ago

Branch 2019/dev_r11943_MERGE_2019. This commit introduces basic do loop macro
substitution to the 2019 option 1, merge branch. These changes have been SETTE
tested. The only addition is the do_loop_substitute.h90 file in the OCE directory but
the macros defined therein are used throughout the code to replace identifiable, 2D-
and 3D- nested loop opening and closing statements with single-line alternatives. Code
indents are also adjusted accordingly.

The following explanation is taken from comments in the new header file:

This header file contains preprocessor definitions and macros used in the do-loop
substitutions introduced between version 4.0 and 4.2. The primary aim of these macros
is to assist in future applications of tiling to improve performance. This is expected
to be achieved by alternative versions of these macros in selected locations. The
initial introduction of these macros simply replaces all identifiable nested 2D- and
3D-loops with single line statements (and adjusts indenting accordingly). Do loops
are identifiable if they comform to either:

DO jk = ....

DO jj = .... DO jj = ...

DO ji = .... DO ji = ...
. OR .
. .

END DO END DO

END DO END DO

END DO

and white-space variants thereof.

Additionally, only loops with recognised jj and ji loops limits are treated; these are:
Lower limits of 1, 2 or fs_2
Upper limits of jpi, jpim1 or fs_jpim1 (for ji) or jpj, jpjm1 or fs_jpjm1 (for jj)

The macro naming convention takes the form: DO_2D_BT_LR where:

B is the Bottom offset from the PE's inner domain;
T is the Top offset from the PE's inner domain;
L is the Left offset from the PE's inner domain;
R is the Right offset from the PE's inner domain

So, given an inner domain of 2,jpim1 and 2,jpjm1, a typical example would replace:

DO jj = 2, jpj

DO ji = 1, jpim1
.
.

END DO

END DO

with:

DO_2D_01_10
.
.
END_2D

similar conventions apply to the 3D loops macros. jk loop limits are retained
through macro arguments and are not restricted. This includes the possibility of
strides for which an extra set of DO_3DS macros are defined.

In the example definition below the inner PE domain is defined by start indices of
(kIs, kJs) and end indices of (kIe, KJe)

#define DO_2D_00_00 DO jj = kJs, kJe ; DO ji = kIs, kIe
#define END_2D END DO ; END DO

TO DO:


Only conventional nested loops have been identified and replaced by this step. There are constructs such as:

DO jk = 2, jpkm1

z2d(:,:) = z2d(:,:) + e3w(:,:,jk,Kmm) * z3d(:,:,jk) * wmask(:,:,jk)

END DO

which may need to be considered.

File size: 3.9 KB
Line 
1#ifdef show_comments
2! These comments are not intended to be retained during preprocessing; i.e. do not define "show_comments"
3! This header file contains preprocessor definitions and macros used in the do-loop substitutions introduced
4! between version 4.0 and 4.2. The primary aim of these macros is to assist in future applications of tiling
5! to improve performance. This is expected to be achieved by alternative versions of these macros in selected
6! locations. The initial introduction of these macros simply replaces all identifiable nested 2D- and 3D-loops
7! with single line statements (and adjusts indenting accordingly). Do loops are identifiable if they comform
8! to either:
9!                                       DO jk = ....
10!   DO jj = ....                           DO jj = ...
11!      DO ji = ....                           DO ji = ...
12!      .                   OR                 . 
13!      .                                      .
14!     END DO                                  END DO
15!   END DO                                 END DO
16!                                       END DO
17! and white-space variants thereof.
18!
19! Additionally, only loops with recognised jj and ji loops limits are treated; these are:
20! Lower limits of 1, 2 or fs_2
21! Upper limits of jpi, jpim1 or fs_jpim1 (for ji) or jpj, jpjm1 or fs_jpjm1 (for jj)
22!
23! The macro naming convention takes the form: DO_2D_BT_LR where:
24!   B is the Bottom offset from the PE's inner domain;
25!   T is the Top    offset from the PE's inner domain;
26!   L is the Left   offset from the PE's inner domain;
27!   R is the Right  offset from the PE's inner domain
28!
29! So, given an inner domain of 2,jpim1 and 2,jpjm1, a typical example would replace:
30!
31!   DO jj = 2, jpj
32!      DO ji = 1, jpim1
33!      .
34!      .
35!     END DO
36!   END DO
37!
38! with:
39!
40!   DO_2D_01_10
41!   .
42!   .
43!   END_2D
44!
45! similar conventions apply to the 3D loops macros although jk loop limits are retained through macro arguments and are not restricted. This
46! includes the possibility of strides for which an extra set of DO_3DS macros are defined.
47!
48! In the definitions below the inner PE domain is defined by start indices of (kIs, kJs) and end indices of (kIe, KJe)
49!
50#endif
51#define kIs 2
52#define kJs 2
53#define kIsm1 1
54#define kJsm1 1
55
56#define kIe jpim1
57#define kJe jpjm1
58#define kIep1 jpi
59#define kJep1 jpj
60
61#define DO_2D_00_00 DO jj = kJs, kJe     ; DO ji = kIs, kIe
62#define DO_2D_00_01 DO jj = kJs, kJe     ; DO ji = kIs, kIep1
63#define DO_2D_00_10 DO jj = kJs, kJe     ; DO ji = kIsm1, kIe
64#define DO_2D_00_11 DO jj = kJs, kJe     ; DO ji = kIsm1, kIep1
65 
66#define DO_2D_01_00 DO jj = kJs, kJep1   ; DO ji = kIs, kIe
67#define DO_2D_01_01 DO jj = kJs, kJep1   ; DO ji = kIs, kIep1
68#define DO_2D_01_10 DO jj = kJs, kJep1   ; DO ji = kIsm1, kIe
69#define DO_2D_01_11 DO jj = kJs, kJep1   ; DO ji = kIsm1, kIep1
70 
71#define DO_2D_10_00 DO jj = kJsm1, kJe   ; DO ji = kIs, kIe
72#define DO_2D_10_10 DO jj = kJsm1, kJe   ; DO ji = kIsm1, kIe
73#define DO_2D_10_11 DO jj = kJsm1, kJe   ; DO ji = kIsm1, kIep1
74 
75#define DO_2D_11_00 DO jj = kJsm1, kJep1 ; DO ji = kIs, kIe
76#define DO_2D_11_01 DO jj = kJsm1, kJep1 ; DO ji = kIs, kIep1
77#define DO_2D_11_10 DO jj = kJsm1, kJep1 ; DO ji = kIsm1, kIe
78#define DO_2D_11_11 DO jj = kJsm1, kJep1 ; DO ji = kIsm1, kIep1
79
80
81#define DO_3D_00_00(ks,ke) DO jk = ks, ke ; DO_2D_00_00
82#define DO_3D_00_10(ks,ke) DO jk = ks, ke ; DO_2D_00_10
83 
84#define DO_3D_01_01(ks,ke) DO jk = ks, ke ; DO_2D_01_01
85 
86#define DO_3D_10_00(ks,ke) DO jk = ks, ke ; DO_2D_10_00
87#define DO_3D_10_10(ks,ke) DO jk = ks, ke ; DO_2D_10_10
88#define DO_3D_10_11(ks,ke) DO jk = ks, ke ; DO_2D_10_11
89 
90#define DO_3D_11_11(ks,ke) DO jk = ks, ke ; DO_2D_11_11
91
92#define DO_3DS_00_00(ks,ke,ki) DO jk = ks, ke, ki ; DO_2D_00_00
93#define DO_3DS_01_01(ks,ke,ki) DO jk = ks, ke, ki ; DO_2D_01_01
94#define DO_3DS_10_10(ks,ke,ki) DO jk = ks, ke, ki ; DO_2D_10_10
95#define DO_3DS_11_11(ks,ke,ki) DO jk = ks, ke, ki ; DO_2D_11_11
96
97#define END_2D END DO ; END DO
98#define END_3D END DO ; END DO ; END DO
Note: See TracBrowser for help on using the repository browser.