Skip to content
Snippets Groups Projects
Commit 4d49c03e authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Add skynet benchmark

parent 95d8ded4
No related branches found
No related tags found
No related merge requests found
Pipeline #95204 passed
......@@ -49,6 +49,14 @@ This is the [OpenMP implementation of LLVM's Clang](https://openmp.llvm.org/).
Inspired by prior work of Oliver et al. [oliver2006uts].
For more information, look at the [benchmark's README](./benchmarks/uts/README.md).
### skynet
Inspired by Alexander Temerev's [skynet](https://github.com/atemerev/skynet) micro benchmark.
Skynet creates a large number of fibers by spawning 10 fibers which itself spawn 10 more fibers until the desired number of fibers are created *on the final level*.
Then, each fiber returns its ordinal number, starting with 1, which are then summed on the previous level, which sends its sum back upstream, until the root is reached.
Therefore, calculating the "kleiner Gauß", that is, the sum of the first n subsequent natural numbers.
# Publications
[schmaus2021nowa]
......
......@@ -4,4 +4,5 @@ subdir('integrate')
subdir('lu')
subdir('matmul')
subdir('nqueens')
subdir('skynet')
subdir('uts')
benchmarks += {
'name': 'skynet',
'source_files': ['skynet.cc'],
'is_smoke_test': true,
}
#include <array>
#include <cassert>
#include <iostream>
#include <numeric>
#include "mazstab-backend.hpp"
#include "mazstab.hpp"
namespace mzs = mazstab;
static const uint64_t DIVISOR = 10;
static uint64_t size;
static uint64_t result;
static auto kleiner_gauß(uint64_t num) -> uint64_t {
uint64_t num_squared = num * num;
return (num_squared + num) / 2;
}
mzs_sf static void recurse_sum(uint64_t* res, uint64_t num, uint64_t size) {
if (size == 1) {
*res = num;
return;
}
mzs_sf_state sf_state;
mzs_init(&sf_state);
std::array<uint64_t, DIVISOR> myRes;
uint64_t newSize = size / DIVISOR;
for (uint64_t i = 0; i < DIVISOR; ++i) {
uint64_t newNum = num + (i * newSize);
uint64_t* newRes = &myRes[i];
mzs_spawn(&sf_state, recurse_sum, (newRes, newNum, newSize));
}
mzs_sync(&sf_state);
*res = std::reduce(myRes.begin(), myRes.end());
}
auto mzs_benchmark_verify() -> mzs::VerificationResult {
uint64_t expected = kleiner_gauß(size);
if (expected != result) {
std::cerr << "FAILED recurse_sum(" << size << ")=" << result << " but expected " << expected << std::endl;
return mzs::VerificationResult::failed;
}
return mzs::VerificationResult::successful;
}
void mzs_benchmark_run() {
assert(size > 0);
recurse_sum(&result, 1, size);
}
void mzs_benchmark_init(const mzs::ProblemSize &problem_size) {
switch (problem_size) {
case mzs::ProblemSize::xs:
size = 100;
break;
case mzs::ProblemSize::m:
case mzs::ProblemSize::nowa:
size = 1000000;
break;
}
assert(size % DIVISOR == 0);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment