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

Fix segfault and other issues in time stepper test #185

Merged
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
46 changes: 10 additions & 36 deletions components/omega/src/base/Halo.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,10 @@ class Halo {
/// neighboring task and pack them into the proper send buffer for
/// that Neighbor.
template <typename T>
typename std::enable_if_t<ArrayRank<T>::Is1D, int>
std::enable_if_t<ArrayRank<T>::Is1D>
packBuffer(const T &Array, // 1D Kokkos array of any type
const I4 CurNeighbor // current neighbor
) {
I4 Err = 0;

OMEGA_SCOPE(LocList, Neighbors[CurNeighbor].SendLists[CurElem]);
OMEGA_SCOPE(LocNeighbor, Neighbors[CurNeighbor]);
Expand All @@ -301,16 +300,13 @@ class Halo {
LocBuffH(IExch) = RVal;
}
}

return Err;
}

template <typename T>
typename std::enable_if_t<ArrayRank<T>::Is2D, int>
std::enable_if_t<ArrayRank<T>::Is2D>
packBuffer(const T &Array, // 2D Kokkos array of any type
const I4 CurNeighbor // current neighbor
) {
I4 Err = 0;

OMEGA_SCOPE(LocList, Neighbors[CurNeighbor].SendLists[CurElem]);
OMEGA_SCOPE(LocNeighbor, Neighbors[CurNeighbor]);
Expand Down Expand Up @@ -342,15 +338,13 @@ class Halo {
}
}
}
return Err;
}

template <typename T>
typename std::enable_if_t<ArrayRank<T>::Is3D, int>
std::enable_if_t<ArrayRank<T>::Is3D>
packBuffer(const T &Array, // 3D Kokkos array of any type
const I4 CurNeighbor // current neighbor
) {
I4 Err = 0;

OMEGA_SCOPE(LocList, Neighbors[CurNeighbor].SendLists[CurElem]);
OMEGA_SCOPE(LocNeighbor, Neighbors[CurNeighbor]);
Expand Down Expand Up @@ -387,15 +381,13 @@ class Halo {
}
}
}
return Err;
}

template <typename T>
typename std::enable_if_t<ArrayRank<T>::Is4D, int>
std::enable_if_t<ArrayRank<T>::Is4D>
packBuffer(const T &Array, // 4D Kokkos array of any type
const I4 CurNeighbor // current neighbor
) {
I4 Err = 0;

OMEGA_SCOPE(LocList, Neighbors[CurNeighbor].SendLists[CurElem]);
OMEGA_SCOPE(LocNeighbor, Neighbors[CurNeighbor]);
Expand Down Expand Up @@ -437,15 +429,13 @@ class Halo {
}
}
}
return Err;
}

template <typename T>
typename std::enable_if_t<ArrayRank<T>::Is5D, int>
std::enable_if_t<ArrayRank<T>::Is5D>
packBuffer(const T &Array, // 5D Kokkos array of any type
const I4 CurNeighbor // current neighbor
) {
I4 Err = 0;

OMEGA_SCOPE(LocList, Neighbors[CurNeighbor].SendLists[CurElem]);
OMEGA_SCOPE(LocNeighbor, Neighbors[CurNeighbor]);
Expand Down Expand Up @@ -492,19 +482,17 @@ class Halo {
}
}
}
return Err;
}

/// Buffer unpack specialized function templates for supported Kokkos array
/// ranks. After receiving a message from a neighboring task, save the
/// elements of the proper receive buffer for that Neighbor into the
/// corresponding halo elements of the input Array
template <typename T>
typename std::enable_if_t<ArrayRank<T>::Is1D, int>
std::enable_if_t<ArrayRank<T>::Is1D>
unpackBuffer(const T &Array, // 1D Kokkos array of any type
const I4 CurNeighbor // current neighbor
) {
I4 Err = 0;

using ValType = typename T::non_const_value_type;

Expand All @@ -527,16 +515,13 @@ class Halo {
Array(IArr) = reinterpret_cast<ValType &>(LocBuffH(IExch));
}
}

return Err;
}

template <typename T>
typename std::enable_if_t<ArrayRank<T>::Is2D, int>
std::enable_if_t<ArrayRank<T>::Is2D>
unpackBuffer(const T &Array, // 2D Kokkos array of any type
const I4 CurNeighbor // current neighbor
) {
I4 Err = 0;

using ValType = typename T::non_const_value_type;

Expand Down Expand Up @@ -566,16 +551,13 @@ class Halo {
}
}
}

return Err;
}

template <typename T>
typename std::enable_if_t<ArrayRank<T>::Is3D, int>
std::enable_if_t<ArrayRank<T>::Is3D>
unpackBuffer(const T &Array, // 3D Kokkos array of any type
const I4 CurNeighbor // current neighbor
) {
I4 Err = 0;

using ValType = typename T::non_const_value_type;

Expand Down Expand Up @@ -611,16 +593,13 @@ class Halo {
}
}
}

return Err;
}

template <typename T>
typename std::enable_if_t<ArrayRank<T>::Is4D, int>
std::enable_if_t<ArrayRank<T>::Is4D>
unpackBuffer(const T &Array, // 4D Kokkos array of any type
const I4 CurNeighbor // current neighbor
) {
I4 Err = 0;

using ValType = typename T::non_const_value_type;

Expand Down Expand Up @@ -662,16 +641,13 @@ class Halo {
}
}
}

return Err;
}

template <typename T>
typename std::enable_if_t<ArrayRank<T>::Is5D, int>
std::enable_if_t<ArrayRank<T>::Is5D>
unpackBuffer(const T &Array, // 5D Kokkos array of any type
const I4 CurNeighbor // current neighbor
) {
I4 Err = 0;

using ValType = typename T::non_const_value_type;

Expand Down Expand Up @@ -718,8 +694,6 @@ class Halo {
}
}
}

return Err;
}

//---------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions components/omega/src/timeStepping/RungeKutta4Stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ void RungeKutta4Stepper::finalizeInit() {
int NCellsSize = Mesh->NCellsSize;
int NTimeLevels = 1; // for provisional tracer

ProvisState =
OceanState::create("Provis", Mesh, MeshHalo, NVertLevels, NTimeLevels);
ProvisState = OceanState::create("Provis" + Name, Mesh, MeshHalo,
NVertLevels, NTimeLevels);
if (!ProvisState)
LOG_CRITICAL("Error creating Provis state");

Expand Down
30 changes: 25 additions & 5 deletions components/omega/test/timeStepping/TimeStepperTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,30 @@ int initTimeStepperTest(const std::string &mesh) {
initLogging(DefEnv);

// Open config file
OMEGA::Config("Omega");
Err = OMEGA::Config::readAll("omega.yml");
Config("Omega");
Err = Config::readAll("omega.yml");
if (Err != 0) {
LOG_CRITICAL("TimeStepperTest: Error reading config file");
return Err;
}

// Reset NVertLevels to 1 regardless of config value
Config *OmegaConfig = Config::getOmegaConfig();
Config DimConfig("Dimension");
Err = OmegaConfig->get(DimConfig);
if (Err != 0) {
LOG_CRITICAL("TimeStepperTest: Dimension group not found in Config");
return Err;
}
Err = DimConfig.set("NVertLevels", NVertLevels);
if (Err != 0) {
LOG_CRITICAL("TimeStepperTest: Unable to reset NVertLevels in Config");
return Err;
}

// Horz dimensions will be created in HorzMesh
auto VertDim = Dimension::create("NVertLevels", NVertLevels);

// Note that the default time stepper is not used in subsequent tests
// but is initialized here because the number of time levels is needed
// to initialize the Tracers. If a later timestepper test uses more time
Expand Down Expand Up @@ -198,6 +215,12 @@ int initTimeStepperTest(const std::string &mesh) {
LOG_ERROR("TimeStepperTest: error initializing tracers infrastructure");
}

int AuxStateErr = AuxiliaryState::init();
if (AuxStateErr != 0) {
Err++;
LOG_ERROR("TimeStepperTest: error initializing default aux state");
}

Err = Tendencies::init();
if (Err != 0) {
LOG_CRITICAL("Error initializing default tendencies");
Expand All @@ -223,9 +246,6 @@ int initTimeStepperTest(const std::string &mesh) {
auto *DefMesh = HorzMesh::getDefault();
auto *DefHalo = Halo::getDefault();

// Horz dimensions created in HorzMesh
auto VertDim = Dimension::create("NVertLevels", NVertLevels);

int NTracers = Tracers::getNumTracers();
const int NTimeLevels = 2;
auto *TestOceanState = OceanState::create("TestState", DefMesh, DefHalo,
Expand Down
Loading