Skip to content

Commit

Permalink
Merge branch 'develop' into lroberts36/mg-riot-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lroberts36 authored Mar 19, 2024
2 parents d419c1e + cd96dd7 commit 77057f4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [[PR 973]](https://github.com/parthenon-hpc-lab/parthenon/pull/973) Multigrid performance upgrades

### Fixed (not changing behavior/API/variables/...)
- [[PR1023]](https://github.com/parthenon-hpc-lab/parthenon/pull/1023) Fix broken param of a scalar bool
- [[PR1012]](https://github.com/parthenon-hpc-lab/parthenon/pull/1012) Remove accidentally duplicated code
- [[PR992]](https://github.com/parthenon-hpc-lab/parthenon/pull/992) Allow custom PR ops with sparse pools
- [[PR988]](https://github.com/parthenon-hpc-lab/parthenon/pull/988) Fix bug in neighbor finding routine for small, periodic, refined meshes
Expand Down
25 changes: 19 additions & 6 deletions src/outputs/parthenon_hdf5_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,26 @@ std::vector<std::string> HDF5ReadAttributeVec(hid_t location, const std::string
// JMM: A little circular but it works.
template <>
std::vector<bool> HDF5ReadAttributeVec(hid_t location, const std::string &name) {
HostArray1D<bool> temp;
HDF5ReadAttribute(location, name, temp);
std::vector<bool> out(temp.size());
for (int i = 0; i < temp.size(); ++i) {
out[i] = temp[i];
H5A attr;
auto [rank, dim, size] = HDF5GetAttributeInfo(location, name, attr);

// Check type
const hid_t type = H5T_NATIVE_HBOOL;
const H5T hdf5_type = H5T::FromHIDCheck(H5Aget_type(attr));
auto status = PARTHENON_HDF5_CHECK(H5Tequal(type, hdf5_type));
PARTHENON_REQUIRE_THROWS(status > 0, "Type mismatch for attribute " + name);

// Read data from file
// can't use std::vector here because std::vector<bool> doesn't have .data() member
std::unique_ptr<hbool_t[]> data(new hbool_t[size]);
PARTHENON_HDF5_CHECK(H5Aread(attr, type, data.get()));

std::vector<bool> res(size);
for (size_t i = 0; i < res.size(); ++i) {
res[i] = data[i];
}
return out;

return res;
}

template <>
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/tasks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ class TaskCollection {
return regions.back();
}
TaskListStatus Execute() {
ThreadPool pool(1);
static ThreadPool pool(1);
return Execute(pool);
}
TaskListStatus Execute(ThreadPool &pool) {
Expand Down
10 changes: 10 additions & 0 deletions tst/unit/test_unit_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ TEST_CASE("A set of params can be dumped to file", "[params][output]") {
Real scalar = 3.0;
params.Add("scalar", scalar, restart);

bool boolscalar = false;
params.Add("boolscalar", boolscalar, restart);

std::vector<int> vector = {0, 1, 2};
params.Add("vector", vector, only_mutable);

Expand Down Expand Up @@ -217,6 +220,9 @@ TEST_CASE("A set of params can be dumped to file", "[params][output]") {
Real test_scalar = 0.0;
rparams.Add("scalar", test_scalar, restart);

bool test_bool = true;
rparams.Add("boolscalar", test_bool, restart);

std::vector<int> test_vector;
rparams.Add("vector", test_vector, only_mutable);

Expand All @@ -234,6 +240,10 @@ TEST_CASE("A set of params can be dumped to file", "[params][output]") {
AND_THEN("The values for the restartable params are updated to match the file") {
auto test_scalar = rparams.Get<Real>("scalar");
REQUIRE(std::abs(test_scalar - scalar) <= 1e-10);

auto test_bool = rparams.Get<bool>("boolscalar");
REQUIRE(test_bool == boolscalar);

auto test_hostarr = params.Get<parthenon::HostArray2D<Real>>("hostarr2d");
REQUIRE(test_hostarr.extent_int(0) == hostarr.extent_int(0));
REQUIRE(test_hostarr.extent_int(1) == hostarr.extent_int(1));
Expand Down

0 comments on commit 77057f4

Please sign in to comment.