diff --git a/test/source/kitgenbench.cpp b/test/source/kitgenbench.cpp index a99b322..2239782 100644 --- a/test/source/kitgenbench.cpp +++ b/test/source/kitgenbench.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include "nlohmann/json.hpp" @@ -44,9 +45,9 @@ namespace setups { typename TLogger = kitgenbench::setup::NoLogger, typename TChecker = kitgenbench::setup::NoChecker> struct InstructionDetails { - Aggregate recipes{}; - Aggregate loggers{}; - Aggregate checkers{}; + Aggregate recipes{}; + Aggregate loggers{}; + Aggregate checkers{}; auto sendTo([[maybe_unused]] auto const& device, [[maybe_unused]] auto& queue) { // This is not exactly how it's supposed to be used (or at least it's not necessary). You @@ -122,14 +123,15 @@ TEST_CASE("Single size malloc") { namespace setups::mallocFreeManySize { struct MallocFreeRecipe { - std::vector sizes{}; + const std::array sizes{16U, 256U, 1024U, 16U, 16U, 256U, 16U, 1024U, 1024U}; std::uint32_t currentIndex{0U}; void* currentPointer{nullptr}; ALPAKA_FN_ACC auto next([[maybe_unused]] const auto& acc) { - if (currentIndex >= sizes.size()) + if (currentIndex >= sizes.size()) { return std::make_tuple(kitgenbench::Actions::STOP, std::span{static_cast(nullptr), 0U}); + } if (currentPointer == nullptr) { currentPointer = malloc(sizes[currentIndex]); @@ -150,33 +152,19 @@ namespace setups::mallocFreeManySize { nlohmann::json generateReport() { return {}; } }; - std::vector ALLOCATION_SIZES - = {16U, 256U, 1024U, 16U, 16U, 256U, 16U, 1024U, 1024U}; auto makeInstructionDetails() { return InstructionDetails{}; } - namespace detail { - template T unique(T const& values) { - // It's a pity but the following are algorithms and not "adaptors", so the pipe operator - // doesn't work. - T tmp = values; - std::ranges::sort(tmp); - const auto [new_end, old_end] = std::ranges::unique(tmp); - return {std::begin(tmp), new_end}; - } - } // namespace detail - auto composeSetup() { return composeSetup("mallocFreeManySize", makeExecutionDetails(), makeInstructionDetails(), {{"what it does", "This setup runs through a given vector of allocation sizes, allocating " "and deallocating each size one after another."}, - {"number of allocations", ALLOCATION_SIZES.size()}, - {"available allocation sizes [bytes]", detail::unique(ALLOCATION_SIZES)}}); + {"number of allocations", MallocFreeRecipe{}.sizes.size()}}); } } // namespace setups::mallocFreeManySize TEST_CASE("Malloc free many size") { auto setup = setups::mallocFreeManySize::composeSetup(); - auto benchmarkReports = runBenchmarks(setup); + auto benchmarkReports = kitgenbench::runBenchmarks(setup); }