- •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
434 |
CHAPTER 13. I/O |
1MPI_REGISTER_DATAREP(datarep, read_conversion_fn, write_conversion_fn,
2dtype_ le_extent_fn, extra_state)
3 |
IN |
datarep |
data representation identi er (string) |
|
4 |
||||
|
|
|
||
5 |
IN |
read_conversion_fn |
function invoked to convert from le representation to |
|
6 |
|
|
native representation (function) |
|
7 |
IN |
write_conversion_fn |
function invoked to convert from native representation |
|
|
||||
8 |
|
|
to le representation (function) |
|
|
|
|
||
9 |
IN |
dtype_ le_extent_fn |
function invoked to get the extent of a datatype as |
|
10 |
||||
|
|
represented in the le (function) |
||
11 |
|
|
||
|
|
|
||
12 |
IN |
extra_state |
extra state |
|
13 |
|
|
|
|
14 |
int MPI_Register_datarep(char *datarep, |
|||
|
||||
15 |
|
MPI_Datarep_conversion_function *read_conversion_fn, |
||
|
|
|||
16 |
|
MPI_Datarep_conversion_function *write_conversion_fn, |
||
|
|
|||
17 |
|
MPI_Datarep_extent_function *dtype_file_extent_fn, |
||
|
|
|||
18 |
|
void *extra_state) |
|
|
|
|
|
||
19 |
MPI_REGISTER_DATAREP(DATAREP, READ_CONVERSION_FN, WRITE_CONVERSION_FN, |
|||
20 |
||||
|
DTYPE_FILE_EXTENT_FN, EXTRA_STATE, IERROR) |
|||
21 |
|
|||
|
CHARACTER*(*) DATAREP |
|
||
22 |
|
|
||
|
EXTERNAL READ_CONVERSION_FN, WRITE_CONVERSION_FN, DTYPE_FILE_EXTENT_FN |
|||
23 |
|
|||
|
INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE |
|||
24 |
|
|||
|
INTEGER IERROR |
|
||
25 |
|
|
||
|
|
|
||
26 |
fvoid MPI::Register_datarep(const char* datarep, |
|||
|
||||
27 |
|
MPI::Datarep_conversion_function* read_conversion_fn, |
||
|
|
|||
28 |
|
MPI::Datarep_conversion_function* write_conversion_fn, |
||
|
|
|||
29 |
|
MPI::Datarep_extent_function* dtype_file_extent_fn, |
||
|
|
|||
30 |
|
void* extra_state) (binding deprecated, see Section 15.2) g |
||
|
|
|
||
31 |
|
The call associates read_conversion_fn, write_conversion_fn, and dtype_ le_extent_fn |
||
32 |
|
|||
with the data representation identi er datarep. datarep can then be used as an argument |
||||
33 |
||||
to MPI_FILE_SET_VIEW, causing subsequent data access operations to call the conversion |
||||
34 |
||||
functions to convert all data items accessed between le data representation and native |
||||
35 |
||||
representation. MPI_REGISTER_DATAREP is a local operation and only registers the data |
||||
36 |
||||
representation for the calling MPI process. If datarep is already de ned, an error in the |
||||
37 |
||||
error class MPI_ERR_DUP_DATAREP is raised using the default le error handler (see Sec- |
||||
38 |
||||
tion 13.7, page 447). The length of a data representation string is limited to the value of |
||||
39 |
||||
MPI_MAX_DATAREP_STRING. MPI_MAX_DATAREP_STRING must have a value of at least 64. |
||||
40 |
||||
No routines are provided to delete data representations and free the associated resources; |
||||
41 |
||||
it is not expected that an application will generate them in signi cant numbers. |
||||
42 |
||||
|
|
|
||
43 |
|
|
|
|
44 |
Extent Callback |
|
||
45 |
typedef int MPI_Datarep_extent_function(MPI_Datatype datatype, |
|||
|
46
MPI_Aint *file_extent, void *extra_state);
47
48 |
SUBROUTINE DATAREP_EXTENT_FUNCTION(DATATYPE, EXTENT, EXTRA_STATE, IERROR) |
13.5. FILE INTEROPERABILITY |
435 |
INTEGER DATATYPE, IERROR
INTEGER(KIND=MPI_ADDRESS_KIND) EXTENT, EXTRA_STATE
ftypedef void MPI::Datarep_extent_function(const MPI::Datatype& datatype, MPI::Aint& file_extent, void* extra_state); (binding deprecated, see Section 15.2) g
The function dtype_ le_extent_fn must return, in le_extent, the number of bytes required to store datatype in the le representation. The function is passed, in extra_state, the argument that was passed to the MPI_REGISTER_DATAREP call. MPI will only call this routine with prede ned datatypes employed by the user.
Datarep Conversion Functions
typedef int MPI_Datarep_conversion_function(void *userbuf, MPI_Datatype datatype, int count, void *filebuf, MPI_Offset position, void *extra_state);
SUBROUTINE DATAREP_CONVERSION_FUNCTION(USERBUF, DATATYPE, COUNT, FILEBUF, POSITION, EXTRA_STATE, IERROR)
<TYPE> USERBUF(*), FILEBUF(*)
INTEGER COUNT, DATATYPE, IERROR
INTEGER(KIND=MPI_OFFSET_KIND) POSITION
INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE
ftypedef void MPI::Datarep_conversion_function(void* userbuf, MPI::Datatype& datatype, int count, void* filebuf, MPI::Offset position, void* extra_state); (binding deprecated, see Section 15.2) g
The function read_conversion_fn must convert from le data representation to native representation. Before calling this routine, MPI allocates and lls lebuf with
count contiguous data items. The type of each data item matches the corresponding entry for the prede ned datatype in the type signature of datatype. The function is passed, in extra_state, the argument that was passed to the MPI_REGISTER_DATAREP call. The function must copy all count data items from lebuf to userbuf in the distribution described by datatype, converting each data item from le representation to native representation. datatype will be equivalent to the datatype that the user passed to the read function. If the size of datatype is less than the size of the count data items, the conversion function must treat datatype as being contiguously tiled over the userbuf. The conversion function must begin storing converted data at the location in userbuf speci ed by position into the (tiled) datatype.
Advice to users. Although the conversion functions have similarities to MPI_PACK and MPI_UNPACK, one should note the di erences in the use of the arguments count and position. In the conversion functions, count is a count of data items (i.e., count of typemap entries of datatype), and position is an index into this typemap. In MPI_PACK, incount refers to the number of whole datatypes, and position is a number of bytes. (End of advice to users.)
Advice to implementors. A converted read operation could be implemented as follows:
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
3
4
436 |
CHAPTER 13. I/O |
1.Get le extent of all data items
2.Allocate a lebuf large enough to hold all count data items
3.Read data from le into lebuf
54. Call read_conversion_fn to convert data and place it into userbuf
6
7
8
9
5. Deallocate lebuf
(End of advice to implementors.)
10If MPI cannot allocate a bu er large enough to hold all the data to be converted from
11a read operation, it may call the conversion function repeatedly using the same datatype
12and userbuf, and reading successive chunks of data to be converted in lebuf. For the rst
13call (and in the case when all the data to be converted ts into lebuf), MPI will call the
14function with position set to zero. Data converted during this call will be stored in the
15userbuf according to the rst count data items in datatype. Then in subsequent calls to the
16conversion function, MPI will increment the value in position by the count of items converted
17in the previous call, and the userbuf pointer will be unchanged.
18
19Rationale. Passing the conversion function a position and one datatype for the
20transfer allows the conversion function to decode the datatype only once and cache an
21internal representation of it on the datatype. Then on subsequent calls, the conversion
22function can use the position to quickly nd its place in the datatype and continue
23storing converted data where it left o at the end of the previous call. (End of
24rationale.)
25
26Advice to users. Although the conversion function may usefully cache an internal
27representation on the datatype, it should not cache any state information speci c to
28an ongoing conversion operation, since it is possible for the same datatype to be used
29concurrently in multiple conversion operations. (End of advice to users.)
30
31The function write_conversion_fn must convert from native representation to le data
32representation. Before calling this routine, MPI allocates lebuf of a size large enough to
33hold count contiguous data items. The type of each data item matches the corresponding
34entry for the prede ned datatype in the type signature of datatype. The function must copy
35count data items from userbuf in the distribution described by datatype, to a contiguous
36distribution in lebuf, converting each data item from native representation to le repre-
37sentation. If the size of datatype is less than the size of count data items, the conversion
38function must treat datatype as being contiguously tiled over the userbuf.
39The function must begin copying at the location in userbuf speci ed by position into
40the (tiled) datatype. datatype will be equivalent to the datatype that the user passed to the
41write function. The function is passed, in extra_state, the argument that was passed to the
42MPI_REGISTER_DATAREP call.
43The prede ned constant MPI_CONVERSION_FN_NULL may be used as either
44write_conversion_fn or read_conversion_fn. In that case, MPI will not attempt to invoke
45write_conversion_fn or read_conversion_fn, respectively, but will perform the requested data
46access using the native data representation.
47An MPI implementation must ensure that all data accessed is converted, either by
48using a lebuf large enough to hold all the requested data items or else by making repeated