| 1 |
% $Header$ |
% $Header$ |
| 2 |
|
|
| 3 |
In this chapter we describe the software architecture and |
This chapter focuses on describing the {\bf WRAPPER} environment within which |
| 4 |
implementation strategy for the MITgcm code. The first part of this |
both the core numerics and the pluggable packages operate. The description |
| 5 |
chapter discusses the MITgcm architecture at an abstract level. In the second |
presented here is intended to be a detailed exposition and contains significant |
| 6 |
part of the chapter we described practical details of the MITgcm implementation |
background material, as well as advanced details on working with the WRAPPER. |
| 7 |
and of current tools and operating system features that are employed. |
The tutorial sections of this manual (see sections |
| 8 |
|
\ref{sect:tutorials} and \ref{sect:tutorialIII}) |
| 9 |
|
contain more succinct, step-by-step instructions on running basic numerical |
| 10 |
|
experiments, of varous types, both sequentially and in parallel. For many |
| 11 |
|
projects simply starting from an example code and adapting it to suit a |
| 12 |
|
particular situation |
| 13 |
|
will be all that is required. |
| 14 |
|
The first part of this chapter discusses the MITgcm architecture at an |
| 15 |
|
abstract level. In the second part of the chapter we described practical |
| 16 |
|
details of the MITgcm implementation and of current tools and operating system |
| 17 |
|
features that are employed. |
| 18 |
|
|
| 19 |
\section{Overall architectural goals} |
\section{Overall architectural goals} |
| 20 |
|
|
| 38 |
|
|
| 39 |
\begin{enumerate} |
\begin{enumerate} |
| 40 |
\item A core set of numerical and support code. This is discussed in detail in |
\item A core set of numerical and support code. This is discussed in detail in |
| 41 |
section \ref{sec:partII}. |
section \ref{sect:partII}. |
| 42 |
\item A scheme for supporting optional "pluggable" {\bf packages} (containing |
\item A scheme for supporting optional "pluggable" {\bf packages} (containing |
| 43 |
for example mixed-layer schemes, biogeochemical schemes, atmospheric physics). |
for example mixed-layer schemes, biogeochemical schemes, atmospheric physics). |
| 44 |
These packages are used both to overlay alternate dynamics and to introduce |
These packages are used both to overlay alternate dynamics and to introduce |
| 84 |
to ``fit'' within the WRAPPER infrastructure. Writing code to ``fit'' within |
to ``fit'' within the WRAPPER infrastructure. Writing code to ``fit'' within |
| 85 |
the WRAPPER means that coding has to follow certain, relatively |
the WRAPPER means that coding has to follow certain, relatively |
| 86 |
straightforward, rules and conventions ( these are discussed further in |
straightforward, rules and conventions ( these are discussed further in |
| 87 |
section \ref{sec:specifying_a_decomposition} ). |
section \ref{sect:specifying_a_decomposition} ). |
| 88 |
|
|
| 89 |
The approach taken by the WRAPPER is illustrated in figure |
The approach taken by the WRAPPER is illustrated in figure |
| 90 |
\ref{fig:fit_in_wrapper} which shows how the WRAPPER serves to insulate code |
\ref{fig:fit_in_wrapper} which shows how the WRAPPER serves to insulate code |
| 97 |
\resizebox{!}{4.5in}{\includegraphics{part4/fit_in_wrapper.eps}} |
\resizebox{!}{4.5in}{\includegraphics{part4/fit_in_wrapper.eps}} |
| 98 |
\end{center} |
\end{center} |
| 99 |
\caption{ |
\caption{ |
| 100 |
Numerical code is written too fit within a software support |
Numerical code is written to fit within a software support |
| 101 |
infrastructure called WRAPPER. The WRAPPER is portable and |
infrastructure called WRAPPER. The WRAPPER is portable and |
| 102 |
can be specialized for a wide range of specific target hardware and |
can be specialized for a wide range of specific target hardware and |
| 103 |
programming environments, without impacting numerical code that fits |
programming environments, without impacting numerical code that fits |
| 108 |
\end{figure} |
\end{figure} |
| 109 |
|
|
| 110 |
\subsection{Target hardware} |
\subsection{Target hardware} |
| 111 |
\label{sec:target_hardware} |
\label{sect:target_hardware} |
| 112 |
|
|
| 113 |
The WRAPPER is designed to target as broad as possible a range of computer |
The WRAPPER is designed to target as broad as possible a range of computer |
| 114 |
systems. The original development of the WRAPPER took place on a |
systems. The original development of the WRAPPER took place on a |
| 120 |
(UMA) and non-uniform memory access (NUMA) designs. Significant work has also |
(UMA) and non-uniform memory access (NUMA) designs. Significant work has also |
| 121 |
been undertaken on x86 cluster systems, Alpha processor based clustered SMP |
been undertaken on x86 cluster systems, Alpha processor based clustered SMP |
| 122 |
systems, and on cache-coherent NUMA (CC-NUMA) systems from Silicon Graphics. |
systems, and on cache-coherent NUMA (CC-NUMA) systems from Silicon Graphics. |
| 123 |
The MITgcm code, operating within the WRAPPER, is also used routinely used on |
The MITgcm code, operating within the WRAPPER, is also routinely used on |
| 124 |
large scale MPP systems (for example T3E systems and IBM SP systems). In all |
large scale MPP systems (for example T3E systems and IBM SP systems). In all |
| 125 |
cases numerical code, operating within the WRAPPER, performs and scales very |
cases numerical code, operating within the WRAPPER, performs and scales very |
| 126 |
competitively with equivalent numerical code that has been modified to contain |
competitively with equivalent numerical code that has been modified to contain |
| 128 |
|
|
| 129 |
\subsection{Supporting hardware neutrality} |
\subsection{Supporting hardware neutrality} |
| 130 |
|
|
| 131 |
The different systems listed in section \ref{sec:target_hardware} can be |
The different systems listed in section \ref{sect:target_hardware} can be |
| 132 |
categorized in many different ways. For example, one common distinction is |
categorized in many different ways. For example, one common distinction is |
| 133 |
between shared-memory parallel systems (SMP's, PVP's) and distributed memory |
between shared-memory parallel systems (SMP's, PVP's) and distributed memory |
| 134 |
parallel systems (for example x86 clusters and large MPP systems). This is one |
parallel systems (for example x86 clusters and large MPP systems). This is one |
| 221 |
whenever it requires values that outside the domain it owns. Periodically |
whenever it requires values that outside the domain it owns. Periodically |
| 222 |
processors will make calls to WRAPPER functions to communicate data between |
processors will make calls to WRAPPER functions to communicate data between |
| 223 |
tiles, in order to keep the overlap regions up to date (see section |
tiles, in order to keep the overlap regions up to date (see section |
| 224 |
\ref{sec:communication_primitives}). The WRAPPER functions can use a |
\ref{sect:communication_primitives}). The WRAPPER functions can use a |
| 225 |
variety of different mechanisms to communicate data between tiles. |
variety of different mechanisms to communicate data between tiles. |
| 226 |
|
|
| 227 |
\begin{figure} |
\begin{figure} |
| 308 |
\end{figure} |
\end{figure} |
| 309 |
|
|
| 310 |
\subsection{Shared memory communication} |
\subsection{Shared memory communication} |
| 311 |
\label{sec:shared_memory_communication} |
\label{sect:shared_memory_communication} |
| 312 |
|
|
| 313 |
Under shared communication independent CPU's are operating |
Under shared communication independent CPU's are operating |
| 314 |
on the exact same global address space at the application level. |
on the exact same global address space at the application level. |
| 334 |
communication very efficient provided it is used appropriately. |
communication very efficient provided it is used appropriately. |
| 335 |
|
|
| 336 |
\subsubsection{Memory consistency} |
\subsubsection{Memory consistency} |
| 337 |
\label{sec:memory_consistency} |
\label{sect:memory_consistency} |
| 338 |
|
|
| 339 |
When using shared memory communication between |
When using shared memory communication between |
| 340 |
multiple processors the WRAPPER level shields user applications from |
multiple processors the WRAPPER level shields user applications from |
| 358 |
ensure memory consistency for a particular platform. |
ensure memory consistency for a particular platform. |
| 359 |
|
|
| 360 |
\subsubsection{Cache effects and false sharing} |
\subsubsection{Cache effects and false sharing} |
| 361 |
\label{sec:cache_effects_and_false_sharing} |
\label{sect:cache_effects_and_false_sharing} |
| 362 |
|
|
| 363 |
Shared-memory machines often have local to processor memory caches |
Shared-memory machines often have local to processor memory caches |
| 364 |
which contain mirrored copies of main memory. Automatic cache-coherence |
which contain mirrored copies of main memory. Automatic cache-coherence |
| 377 |
threads operating within a single process is the standard mechanism for |
threads operating within a single process is the standard mechanism for |
| 378 |
supporting shared memory that the WRAPPER utilizes. Configuring and launching |
supporting shared memory that the WRAPPER utilizes. Configuring and launching |
| 379 |
code to run in multi-threaded mode on specific platforms is discussed in |
code to run in multi-threaded mode on specific platforms is discussed in |
| 380 |
section \ref{sec:running_with_threads}. However, on many systems, potentially |
section \ref{sect:running_with_threads}. However, on many systems, potentially |
| 381 |
very efficient mechanisms for using shared memory communication between |
very efficient mechanisms for using shared memory communication between |
| 382 |
multiple processes (in contrast to multiple threads within a single |
multiple processes (in contrast to multiple threads within a single |
| 383 |
process) also exist. In most cases this works by making a limited region of |
process) also exist. In most cases this works by making a limited region of |
| 390 |
nature. |
nature. |
| 391 |
|
|
| 392 |
\subsection{Distributed memory communication} |
\subsection{Distributed memory communication} |
| 393 |
\label{sec:distributed_memory_communication} |
\label{sect:distributed_memory_communication} |
| 394 |
Many parallel systems are not constructed in a way where it is |
Many parallel systems are not constructed in a way where it is |
| 395 |
possible or practical for an application to use shared memory |
possible or practical for an application to use shared memory |
| 396 |
for communication. For example cluster systems consist of individual computers |
for communication. For example cluster systems consist of individual computers |
| 404 |
highly optimized library. |
highly optimized library. |
| 405 |
|
|
| 406 |
\subsection{Communication primitives} |
\subsection{Communication primitives} |
| 407 |
\label{sec:communication_primitives} |
\label{sect:communication_primitives} |
| 408 |
|
|
| 409 |
\begin{figure} |
\begin{figure} |
| 410 |
\begin{center} |
\begin{center} |
| 548 |
computing CPU's. |
computing CPU's. |
| 549 |
\end{enumerate} |
\end{enumerate} |
| 550 |
This section describes the details of each of these operations. |
This section describes the details of each of these operations. |
| 551 |
Section \ref{sec:specifying_a_decomposition} explains how the way in which |
Section \ref{sect:specifying_a_decomposition} explains how the way in which |
| 552 |
a domain is decomposed (or composed) is expressed. Section |
a domain is decomposed (or composed) is expressed. Section |
| 553 |
\ref{sec:starting_a_code} describes practical details of running codes |
\ref{sect:starting_a_code} describes practical details of running codes |
| 554 |
in various different parallel modes on contemporary computer systems. |
in various different parallel modes on contemporary computer systems. |
| 555 |
Section \ref{sec:controlling_communication} explains the internal information |
Section \ref{sect:controlling_communication} explains the internal information |
| 556 |
that the WRAPPER uses to control how information is communicated between |
that the WRAPPER uses to control how information is communicated between |
| 557 |
tiles. |
tiles. |
| 558 |
|
|
| 559 |
\subsection{Specifying a domain decomposition} |
\subsection{Specifying a domain decomposition} |
| 560 |
\label{sec:specifying_a_decomposition} |
\label{sect:specifying_a_decomposition} |
| 561 |
|
|
| 562 |
At its heart much of the WRAPPER works only in terms of a collection of tiles |
At its heart much of the WRAPPER works only in terms of a collection of tiles |
| 563 |
which are interconnected to each other. This is also true of application |
which are interconnected to each other. This is also true of application |
| 609 |
dimensions of {\em sNx} and {\em sNy}. If, when the code is executed, these tiles are |
dimensions of {\em sNx} and {\em sNy}. If, when the code is executed, these tiles are |
| 610 |
allocated to different threads of a process that are then bound to |
allocated to different threads of a process that are then bound to |
| 611 |
different physical processors ( see the multi-threaded |
different physical processors ( see the multi-threaded |
| 612 |
execution discussion in section \ref{sec:starting_the_code} ) then |
execution discussion in section \ref{sect:starting_the_code} ) then |
| 613 |
computation will be performed concurrently on each tile. However, it is also |
computation will be performed concurrently on each tile. However, it is also |
| 614 |
possible to run the same decomposition within a process running a single thread on |
possible to run the same decomposition within a process running a single thread on |
| 615 |
a single processor. In this case the tiles will be computed over sequentially. |
a single processor. In this case the tiles will be computed over sequentially. |
| 661 |
computation is performed concurrently over as many processes and threads |
computation is performed concurrently over as many processes and threads |
| 662 |
as there are physical processors available to compute. |
as there are physical processors available to compute. |
| 663 |
|
|
| 664 |
|
An exception to the the use of {\em bi} and {\em bj} in loops arises in the |
| 665 |
|
exchange routines used when the exch2 package is used with the cubed |
| 666 |
|
sphere. In this case {\em bj} is generally set to 1 and the loop runs from |
| 667 |
|
1,{\em bi}. Within the loop {\em bi} is used to retrieve the tile number, |
| 668 |
|
which is then used to reference exchange parameters. |
| 669 |
|
|
| 670 |
The amount of computation that can be embedded |
The amount of computation that can be embedded |
| 671 |
a single loop over {\em bi} and {\em bj} varies for different parts of the |
a single loop over {\em bi} and {\em bj} varies for different parts of the |
| 672 |
MITgcm algorithm. Figure \ref{fig:bibj_extract} shows a code extract |
MITgcm algorithm. Figure \ref{fig:bibj_extract} shows a code extract |
| 787 |
forty grid points in y. The two sub-domains in each process will be computed |
forty grid points in y. The two sub-domains in each process will be computed |
| 788 |
sequentially if they are given to a single thread within a single process. |
sequentially if they are given to a single thread within a single process. |
| 789 |
Alternatively if the code is invoked with multiple threads per process |
Alternatively if the code is invoked with multiple threads per process |
| 790 |
the two domains in y may be computed on concurrently. |
the two domains in y may be computed concurrently. |
| 791 |
\item |
\item |
| 792 |
\begin{verbatim} |
\begin{verbatim} |
| 793 |
PARAMETER ( |
PARAMETER ( |
| 806 |
This set of values can be used for a cube sphere calculation. |
This set of values can be used for a cube sphere calculation. |
| 807 |
Each tile of size $32 \times 32$ represents a face of the |
Each tile of size $32 \times 32$ represents a face of the |
| 808 |
cube. Initializing the tile connectivity correctly ( see section |
cube. Initializing the tile connectivity correctly ( see section |
| 809 |
\ref{sec:cube_sphere_communication}. allows the rotations associated with |
\ref{sect:cube_sphere_communication}. allows the rotations associated with |
| 810 |
moving between the six cube faces to be embedded within the |
moving between the six cube faces to be embedded within the |
| 811 |
tile-tile communication code. |
tile-tile communication code. |
| 812 |
\end{enumerate} |
\end{enumerate} |
| 813 |
|
|
| 814 |
|
|
| 815 |
\subsection{Starting the code} |
\subsection{Starting the code} |
| 816 |
\label{sec:starting_the_code} |
\label{sect:starting_the_code} |
| 817 |
When code is started under the WRAPPER, execution begins in a main routine {\em |
When code is started under the WRAPPER, execution begins in a main routine {\em |
| 818 |
eesupp/src/main.F} that is owned by the WRAPPER. Control is transferred |
eesupp/src/main.F} that is owned by the WRAPPER. Control is transferred |
| 819 |
to the application through a routine called {\em THE\_MODEL\_MAIN()} |
to the application through a routine called {\em THE\_MODEL\_MAIN()} |
| 823 |
WRAPPER is shown in figure \ref{fig:wrapper_startup}. |
WRAPPER is shown in figure \ref{fig:wrapper_startup}. |
| 824 |
|
|
| 825 |
\begin{figure} |
\begin{figure} |
| 826 |
|
{\footnotesize |
| 827 |
\begin{verbatim} |
\begin{verbatim} |
| 828 |
|
|
| 829 |
MAIN |
MAIN |
| 852 |
|
|
| 853 |
|
|
| 854 |
\end{verbatim} |
\end{verbatim} |
| 855 |
|
} |
| 856 |
\caption{Main stages of the WRAPPER startup procedure. |
\caption{Main stages of the WRAPPER startup procedure. |
| 857 |
This process proceeds transfer of control to application code, which |
This process proceeds transfer of control to application code, which |
| 858 |
occurs through the procedure {\em THE\_MODEL\_MAIN()}. |
occurs through the procedure {\em THE\_MODEL\_MAIN()}. |
| 860 |
\end{figure} |
\end{figure} |
| 861 |
|
|
| 862 |
\subsubsection{Multi-threaded execution} |
\subsubsection{Multi-threaded execution} |
| 863 |
\label{sec:multi-threaded-execution} |
\label{sect:multi-threaded-execution} |
| 864 |
Prior to transferring control to the procedure {\em THE\_MODEL\_MAIN()} the |
Prior to transferring control to the procedure {\em THE\_MODEL\_MAIN()} the |
| 865 |
WRAPPER may cause several coarse grain threads to be initialized. The routine |
WRAPPER may cause several coarse grain threads to be initialized. The routine |
| 866 |
{\em THE\_MODEL\_MAIN()} is called once for each thread and is passed a single |
{\em THE\_MODEL\_MAIN()} is called once for each thread and is passed a single |
| 867 |
stack argument which is the thread number, stored in the |
stack argument which is the thread number, stored in the |
| 868 |
variable {\em myThid}. In addition to specifying a decomposition with |
variable {\em myThid}. In addition to specifying a decomposition with |
| 869 |
multiple tiles per process ( see section \ref{sec:specifying_a_decomposition}) |
multiple tiles per process ( see section \ref{sect:specifying_a_decomposition}) |
| 870 |
configuring and starting a code to run using multiple threads requires the following |
configuring and starting a code to run using multiple threads requires the following |
| 871 |
steps.\\ |
steps.\\ |
| 872 |
|
|
| 935 |
File: {\em eesupp/inc/MAIN\_PDIRECTIVES2.h}\\ |
File: {\em eesupp/inc/MAIN\_PDIRECTIVES2.h}\\ |
| 936 |
File: {\em model/src/THE\_MODEL\_MAIN.F}\\ |
File: {\em model/src/THE\_MODEL\_MAIN.F}\\ |
| 937 |
File: {\em eesupp/src/MAIN.F}\\ |
File: {\em eesupp/src/MAIN.F}\\ |
| 938 |
File: {\em tools/genmake}\\ |
File: {\em tools/genmake2}\\ |
| 939 |
File: {\em eedata}\\ |
File: {\em eedata}\\ |
| 940 |
CPP: {\em TARGET\_SUN}\\ |
CPP: {\em TARGET\_SUN}\\ |
| 941 |
CPP: {\em TARGET\_DEC}\\ |
CPP: {\em TARGET\_DEC}\\ |
| 948 |
} \\ |
} \\ |
| 949 |
|
|
| 950 |
\subsubsection{Multi-process execution} |
\subsubsection{Multi-process execution} |
| 951 |
\label{sec:multi-process-execution} |
\label{sect:multi-process-execution} |
| 952 |
|
|
| 953 |
Despite its appealing programming model, multi-threaded execution remains |
Despite its appealing programming model, multi-threaded execution remains |
| 954 |
less common then multi-process execution. One major reason for this |
less common then multi-process execution. One major reason for this |
| 960 |
|
|
| 961 |
Multi-process execution is more ubiquitous. |
Multi-process execution is more ubiquitous. |
| 962 |
In order to run code in a multi-process configuration a decomposition |
In order to run code in a multi-process configuration a decomposition |
| 963 |
specification ( see section \ref{sec:specifying_a_decomposition}) |
specification ( see section \ref{sect:specifying_a_decomposition}) |
| 964 |
is given ( in which the at least one of the |
is given ( in which the at least one of the |
| 965 |
parameters {\em nPx} or {\em nPy} will be greater than one) |
parameters {\em nPx} or {\em nPy} will be greater than one) |
| 966 |
and then, as for multi-threaded operation, |
and then, as for multi-threaded operation, |
| 974 |
of controlling and coordinating the start up of a large number |
of controlling and coordinating the start up of a large number |
| 975 |
(hundreds and possibly even thousands) of copies of the same |
(hundreds and possibly even thousands) of copies of the same |
| 976 |
program, MPI is used. The calls to the MPI multi-process startup |
program, MPI is used. The calls to the MPI multi-process startup |
| 977 |
routines must be activated at compile time. This is done |
routines must be activated at compile time. Currently MPI libraries are |
| 978 |
by setting the {\em ALLOW\_USE\_MPI} and {\em ALWAYS\_USE\_MPI} |
invoked by |
| 979 |
flags in the {\em CPP\_EEOPTIONS.h} file.\\ |
specifying the appropriate options file with the |
| 980 |
|
\begin{verbatim}-of\end{verbatim} flag when running the {\em genmake2} |
| 981 |
\fbox{ |
script, which generates the Makefile for compiling and linking MITgcm. |
| 982 |
\begin{minipage}{4.75in} |
(Previously this was done by setting the {\em ALLOW\_USE\_MPI} and |
| 983 |
File: {\em eesupp/inc/CPP\_EEOPTIONS.h}\\ |
{\em ALWAYS\_USE\_MPI} flags in the {\em CPP\_EEOPTIONS.h} file.) More |
| 984 |
CPP: {\em ALLOW\_USE\_MPI}\\ |
detailed information about the use of {\em genmake2} for specifying |
| 985 |
CPP: {\em ALWAYS\_USE\_MPI}\\ |
local compiler flags is located in section 3 ??\\ |
|
Parameter: {\em nPx}\\ |
|
|
Parameter: {\em nPy} |
|
|
\end{minipage} |
|
|
} \\ |
|
| 986 |
|
|
|
Additionally, compile time options are required to link in the |
|
|
MPI libraries and header files. Examples of these options |
|
|
can be found in the {\em genmake} script that creates makefiles |
|
|
for compilation. When this script is executed with the {bf -mpi} |
|
|
flag it will generate a makefile that includes |
|
|
paths for search for MPI head files and for linking in |
|
|
MPI libraries. For example the {\bf -mpi} flag on a |
|
|
Silicon Graphics IRIX system causes a |
|
|
Makefile with the compilation command |
|
|
Graphics IRIX system \begin{verbatim} |
|
|
mpif77 -I/usr/local/mpi/include -DALLOW_USE_MPI -DALWAYS_USE_MPI |
|
|
\end{verbatim} |
|
|
to be generated. |
|
|
This is the correct set of options for using the MPICH open-source |
|
|
version of MPI, when it has been installed under the subdirectory |
|
|
/usr/local/mpi. |
|
|
However, on many systems there may be several |
|
|
versions of MPI installed. For example many systems have both |
|
|
the open source MPICH set of libraries and a vendor specific native form |
|
|
of the MPI libraries. The correct setup to use will depend on the |
|
|
local configuration of your system.\\ |
|
| 987 |
|
|
| 988 |
\fbox{ |
\fbox{ |
| 989 |
\begin{minipage}{4.75in} |
\begin{minipage}{4.75in} |
| 990 |
File: {\em tools/genmake} |
File: {\em tools/genmake2} |
| 991 |
\end{minipage} |
\end{minipage} |
| 992 |
} \\ |
} \\ |
| 993 |
\paragraph{\bf Execution} The mechanics of starting a program in |
\paragraph{\bf Execution} The mechanics of starting a program in |
| 1105 |
neighbor to communicate with on a particular face. A value |
neighbor to communicate with on a particular face. A value |
| 1106 |
of {\em COMM\_MSG} is used to indicated that some form of distributed |
of {\em COMM\_MSG} is used to indicated that some form of distributed |
| 1107 |
memory communication is required to communicate between |
memory communication is required to communicate between |
| 1108 |
these tile faces ( see section \ref{sec:distributed_memory_communication}). |
these tile faces ( see section \ref{sect:distributed_memory_communication}). |
| 1109 |
A value of {\em COMM\_PUT} or {\em COMM\_GET} is used to indicate |
A value of {\em COMM\_PUT} or {\em COMM\_GET} is used to indicate |
| 1110 |
forms of shared memory communication ( see section |
forms of shared memory communication ( see section |
| 1111 |
\ref{sec:shared_memory_communication}). The {\em COMM\_PUT} value indicates |
\ref{sect:shared_memory_communication}). The {\em COMM\_PUT} value indicates |
| 1112 |
that a CPU should communicate by writing to data structures owned by another |
that a CPU should communicate by writing to data structures owned by another |
| 1113 |
CPU. A {\em COMM\_GET} value indicates that a CPU should communicate by reading |
CPU. A {\em COMM\_GET} value indicates that a CPU should communicate by reading |
| 1114 |
from data structures owned by another CPU. These flags affect the behavior |
from data structures owned by another CPU. These flags affect the behavior |
| 1159 |
are read from the file {\em eedata}. If the value of {\em nThreads} |
are read from the file {\em eedata}. If the value of {\em nThreads} |
| 1160 |
is inconsistent with the number of threads requested from the |
is inconsistent with the number of threads requested from the |
| 1161 |
operating system (for example by using an environment |
operating system (for example by using an environment |
| 1162 |
variable as described in section \ref{sec:multi_threaded_execution}) |
variable as described in section \ref{sect:multi_threaded_execution}) |
| 1163 |
then usually an error will be reported by the routine |
then usually an error will be reported by the routine |
| 1164 |
{\em CHECK\_THREADS}.\\ |
{\em CHECK\_THREADS}.\\ |
| 1165 |
|
|
| 1177 |
} |
} |
| 1178 |
|
|
| 1179 |
\item {\bf memsync flags} |
\item {\bf memsync flags} |
| 1180 |
As discussed in section \ref{sec:memory_consistency}, when using shared memory, |
As discussed in section \ref{sect:memory_consistency}, when using shared memory, |
| 1181 |
a low-level system function may be need to force memory consistency. |
a low-level system function may be need to force memory consistency. |
| 1182 |
The routine {\em MEMSYNC()} is used for this purpose. This routine should |
The routine {\em MEMSYNC()} is used for this purpose. This routine should |
| 1183 |
not need modifying and the information below is only provided for |
not need modifying and the information below is only provided for |
| 1203 |
\end{verbatim} |
\end{verbatim} |
| 1204 |
|
|
| 1205 |
\item {\bf Cache line size} |
\item {\bf Cache line size} |
| 1206 |
As discussed in section \ref{sec:cache_effects_and_false_sharing}, |
As discussed in section \ref{sect:cache_effects_and_false_sharing}, |
| 1207 |
milti-threaded codes explicitly avoid penalties associated with excessive |
milti-threaded codes explicitly avoid penalties associated with excessive |
| 1208 |
coherence traffic on an SMP system. To do this the shared memory data structures |
coherence traffic on an SMP system. To do this the shared memory data structures |
| 1209 |
used by the {\em GLOBAL\_SUM}, {\em GLOBAL\_MAX} and {\em BARRIER} routines |
used by the {\em GLOBAL\_SUM}, {\em GLOBAL\_MAX} and {\em BARRIER} routines |
| 1231 |
setting for the \_GSUM macro is given in the file {\em CPP\_EEMACROS.h}. |
setting for the \_GSUM macro is given in the file {\em CPP\_EEMACROS.h}. |
| 1232 |
The \_GSUM macro is a performance critical operation, especially for |
The \_GSUM macro is a performance critical operation, especially for |
| 1233 |
large processor count, small tile size configurations. |
large processor count, small tile size configurations. |
| 1234 |
The custom communication example discussed in section \ref{sec:jam_example} |
The custom communication example discussed in section \ref{sect:jam_example} |
| 1235 |
shows how the macro is used to invoke a custom global sum routine |
shows how the macro is used to invoke a custom global sum routine |
| 1236 |
for a specific set of hardware. |
for a specific set of hardware. |
| 1237 |
|
|
| 1245 |
in the header file {\em CPP\_EEMACROS.h}. As with \_GSUM, the |
in the header file {\em CPP\_EEMACROS.h}. As with \_GSUM, the |
| 1246 |
\_EXCH operation plays a crucial role in scaling to small tile, |
\_EXCH operation plays a crucial role in scaling to small tile, |
| 1247 |
large logical and physical processor count configurations. |
large logical and physical processor count configurations. |
| 1248 |
The example in section \ref{sec:jam_example} discusses defining an |
The example in section \ref{sect:jam_example} discusses defining an |
| 1249 |
optimized and specialized form on the \_EXCH operation. |
optimized and specialized form on the \_EXCH operation. |
| 1250 |
|
|
| 1251 |
The \_EXCH operation is also central to supporting grids such as |
The \_EXCH operation is also central to supporting grids such as |
| 1285 |
if this might be unavailable then the work arrays can be extended |
if this might be unavailable then the work arrays can be extended |
| 1286 |
with dimensions use the tile dimensioning scheme of {\em nSx} |
with dimensions use the tile dimensioning scheme of {\em nSx} |
| 1287 |
and {\em nSy} ( as described in section |
and {\em nSy} ( as described in section |
| 1288 |
\ref{sec:specifying_a_decomposition}). However, if the configuration |
\ref{sect:specifying_a_decomposition}). However, if the configuration |
| 1289 |
being specified involves many more tiles than OS threads then |
being specified involves many more tiles than OS threads then |
| 1290 |
it can save memory resources to reduce the variable |
it can save memory resources to reduce the variable |
| 1291 |
{\em MAX\_NO\_THREADS} to be equal to the actual number of threads that |
{\em MAX\_NO\_THREADS} to be equal to the actual number of threads that |
| 1344 |
how it can be used to adapt to new griding approaches. |
how it can be used to adapt to new griding approaches. |
| 1345 |
|
|
| 1346 |
\subsubsection{JAM example} |
\subsubsection{JAM example} |
| 1347 |
\label{sec:jam_example} |
\label{sect:jam_example} |
| 1348 |
On some platforms a big performance boost can be obtained by |
On some platforms a big performance boost can be obtained by |
| 1349 |
binding the communication routines {\em \_EXCH} and |
binding the communication routines {\em \_EXCH} and |
| 1350 |
{\em \_GSUM} to specialized native libraries ) fro example the |
{\em \_GSUM} to specialized native libraries ) fro example the |
| 1367 |
pattern. |
pattern. |
| 1368 |
|
|
| 1369 |
\subsubsection{Cube sphere communication} |
\subsubsection{Cube sphere communication} |
| 1370 |
\label{sec:cube_sphere_communication} |
\label{sect:cube_sphere_communication} |
| 1371 |
Actual {\em \_EXCH} routine code is generated automatically from |
Actual {\em \_EXCH} routine code is generated automatically from |
| 1372 |
a series of template files, for example {\em exch\_rx.template}. |
a series of template files, for example {\em exch\_rx.template}. |
| 1373 |
This is done to allow a large number of variations on the exchange |
This is done to allow a large number of variations on the exchange |
| 1400 |
|
|
| 1401 |
Fitting together the WRAPPER elements, package elements and |
Fitting together the WRAPPER elements, package elements and |
| 1402 |
MITgcm core equation elements of the source code produces calling |
MITgcm core equation elements of the source code produces calling |
| 1403 |
sequence shown in section \ref{sec:calling_sequence} |
sequence shown in section \ref{sect:calling_sequence} |
| 1404 |
|
|
| 1405 |
\subsection{Annotated call tree for MITgcm and WRAPPER} |
\subsection{Annotated call tree for MITgcm and WRAPPER} |
| 1406 |
\label{sec:calling_sequence} |
\label{sect:calling_sequence} |
| 1407 |
|
|
| 1408 |
WRAPPER layer. |
WRAPPER layer. |
| 1409 |
|
|
| 1410 |
|
{\footnotesize |
| 1411 |
\begin{verbatim} |
\begin{verbatim} |
| 1412 |
|
|
| 1413 |
MAIN |
MAIN |
| 1435 |
|--THE_MODEL_MAIN :: Numerical code top-level driver routine |
|--THE_MODEL_MAIN :: Numerical code top-level driver routine |
| 1436 |
|
|
| 1437 |
\end{verbatim} |
\end{verbatim} |
| 1438 |
|
} |
| 1439 |
|
|
| 1440 |
Core equations plus packages. |
Core equations plus packages. |
| 1441 |
|
|
| 1442 |
|
{\footnotesize |
| 1443 |
\begin{verbatim} |
\begin{verbatim} |
| 1444 |
C |
C |
| 1445 |
C |
C |
| 1778 |
C :: events. |
C :: events. |
| 1779 |
C |
C |
| 1780 |
\end{verbatim} |
\end{verbatim} |
| 1781 |
|
} |
| 1782 |
|
|
| 1783 |
\subsection{Measuring and Characterizing Performance} |
\subsection{Measuring and Characterizing Performance} |
| 1784 |
|
|