diff --git a/include/parallelzone/hardware/ram/ram.hpp b/include/parallelzone/hardware/ram/ram.hpp index ae48bb29..046f1689 100644 --- a/include/parallelzone/hardware/ram/ram.hpp +++ b/include/parallelzone/hardware/ram/ram.hpp @@ -25,7 +25,7 @@ namespace parallelzone::hardware { namespace detail_ { -class RAMPIMPL; +struct RAMPIMPL; } /** @brief Provides a runtime API for interacting with memory diff --git a/include/parallelzone/mpi_helpers/commpp/commpp.ipp b/include/parallelzone/mpi_helpers/commpp/commpp.ipp index 87ee8de9..893245aa 100644 --- a/include/parallelzone/mpi_helpers/commpp/commpp.ipp +++ b/include/parallelzone/mpi_helpers/commpp/commpp.ipp @@ -90,7 +90,7 @@ typename CommPP::gather_return_type CommPP::gather_t_( auto serialized_size = buffer.size() / size(); value_type vec(size()); - for(size_type i = 0, j = 0; i < buffer.size(); + for(size_type i = 0, j = 0; i < size_type(buffer.size()); i += serialized_size, ++j) { const_binary_reference view(binary_rv->data() + i, serialized_size); vec[j] = std::move(from_binary_view(view)); @@ -122,8 +122,6 @@ typename CommPP::gather_return_type CommPP::gatherv_t_( using return_type = typename CommPP::gather_return_type; using value_type = typename return_type::value_type; - const bool am_i_root = root.has_value() ? me() == *root : true; - if constexpr(needs_serialized_v) { // Do gather in binary auto binary = make_binary_buffer(std::forward(input)); @@ -165,8 +163,7 @@ typename CommPP::gather_return_type CommPP::gatherv_t_( constexpr auto t_size = sizeof(element_type); value_type vec; - auto n_elements = buffer.size() / t_size; - for(size_type i = 0; i < buffer.size(); i += t_size) { + for(size_type i = 0; i < size_type(buffer.size()); i += t_size) { const_binary_reference view(buffer.data() + i, t_size); vec.emplace_back(std::move(from_binary_view(view))); } diff --git a/include/parallelzone/runtime/resource_set.hpp b/include/parallelzone/runtime/resource_set.hpp index fc02843d..94d07c8d 100644 --- a/include/parallelzone/runtime/resource_set.hpp +++ b/include/parallelzone/runtime/resource_set.hpp @@ -22,7 +22,7 @@ namespace parallelzone::runtime { namespace detail_ { -class ResourceSetPIMPL; +struct ResourceSetPIMPL; } /** @brief A set of runtime resources. diff --git a/include/parallelzone/runtime/runtime_view.hpp b/include/parallelzone/runtime/runtime_view.hpp index 14164b54..8cd51aed 100644 --- a/include/parallelzone/runtime/runtime_view.hpp +++ b/include/parallelzone/runtime/runtime_view.hpp @@ -21,7 +21,7 @@ namespace parallelzone::runtime { namespace detail_ { -class RuntimeViewPIMPL; +struct RuntimeViewPIMPL; } /** @brief A view of the execution environment. diff --git a/src/parallelzone/runtime/resource_set.cpp b/src/parallelzone/runtime/resource_set.cpp index 0db05d22..0aa1ce6a 100644 --- a/src/parallelzone/runtime/resource_set.cpp +++ b/src/parallelzone/runtime/resource_set.cpp @@ -51,8 +51,8 @@ ResourceSet::size_type ResourceSet::mpi_rank() const noexcept { bool ResourceSet::is_mine() const noexcept { if(!has_pimpl_()) return false; - if(mpi_rank() == MPI_PROC_NULL) return false; - return m_pimpl_->m_my_mpi.me() == mpi_rank(); + if(mpi_rank() == size_type(MPI_PROC_NULL)) return false; + return size_type(m_pimpl_->m_my_mpi.me()) == mpi_rank(); } bool ResourceSet::has_ram() const noexcept { return has_pimpl_() && !null(); } @@ -71,7 +71,9 @@ ResourceSet::logger_reference ResourceSet::logger() const { // -- Utility methods // ----------------------------------------------------------------------------- -bool ResourceSet::null() const noexcept { return mpi_rank() == MPI_PROC_NULL; } +bool ResourceSet::null() const noexcept { + return mpi_rank() == size_type(MPI_PROC_NULL); +} bool ResourceSet::empty() const noexcept { // TODO: Need to check for loggers diff --git a/tests/cxx/doc_snippets/quickstart.cpp b/tests/cxx/doc_snippets/quickstart.cpp index 8378ddd2..1a7a7ccb 100644 --- a/tests/cxx/doc_snippets/quickstart.cpp +++ b/tests/cxx/doc_snippets/quickstart.cpp @@ -50,6 +50,7 @@ TEST_CASE("quick start") { // Figure out how much RAM the local process has access to const auto my_ram = my_rs.ram().total_space(); + REQUIRE(my_ram >= 0); REQUIRE(n_rs > 0); if(my_rs_rank == 0) { REQUIRE(ranks_on_0); diff --git a/tests/cxx/doc_snippets/ram.cpp b/tests/cxx/doc_snippets/ram.cpp index 78dff63e..f0821665 100644 --- a/tests/cxx/doc_snippets/ram.cpp +++ b/tests/cxx/doc_snippets/ram.cpp @@ -57,4 +57,6 @@ TEST_CASE("ram") { } else { REQUIRE_FALSE(all_data); } + REQUIRE(rank_0_total >= 0); + REQUIRE(my_total_ram >= 0); } diff --git a/tests/cxx/doc_snippets/resource_set.cpp b/tests/cxx/doc_snippets/resource_set.cpp index 55c7c540..b66f93b9 100644 --- a/tests/cxx/doc_snippets/resource_set.cpp +++ b/tests/cxx/doc_snippets/resource_set.cpp @@ -57,4 +57,6 @@ TEST_CASE("resource_set") { REQUIRE(is_local == am_i_supposed_to_be_0); REQUIRE(do_i_have_ram); REQUIRE(does_0_have_ram); + REQUIRE(my_ram.total_space() >= 0); + REQUIRE(ram_0.total_space() >= 0); } diff --git a/tests/cxx/unit_tests/parallelzone/hardware/ram/ram.cpp b/tests/cxx/unit_tests/parallelzone/hardware/ram/ram.cpp index b68b4718..f0e71019 100644 --- a/tests/cxx/unit_tests/parallelzone/hardware/ram/ram.cpp +++ b/tests/cxx/unit_tests/parallelzone/hardware/ram/ram.cpp @@ -30,7 +30,6 @@ TEST_CASE("RAM") { using size_type = ram_type::size_type; const auto& run = testing::PZEnvironment::comm_world(); const auto& rs = run.my_resource_set(); - auto my_rank = rs.mpi_rank(); RAM defaulted; RAM has_value = rs.ram(); diff --git a/tests/cxx/unit_tests/parallelzone/logging/detail_/spdlog/spdlog.cpp b/tests/cxx/unit_tests/parallelzone/logging/detail_/spdlog/spdlog.cpp index 7a1b1113..fb055004 100644 --- a/tests/cxx/unit_tests/parallelzone/logging/detail_/spdlog/spdlog.cpp +++ b/tests/cxx/unit_tests/parallelzone/logging/detail_/spdlog/spdlog.cpp @@ -51,7 +51,7 @@ TEST_CASE("SpdlogPIMPL") { severity::info, severity::warn, severity::error, severity::critical}; - for(auto i = 0; i < all_levels.size(); ++i) { + for(decltype(all_levels.size()) i = 0; i < all_levels.size(); ++i) { SECTION("level = " + std::to_string(i)) { ss_log.set_severity(all_levels[i]); ss_log.log(severity::trace, "Hello trace"); diff --git a/tests/cxx/unit_tests/parallelzone/mpi_helpers/binary_buffer/binary_view.cpp b/tests/cxx/unit_tests/parallelzone/mpi_helpers/binary_buffer/binary_view.cpp index 067b37a6..95176eae 100644 --- a/tests/cxx/unit_tests/parallelzone/mpi_helpers/binary_buffer/binary_view.cpp +++ b/tests/cxx/unit_tests/parallelzone/mpi_helpers/binary_buffer/binary_view.cpp @@ -31,7 +31,6 @@ namespace { template auto byte_data(T&& input) { using const_pointer = BinaryView::const_pointer; - using size_type = BinaryView::size_type; using clean_type = std::decay_t; auto p = reinterpret_cast(input.data()); auto n = input.size() * sizeof(typename clean_type::value_type); diff --git a/tests/cxx/unit_tests/parallelzone/mpi_helpers/commpp/commpp.cpp b/tests/cxx/unit_tests/parallelzone/mpi_helpers/commpp/commpp.cpp index 0da631b7..667291c0 100644 --- a/tests/cxx/unit_tests/parallelzone/mpi_helpers/commpp/commpp.cpp +++ b/tests/cxx/unit_tests/parallelzone/mpi_helpers/commpp/commpp.cpp @@ -22,9 +22,6 @@ using size_type = std::size_t; using opt_root_type = std::optional; TEST_CASE("CommPP") { - using value_type = CommPP::binary_type; - using const_reference = CommPP::const_binary_reference; - auto& world = testing::PZEnvironment::comm_world(); CommPP defaulted; @@ -35,8 +32,8 @@ TEST_CASE("CommPP") { MPI_Comm_size(comm.comm(), &corr_size); MPI_Comm_rank(comm.comm(), &corr_rank); - auto n_ranks = comm.size(); - auto me = comm.me(); + auto n_ranks = size_type(comm.size()); + auto me = size_type(comm.me()); SECTION("CTors") { SECTION("Default") { @@ -125,13 +122,13 @@ TEST_CASE("CommPP") { SECTION("size()") { REQUIRE(defaulted.size() == 0); REQUIRE(null.size() == 0); - REQUIRE(n_ranks == corr_size); + REQUIRE(n_ranks == size_type(corr_size)); } SECTION("me()") { REQUIRE(defaulted.me() == MPI_PROC_NULL); REQUIRE(null.me() == MPI_PROC_NULL); - REQUIRE(me == corr_rank); + REQUIRE(me == size_type(corr_rank)); } SECTION("swap") { @@ -168,16 +165,15 @@ TEST_CASE("CommPP") { // These loops test various MPI operations under different roots and // different message sizes. - // All of these types must be constructible given a single std::size_t - const int max_ranks = 5; - const std::size_t max_chunk_size = 5; - using needs_serialized = std::string; - using no_serialization = double; + // All of these types must be constructible given a single size_type + const size_type max_ranks = 5; + const size_type max_chunk_size = 5; + using needs_serialized = std::string; + using no_serialization = double; - for(std::size_t chunk_size = 1; chunk_size < max_chunk_size; ++chunk_size) { + for(size_type chunk_size = 1; chunk_size < max_chunk_size; ++chunk_size) { auto chunk_str = " chunk = " + std::to_string(chunk_size); auto begin = me * chunk_size; - auto end = begin + chunk_size; SECTION("all gather" + chunk_str) { SECTION("needs serialized") { @@ -205,7 +201,7 @@ TEST_CASE("CommPP") { data_type local_data(chunk_size * me, "Hello"); auto rv = comm.gatherv(local_data); std::vector corr; - for(std::size_t i = 0; i < n_ranks; ++i) { + for(size_type i = 0; i < n_ranks; ++i) { corr.emplace_back(data_type(chunk_size * i, "Hello")); } REQUIRE(rv == corr); @@ -240,7 +236,7 @@ TEST_CASE("CommPP") { REQUIRE(rv == corr); } - for(std::size_t root = 0; root < std::min(n_ranks, max_ranks); ++root) { + for(size_type root = 0; root < std::min(n_ranks, max_ranks); ++root) { auto root_str = " root = " + std::to_string(root); SECTION("gather " + root_str + chunk_str) { @@ -281,7 +277,7 @@ TEST_CASE("CommPP") { if(me == root) { std::vector corr; - for(std::size_t i = 0; i < n_ranks; ++i) { + for(size_type i = 0; i < n_ranks; ++i) { corr.emplace_back( data_type(chunk_size * i, "Hello")); } diff --git a/tests/cxx/unit_tests/parallelzone/mpi_helpers/commpp/detail_/commpp_pimpl.cpp b/tests/cxx/unit_tests/parallelzone/mpi_helpers/commpp/detail_/commpp_pimpl.cpp index 27145b7a..fd8f2654 100644 --- a/tests/cxx/unit_tests/parallelzone/mpi_helpers/commpp/detail_/commpp_pimpl.cpp +++ b/tests/cxx/unit_tests/parallelzone/mpi_helpers/commpp/detail_/commpp_pimpl.cpp @@ -49,9 +49,7 @@ auto make_data(std::size_t min, std::size_t max) { */ template void gather_kernel(std::size_t chunk_size, root_type root, pimpl_type& comm) { - using reference = pimpl_type::binary_reference; using const_reference = pimpl_type::const_binary_reference; - using size_type = std::size_t; auto am_i_root = root.has_value() ? comm.me() == *root : true; auto data = make_data(0, chunk_size * comm.size()); @@ -83,7 +81,6 @@ void gather_buffer_kernel(std::size_t chunk_size, root_type root, pimpl_type& comm) { using reference = pimpl_type::binary_reference; using const_reference = pimpl_type::const_binary_reference; - using size_type = std::size_t; bool am_i_root = root.has_value() ? comm.me() == *root : true; @@ -128,7 +125,7 @@ void gatherv_kernel(std::size_t chunk_size, root_type root, pimpl_type& comm) { REQUIRE(rv.has_value()); std::vector corr; std::vector sizes_corr; // Sizes (in bytes) - for(std::size_t rank = 0; rank < n_ranks; ++rank) { + for(std::size_t rank = 0; rank < std::size_t(n_ranks); ++rank) { sizes_corr.push_back((chunk_size + rank) * sizeof(T)); for(std::size_t i = 0; i < chunk_size + rank; ++i) corr.push_back(T(i + 1)); @@ -202,7 +199,8 @@ TEST_CASE("CommPPPIMPL") { gatherv_kernel(chunk_size, std::nullopt, comm); } - for(std::size_t root = 0; root < std::min(n_ranks, 5); ++root) { + std::size_t min = std::min(n_ranks, 5); + for(std::size_t root = 0; root < min; ++root) { auto root_str = " root = " + std::to_string(root); SECTION("gather" + root_str + chunk_str) { gather_kernel(chunk_size, root, comm); diff --git a/tests/cxx/unit_tests/parallelzone/runtime/resource_set.cpp b/tests/cxx/unit_tests/parallelzone/runtime/resource_set.cpp index ffa8f615..8d25d0c5 100644 --- a/tests/cxx/unit_tests/parallelzone/runtime/resource_set.cpp +++ b/tests/cxx/unit_tests/parallelzone/runtime/resource_set.cpp @@ -28,10 +28,11 @@ using namespace parallelzone::runtime; * */ TEST_CASE("ResourceSet") { - using pimpl_type = ResourceSet::pimpl_type; - using comm_type = parallelzone::mpi_helpers::CommPP; - using logger_type = ResourceSet::logger_type; - const auto null_rank = MPI_PROC_NULL; + using pimpl_type = ResourceSet::pimpl_type; + using comm_type = parallelzone::mpi_helpers::CommPP; + using logger_type = ResourceSet::logger_type; + using size_type = ResourceSet::size_type; + const size_type null_rank(MPI_PROC_NULL); logger_type log; @@ -59,7 +60,7 @@ TEST_CASE("ResourceSet") { REQUIRE_FALSE(null.is_mine()); REQUIRE_FALSE(null.has_ram()); - REQUIRE(rs.mpi_rank() == comm.me()); + REQUIRE(rs.mpi_rank() == size_type(comm.me())); REQUIRE(rs.is_mine()); REQUIRE(rs.has_ram()); // I presume all computers have RAM... } @@ -112,7 +113,7 @@ TEST_CASE("ResourceSet") { SECTION("mpi_rank") { REQUIRE(defaulted.mpi_rank() == null_rank); REQUIRE(null.mpi_rank() == null_rank); - REQUIRE(rs.mpi_rank() == comm.me()); + REQUIRE(rs.mpi_rank() == size_type(comm.me())); } SECTION("is_mine") { diff --git a/tests/cxx/unit_tests/parallelzone/runtime/runtime_view.cpp b/tests/cxx/unit_tests/parallelzone/runtime/runtime_view.cpp index 53b6304c..af25079f 100644 --- a/tests/cxx/unit_tests/parallelzone/runtime/runtime_view.cpp +++ b/tests/cxx/unit_tests/parallelzone/runtime/runtime_view.cpp @@ -164,7 +164,7 @@ TEST_CASE("RuntimeView") { REQUIRE_THROWS_AS(null.at(0), std::out_of_range); auto n_resource_sets = defaulted.size(); logger_type log; - for(auto i = 0; i < n_resource_sets; ++i) { + for(decltype(n_resource_sets) i = 0; i < n_resource_sets; ++i) { auto corr = runtime::detail_::make_resource_set(i, comm, log); REQUIRE(defaulted.at(i) == corr); REQUIRE(argc_argv.at(i) == corr);