Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OMEGA Broadcast functions #36

Merged
merged 3 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/omega/create_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def generate_scripts(self, outvar):
f.write("#!/usr/bin/env bash\n\n")

f.write("source ./omega_env.sh\n")
f.write("ctest # --rerun-failed --output-on-failure\n")
f.write("ctest $* # --rerun-failed --output-on-failure\n")

st = os.stat(omega_env)
os.chmod(omega_env, st.st_mode | stat.S_IEXEC)
Expand Down
26 changes: 13 additions & 13 deletions components/omega/doc/design/Broadcast.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function with simplified arguments.

### 4.1 Data types and parameters

For non-blocking broadcasts, we will alias the MPI_request type
For non-blocking broadcasts, we will alias the `MPI_request` type
to a Broadcast ID:

```c++
Expand All @@ -67,15 +67,15 @@ The first form is the simplest for a broadcast within the default
environment and from the master task:

```c++
int Broadcast([data type] value);
int Broadcast([data type] Value);
```

where `[data type]` is one of the supported types (I4, I8 R4, R8, Real,
boolean, std::string). In actual use, this would look like:

```c++
ierr = Broadcast(myIntVar);
ierr = Broadcast(myRealVar);
int Err = Broadcast(MyIntValue);
int Err = Broadcast(MyRealValue);
[etc for all data types]
```

Expand All @@ -88,8 +88,8 @@ This is similar to the above, but adds the additional argument
for the source rank to broadcast from.

```c++
int Broadcast([data type] value, ///< [in] value to be broadcast
const int srcRank ///< [in] rank to broadcast from
int Broadcast([data type] Value, ///< [in] value to be broadcast
const int SrcRank ///< [in] rank to broadcast from
); //
```

Expand All @@ -98,8 +98,8 @@ int Broadcast([data type] value, ///< [in] value to be broadcast
As in 4.2.1, but adds the machine environment as an argument:

```c++
int Broadcast([data type] value, ///< [in] value to be broadcast
const MachEnv subEnv, ///< [in] defined OMEGA environment
int Broadcast([data type] Value, ///< [in] value to be broadcast
const MachEnv *SubEnv, ///< [in] defined OMEGA environment
);
```

Expand All @@ -108,9 +108,9 @@ int Broadcast([data type] value, ///< [in] value to be broadcast
As in 4.2.2, but adds the machine environment as an argument:

```c++
int Broadcast([data type] value, ///< [in] value to be broadcast
const MachEnv subEnv, ///< [in] defined OMEGA environment
const int srcRank ///< [in] rank to broadcast from
int Broadcast([data type] Value, ///< [in] value to be broadcast
const MachEnv *SubEnv, ///< [in] defined OMEGA environment
const int SrcRank ///< [in] rank to broadcast from
);
```

Expand All @@ -128,9 +128,9 @@ included to wait for the request to complete. A non-blocking
sequence would look like:

```c++
BroadcastID myReqID = IBroadcast(myVar);
BroadcastID myReqID = IBroadcast(MyVar);
[ perform other tasks/computation ]
int err = IBroadcastWait(myReqID);
int Err = IBroadcastWait(MyReqID);
```

## 5 Verification and Testing
Expand Down
34 changes: 34 additions & 0 deletions components/omega/doc/devGuide/Broadcast.md
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.
2 changes: 2 additions & 0 deletions components/omega/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ userGuide/QuickStart
userGuide/OmegaBuild
userGuide/DataTypes
userGuide/MachEnv
userGuide/Broadcast
userGuide/Logging
```

Expand All @@ -34,6 +35,7 @@ userGuide/Logging
devGuide/QuickStart
devGuide/DataTypes
devGuide/MachEnv
devGuide/Broadcast
devGuide/CondaEnv
devGuide/Linting
devGuide/Docs
Expand Down
97 changes: 97 additions & 0 deletions components/omega/doc/userGuide/Broadcast.md
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.
5 changes: 3 additions & 2 deletions components/omega/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# build Omega

# Add source files for the library
file(GLOB _LIBSRC_FILES base/*.cpp infra/*.cpp ocn/*.cpp)
file(GLOB _LIBSRC_FILES infra/*.cpp base/*.cpp ocn/*.cpp)

# Create the library target
add_library(${OMEGA_LIB_NAME} ${_LIBSRC_FILES})

# add include directories
# add compiler options
target_compile_options(
${OMEGA_LIB_NAME}
PRIVATE
Expand All @@ -15,6 +15,7 @@ target_compile_options(
${OMEGA_CXX_FLAGS}
)

# add linker options
target_link_options(
${OMEGA_LIB_NAME}
PRIVATE
Expand Down
Loading
Loading