Skip to content

Commit

Permalink
Merge reducer destructor callback into reduce callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxSciurorum authored and neboat committed Jul 13, 2022
1 parent 8bff747 commit d8640ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
15 changes: 8 additions & 7 deletions cilkscale/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ using out_reducer = cilk::ostream_reducer<char>;
static void timer_identity(void *view) {
new (view) cilkscale_timer_t();
}
static void timer_reduce(void *left, void *right) { }
static void timer_destroy(void *view) {
static_cast<cilkscale_timer_t *>(view)->~cilkscale_timer_t();
static void timer_reduce(void *left, void *right) {
static_cast<cilkscale_timer_t *>(right)->~cilkscale_timer_t();
}

using cilkscale_timer_reducer =
cilkscale_timer_t _Hyperobject(timer_identity, timer_reduce, timer_destroy);
cilkscale_timer_t _Hyperobject(timer_identity, timer_reduce);

#endif

Expand All @@ -69,7 +68,10 @@ class BenchmarkImpl_t {
#if SERIAL_TOOL
cilkscale_timer_t timer;
#else
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcilk-ignored"
cilkscale_timer_reducer timer;
#pragma clang diagnostic pop
#endif

std::ostream &outs = std::cout;
Expand Down Expand Up @@ -157,14 +159,13 @@ BenchmarkImpl_t::BenchmarkImpl_t() {

#if !SERIAL_TOOL
__cilkrts_reducer_register
(&timer, sizeof timer, timer_identity, timer_reduce, timer_destroy);
(&timer, sizeof timer, timer_identity, timer_reduce);

outf_red = new out_reducer((outf.is_open() ? outf : outs));
__cilkrts_reducer_register
(outf_red, sizeof *outf_red,
&cilk::ostream_view<char, std::char_traits<char>>::identity,
&cilk::ostream_view<char, std::char_traits<char>>::reduce,
&cilk::ostream_view<char, std::char_traits<char>>::destruct);
&cilk::ostream_view<char, std::char_traits<char>>::reduce);
#endif

start.gettime();
Expand Down
6 changes: 2 additions & 4 deletions cilkscale/cilkscale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ CilkscaleImpl_t::CilkscaleImpl_t() {
shadow_stack = new shadow_stack_reducer();
__cilkrts_reducer_register(shadow_stack, sizeof *shadow_stack,
&shadow_stack_t::identity,
&shadow_stack_t::reduce,
&shadow_stack_t::destruct);
&shadow_stack_t::reduce);
#endif

const char *envstr = getenv("CILKSCALE_OUT");
Expand All @@ -188,8 +187,7 @@ CilkscaleImpl_t::CilkscaleImpl_t() {
__cilkrts_reducer_register
(outf_red, sizeof *outf_red,
&cilk::ostream_view<char, std::char_traits<char>>::identity,
&cilk::ostream_view<char, std::char_traits<char>>::reduce,
&cilk::ostream_view<char, std::char_traits<char>>::destruct);
&cilk::ostream_view<char, std::char_traits<char>>::reduce);
#endif

shadow_stack->push(frame_type::SPAWNER);
Expand Down
7 changes: 2 additions & 5 deletions cilkscale/shadow_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ struct shadow_stack_t {
}
// Add the continuation span from the right stack into the left.
l_bot.contin_bspan += r_bot.contin_bspan;
}

static void destruct(void *view) {
static_cast<shadow_stack_t *>(view)->~shadow_stack_t();
right->~shadow_stack_t();
}

duration_t elapsed_time() {
Expand All @@ -205,8 +203,7 @@ struct shadow_stack_t {
};

typedef shadow_stack_t _Hyperobject(shadow_stack_t::identity,
shadow_stack_t::reduce,
shadow_stack_t::destruct)
shadow_stack_t::reduce)
shadow_stack_reducer;

#endif

0 comments on commit d8640ee

Please sign in to comment.