- •Contents
- •List of Figures
- •List of Tables
- •Acknowledgments
- •Introduction to MPI
- •Overview and Goals
- •Background of MPI-1.0
- •Background of MPI-1.1, MPI-1.2, and MPI-2.0
- •Background of MPI-1.3 and MPI-2.1
- •Background of MPI-2.2
- •Who Should Use This Standard?
- •What Platforms Are Targets For Implementation?
- •What Is Included In The Standard?
- •What Is Not Included In The Standard?
- •Organization of this Document
- •MPI Terms and Conventions
- •Document Notation
- •Naming Conventions
- •Semantic Terms
- •Data Types
- •Opaque Objects
- •Array Arguments
- •State
- •Named Constants
- •Choice
- •Addresses
- •Language Binding
- •Deprecated Names and Functions
- •Fortran Binding Issues
- •C Binding Issues
- •C++ Binding Issues
- •Functions and Macros
- •Processes
- •Error Handling
- •Implementation Issues
- •Independence of Basic Runtime Routines
- •Interaction with Signals
- •Examples
- •Point-to-Point Communication
- •Introduction
- •Blocking Send and Receive Operations
- •Blocking Send
- •Message Data
- •Message Envelope
- •Blocking Receive
- •Return Status
- •Passing MPI_STATUS_IGNORE for Status
- •Data Type Matching and Data Conversion
- •Type Matching Rules
- •Type MPI_CHARACTER
- •Data Conversion
- •Communication Modes
- •Semantics of Point-to-Point Communication
- •Buffer Allocation and Usage
- •Nonblocking Communication
- •Communication Request Objects
- •Communication Initiation
- •Communication Completion
- •Semantics of Nonblocking Communications
- •Multiple Completions
- •Non-destructive Test of status
- •Probe and Cancel
- •Persistent Communication Requests
- •Send-Receive
- •Null Processes
- •Datatypes
- •Derived Datatypes
- •Type Constructors with Explicit Addresses
- •Datatype Constructors
- •Subarray Datatype Constructor
- •Distributed Array Datatype Constructor
- •Address and Size Functions
- •Lower-Bound and Upper-Bound Markers
- •Extent and Bounds of Datatypes
- •True Extent of Datatypes
- •Commit and Free
- •Duplicating a Datatype
- •Use of General Datatypes in Communication
- •Correct Use of Addresses
- •Decoding a Datatype
- •Examples
- •Pack and Unpack
- •Canonical MPI_PACK and MPI_UNPACK
- •Collective Communication
- •Introduction and Overview
- •Communicator Argument
- •Applying Collective Operations to Intercommunicators
- •Barrier Synchronization
- •Broadcast
- •Example using MPI_BCAST
- •Gather
- •Examples using MPI_GATHER, MPI_GATHERV
- •Scatter
- •Examples using MPI_SCATTER, MPI_SCATTERV
- •Example using MPI_ALLGATHER
- •All-to-All Scatter/Gather
- •Global Reduction Operations
- •Reduce
- •Signed Characters and Reductions
- •MINLOC and MAXLOC
- •All-Reduce
- •Process-local reduction
- •Reduce-Scatter
- •MPI_REDUCE_SCATTER_BLOCK
- •MPI_REDUCE_SCATTER
- •Scan
- •Inclusive Scan
- •Exclusive Scan
- •Example using MPI_SCAN
- •Correctness
- •Introduction
- •Features Needed to Support Libraries
- •MPI's Support for Libraries
- •Basic Concepts
- •Groups
- •Contexts
- •Intra-Communicators
- •Group Management
- •Group Accessors
- •Group Constructors
- •Group Destructors
- •Communicator Management
- •Communicator Accessors
- •Communicator Constructors
- •Communicator Destructors
- •Motivating Examples
- •Current Practice #1
- •Current Practice #2
- •(Approximate) Current Practice #3
- •Example #4
- •Library Example #1
- •Library Example #2
- •Inter-Communication
- •Inter-communicator Accessors
- •Inter-communicator Operations
- •Inter-Communication Examples
- •Caching
- •Functionality
- •Communicators
- •Windows
- •Datatypes
- •Error Class for Invalid Keyval
- •Attributes Example
- •Naming Objects
- •Formalizing the Loosely Synchronous Model
- •Basic Statements
- •Models of Execution
- •Static communicator allocation
- •Dynamic communicator allocation
- •The General case
- •Process Topologies
- •Introduction
- •Virtual Topologies
- •Embedding in MPI
- •Overview of the Functions
- •Topology Constructors
- •Cartesian Constructor
- •Cartesian Convenience Function: MPI_DIMS_CREATE
- •General (Graph) Constructor
- •Distributed (Graph) Constructor
- •Topology Inquiry Functions
- •Cartesian Shift Coordinates
- •Partitioning of Cartesian structures
- •Low-Level Topology Functions
- •An Application Example
- •MPI Environmental Management
- •Implementation Information
- •Version Inquiries
- •Environmental Inquiries
- •Tag Values
- •Host Rank
- •IO Rank
- •Clock Synchronization
- •Memory Allocation
- •Error Handling
- •Error Handlers for Communicators
- •Error Handlers for Windows
- •Error Handlers for Files
- •Freeing Errorhandlers and Retrieving Error Strings
- •Error Codes and Classes
- •Error Classes, Error Codes, and Error Handlers
- •Timers and Synchronization
- •Startup
- •Allowing User Functions at Process Termination
- •Determining Whether MPI Has Finished
- •Portable MPI Process Startup
- •The Info Object
- •Process Creation and Management
- •Introduction
- •The Dynamic Process Model
- •Starting Processes
- •The Runtime Environment
- •Process Manager Interface
- •Processes in MPI
- •Starting Processes and Establishing Communication
- •Reserved Keys
- •Spawn Example
- •Manager-worker Example, Using MPI_COMM_SPAWN.
- •Establishing Communication
- •Names, Addresses, Ports, and All That
- •Server Routines
- •Client Routines
- •Name Publishing
- •Reserved Key Values
- •Client/Server Examples
- •Ocean/Atmosphere - Relies on Name Publishing
- •Simple Client-Server Example.
- •Other Functionality
- •Universe Size
- •Singleton MPI_INIT
- •MPI_APPNUM
- •Releasing Connections
- •Another Way to Establish MPI Communication
- •One-Sided Communications
- •Introduction
- •Initialization
- •Window Creation
- •Window Attributes
- •Communication Calls
- •Examples
- •Accumulate Functions
- •Synchronization Calls
- •Fence
- •General Active Target Synchronization
- •Lock
- •Assertions
- •Examples
- •Error Handling
- •Error Handlers
- •Error Classes
- •Semantics and Correctness
- •Atomicity
- •Progress
- •Registers and Compiler Optimizations
- •External Interfaces
- •Introduction
- •Generalized Requests
- •Examples
- •Associating Information with Status
- •MPI and Threads
- •General
- •Initialization
- •Introduction
- •File Manipulation
- •Opening a File
- •Closing a File
- •Deleting a File
- •Resizing a File
- •Preallocating Space for a File
- •Querying the Size of a File
- •Querying File Parameters
- •File Info
- •Reserved File Hints
- •File Views
- •Data Access
- •Data Access Routines
- •Positioning
- •Synchronism
- •Coordination
- •Data Access Conventions
- •Data Access with Individual File Pointers
- •Data Access with Shared File Pointers
- •Noncollective Operations
- •Collective Operations
- •Seek
- •Split Collective Data Access Routines
- •File Interoperability
- •Datatypes for File Interoperability
- •Extent Callback
- •Datarep Conversion Functions
- •Matching Data Representations
- •Consistency and Semantics
- •File Consistency
- •Random Access vs. Sequential Files
- •Progress
- •Collective File Operations
- •Type Matching
- •Logical vs. Physical File Layout
- •File Size
- •Examples
- •Asynchronous I/O
- •I/O Error Handling
- •I/O Error Classes
- •Examples
- •Subarray Filetype Constructor
- •Requirements
- •Discussion
- •Logic of the Design
- •Examples
- •MPI Library Implementation
- •Systems with Weak Symbols
- •Systems Without Weak Symbols
- •Complications
- •Multiple Counting
- •Linker Oddities
- •Multiple Levels of Interception
- •Deprecated Functions
- •Deprecated since MPI-2.0
- •Deprecated since MPI-2.2
- •Language Bindings
- •Overview
- •Design
- •C++ Classes for MPI
- •Class Member Functions for MPI
- •Semantics
- •C++ Datatypes
- •Communicators
- •Exceptions
- •Mixed-Language Operability
- •Problems With Fortran Bindings for MPI
- •Problems Due to Strong Typing
- •Problems Due to Data Copying and Sequence Association
- •Special Constants
- •Fortran 90 Derived Types
- •A Problem with Register Optimization
- •Basic Fortran Support
- •Extended Fortran Support
- •The mpi Module
- •No Type Mismatch Problems for Subroutines with Choice Arguments
- •Additional Support for Fortran Numeric Intrinsic Types
- •Language Interoperability
- •Introduction
- •Assumptions
- •Initialization
- •Transfer of Handles
- •Status
- •MPI Opaque Objects
- •Datatypes
- •Callback Functions
- •Error Handlers
- •Reduce Operations
- •Addresses
- •Attributes
- •Extra State
- •Constants
- •Interlanguage Communication
- •Language Bindings Summary
- •Groups, Contexts, Communicators, and Caching Fortran Bindings
- •External Interfaces C++ Bindings
- •Change-Log
- •Bibliography
- •Examples Index
- •MPI Declarations Index
- •MPI Function Index
336 |
CHAPTER 11. ONE-SIDED COMMUNICATIONS |
1process in which the memory is accessed. Thus, in a put operation, source=origin and
2destination=target; in a get operation, source=target and destination=origin.
3
4
5
6
7
11.2 Initialization
11.2.1 Window Creation
8The initialization operation allows each process in an intracommunicator group to specify,
9in a collective operation, a \window" in its memory that is made accessible to accesses by
10remote processes. The call returns an opaque object that represents the group of processes
11that own and access the set of windows, and the attributes of each window, as speci ed by
12the initialization call.
13
14
15
16
17
18
19
20
21
22
23
24
25
MPI_WIN_CREATE(base, size, disp_unit, info, comm, win)
IN |
base |
initial address of window (choice) |
IN |
size |
size of window in bytes (non-negative integer) |
IN |
disp_unit |
local unit size for displacements, in bytes (positive in- |
|
|
teger) |
IN |
info |
info argument (handle) |
IN |
comm |
communicator (handle) |
OUT |
win |
window object returned by the call (handle) |
26 |
int MPI_Win_create(void *base, MPI_Aint size, int disp_unit, MPI_Info info, |
27 |
MPI_Comm comm, MPI_Win *win) |
28 |
MPI_WIN_CREATE(BASE, SIZE, DISP_UNIT, INFO, COMM, WIN, IERROR) |
|
|
29 |
<type> BASE(*) |
|
|
30 |
INTEGER(KIND=MPI_ADDRESS_KIND) SIZE |
|
|
31 |
INTEGER DISP_UNIT, INFO, COMM, WIN, IERROR |
|
|
32 |
fstatic MPI::Win MPI::Win::Create(const void* base, MPI::Aint size, int |
33 |
|
34 |
disp_unit, const MPI::Info& info, const MPI::Intracomm& comm) |
35 |
(binding deprecated, see Section 15.2) g |
36
This is a collective call executed by all processes in the group of comm. It returns
37
a window object that can be used by these processes to perform RMA operations. Each
38
process speci es a window of existing memory that it exposes to RMA accesses by the
39
processes in the group of comm. The window consists of size bytes, starting at address base.
40
A process may elect to expose no memory by specifying size = 0.
41
The displacement unit argument is provided to facilitate address arithmetic in RMA
42
operations: the target displacement argument of an RMA operation is scaled by the factor
43
disp_unit speci ed by the target process, at window creation.
44
45Rationale. The window size is speci ed using an address sized integer, so as to allow
46windows that span more than 4 GB of address space. (Even if the physical memory
47size is less than 4 GB, the address range may be larger than 4 GB, if addresses are
48not contiguous.) (End of rationale.)
11.2. INITIALIZATION |
337 |
Advice to users. Common choices for disp_unit are 1 (no scaling), and (in C syntax) sizeof(type), for a window that consists of an array of elements of type type. The later choice will allow one to use array indices in RMA calls, and have those scaled correctly to byte displacements, even in a heterogeneous environment. (End of advice to users.)
The info argument provides optimization hints to the runtime about the expected usage pattern of the window. The following info key is prede ned:
no_locks | if set to true, then the implementation may assume that the local window is never locked (by a call to MPI_WIN_LOCK). This implies that this window is not used for 3-party communication, and RMA can be implemented with no (less) asynchronous agent activity at this process.
The various processes in the group of comm may specify completely di erent target windows, in location, size, displacement units and info arguments. As long as all the get, put and accumulate accesses to a particular process t their speci c target window this should pose no problem. The same area in memory may appear in multiple windows, each associated with a di erent window object. However, concurrent communications to distinct, overlapping windows may lead to erroneous results.
Advice to users. A window can be created in any part of the process memory. However, on some systems, the performance of windows in memory allocated by MPI_ALLOC_MEM (Section 8.2, page 274) will be better. Also, on some systems, performance is improved when window boundaries are aligned at \natural" boundaries (word, double-word, cache line, page frame, etc.). (End of advice to users.)
Advice to implementors. In cases where RMA operations use di erent mechanisms in di erent memory areas (e.g., load/store in a shared memory segment, and an asynchronous handler in private memory), the MPI_WIN_CREATE call needs to gure out which type of memory is used for the window. To do so, MPI maintains, internally, the list of memory segments allocated by MPI_ALLOC_MEM, or by other, implementation speci c, mechanisms, together with information on the type of memory segment allocated. When a call to MPI_WIN_CREATE occurs, then MPI checks which segment contains each window, and decides, accordingly, which mechanism to use for RMA operations.
Vendors may provide additional, implementation-speci c mechanisms to allocate or to specify memory regions that are preferable for use in one-sided communication. In particular, such mechanisms can be used to place static variables into such preferred regions.
Implementors should document any performance impact of window alignment. (End of advice to implementors.)
MPI_WIN_FREE(win)
INOUT win |
window object (handle) |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
1
2
338 |
CHAPTER 11. ONE-SIDED COMMUNICATIONS |
int MPI_Win_free(MPI_Win *win)
3
4
MPI_WIN_FREE(WIN, IERROR) INTEGER WIN, IERROR
5fvoid MPI::Win::Free() (binding deprecated, see Section 15.2) g
6
7Frees the window object win and returns a null handle (equal to MPI_WIN_NULL). This
8is a collective call executed by all processes in the group associated with
9win. MPI_WIN_FREE(win) can be invoked by a process only after it has completed its
10involvement in RMA communications on window win: i.e., the process has called
11MPI_WIN_FENCE, or called MPI_WIN_WAIT to match a previous call to MPI_WIN_POST
12or called MPI_WIN_COMPLETE to match a previous call to MPI_WIN_START or called
13MPI_WIN_UNLOCK to match a previous call to MPI_WIN_LOCK. When the call returns,
14the window memory can be freed.
15
16
17
18
19
20
Advice to implementors. MPI_WIN_FREE requires a barrier synchronization: no process can return from free until all processes in the group of win called free. This, to ensure that no process will attempt to access a remote window (e.g., with lock/unlock) after it was freed. (End of advice to implementors.)
2111.2.2 Window Attributes
22The following three attributes are cached with a window, when the window is created.
23
24
25
26
27
MPI_WIN_BASE |
window base address. |
MPI_WIN_SIZE |
window size, in bytes. |
MPI_WIN_DISP_UNIT |
displacement unit associated with the window. |
In C, calls to MPI_Win_get_attr(win, MPI_WIN_BASE, &base, & ag),
28
MPI_Win_get_attr(win, MPI_WIN_SIZE, &size, & ag) and
29
MPI_Win_get_attr(win, MPI_WIN_DISP_UNIT, &disp_unit, & ag) will return in
30
base a pointer to the start of the window win, and will return in size and disp_unit pointers
31
to the size and displacement unit of the window, respectively. And similarly, in C++.
32
In Fortran, calls to MPI_WIN_GET_ATTR(win, MPI_WIN_BASE, base, ag, ierror),
33
MPI_WIN_GET_ATTR(win, MPI_WIN_SIZE, size, ag, ierror) and
34
MPI_WIN_GET_ATTR(win, MPI_WIN_DISP_UNIT, disp_unit, ag, ierror) will return in
35
base, size and disp_unit the (integer representation of) the base address, the size and the
36
displacement unit of the window win, respectively. (The window attribute access functions
37
are de ned in Section 6.7.3, page 230.)
38
The other \window attribute," namely the group of processes attached to the window,
39
can be retrieved using the call below.
40 |
|
41 |
|
42 |
MPI_WIN_GET_GROUP(win, group) |
|
|
43 |
|
44
45
46
IN |
win |
window object (handle) |
OUT |
group |
group of processes which share access to the window |
|
|
(handle) |
47 |
|
48 |
int MPI_Win_get_group(MPI_Win win, MPI_Group *group) |
|