forked from E3SM-Project/E3SM
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds OMEGA Broadcast functions This PR adds OMEGA broadcasting functions with documentation. * implements blocking broadcast functions * adds testings for the functions * adds user-guide and developer-guide fixed the issues found during PR-review: * properly use MasterRank in MachEnv instead of rank=0 * renamed variable names to match with Clang style * updated document accordingly * moved Broadcast from infra to base directory * moved Broadcast mode from infra to base directory * fixed bugs in document
- Loading branch information
Showing
10 changed files
with
720 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(omega-dev-broadcast)= | ||
|
||
# Omega Broadcast | ||
|
||
## Code Structure | ||
|
||
Omega Broadcasting functions are organized within two primary files: | ||
|
||
1. **Header File**: Located at `src/base/Broadcast.h`, this file declares | ||
various functions of the `Broadcast`. These functions are | ||
distinctively overloaded to accommodate multiple broadcasting needs. | ||
The key differentiators for these overloads are based on: | ||
- The types of variables being broadcasted. | ||
- The specific ordering of function arguments. | ||
|
||
2. **Implementation File**: The actual implementations of these declared | ||
functions are found in `src/base/Broadcast.cpp`. | ||
|
||
## IBroadcast Interface | ||
|
||
Parallel to `Broadcast`, there is the `IBroadcast` interface. Currently under | ||
development, `IBroadcast` focuses on overloading functions for non-blocking | ||
broadcast operations. This aspect of the Omega Broadcasting system is | ||
designed to provide more efficient and asynchronous communication capabilities. | ||
|
||
## Integration with MPI | ||
|
||
At their core, the Omega broadcast functions serve as wrappers around | ||
the MPI (Message Passing Interface) broadcast functions. They are | ||
intricately designed to: | ||
- Retrieve values from the Omega Environment. | ||
- Utilize Omega-specific data types. | ||
- Seamlessly feed these values into the standard MPI functions for | ||
effective broadcasting. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
(omega-user-broadcast)= | ||
|
||
# Omega Broadcast | ||
|
||
## Broadcasting Functions | ||
|
||
Omega's broadcasting functions offer developers a streamlined method for | ||
disseminating scalar and array values among MPI tasks. These functions are | ||
categorized into two types: Blocking and Non-blocking. | ||
|
||
### Blocking Broadcasting Functions | ||
|
||
When it comes to MPI broadcast operations, a blocking broadcast would imply | ||
that the function call to broadcast data to all processes in a group does | ||
not return until the data has been sent and correctly received by all the | ||
target processes. | ||
|
||
### Including the Broadcasting Functions in Your Code | ||
|
||
To leverage Omega's broadcasting functions, you must include the Broadcast.h | ||
header file in your source code: | ||
|
||
```c | ||
#include "Broadcast.h" | ||
``` | ||
|
||
### Broadcasting Scalar or Array Values | ||
|
||
For broadcasting either scalar or array values, utilize the Broadcast | ||
function as demonstrated below: | ||
|
||
```c | ||
OMEGA::I4 MyVal = 1; | ||
|
||
// Broadcasting from the master task | ||
OMEGA::Broadcast(MyVal); | ||
``` | ||
The above example illustrates the broadcasting of an OMEGA::I4 type scalar | ||
value from the master task of the default Omega environment. | ||
### Specifying broadcasting task and/or environment in Omega | ||
For developers seeking to modify the sending task or the Omega environment | ||
during broadcasting, Omega offers flexible syntax options. These additional | ||
arguments to the Broadcast function enable customization, while maintaining | ||
the simplicity of the basic broadcasting operation. | ||
```c | ||
OMEGA::I4 MyVal = 1; | ||
const int RootTask = 1; | ||
// Get a specific Omega Machine Environment | ||
OMEGA::MachEnv *SubsetEnv = OMEGA::MachEnv::getEnv("Subset"); | ||
// broadcast from the master task of SubsetEnv environment | ||
OMEGA::Broadcast(MyVal, SubsetEnv); | ||
// broadcast from task 1 of SubsetEnv environment | ||
OMEGA::Broadcast(MyVal, SubsetEnv, RootTask); | ||
// broadcast from task 1 of the default environment | ||
OMEGA::Broadcast(MyVal, RootTask); | ||
``` | ||
|
||
### Broadcasting Array Values | ||
|
||
The syntax for broadcasting arrays is analogous to that used | ||
for scalar values: | ||
|
||
```c | ||
std::vector<OMEGA::R8> MyVector; | ||
|
||
for (int i = 1; i <= 5; i++) { | ||
MyVector.push_back(1.0); | ||
} | ||
|
||
OMEGA::Broadcast(MyVector, RootTask); | ||
``` | ||
This example shows how to broadcast an array of OMEGA::R8 type values, | ||
specifying the root task for broadcasting. | ||
### Supported Data Types for Broadcasting | ||
The Broadcast functions are compatible with the following data types: | ||
* `OMEGA::I4` | ||
* `OMEGA::I8` | ||
* `OMEGA::R4` | ||
* `OMEGA::R8` | ||
* `bool` | ||
* `std::string` (NOTE: array of strings are not supported) | ||
## Non-blocking Broadcasting Functions | ||
This feature is currently under development and will offer asynchronous | ||
broadcasting capabilities. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.