20 #ifndef GALOIS_RUNTIME_EXECUTOR_PARAMETER_H
21 #define GALOIS_RUNTIME_EXECUTOR_PARAMETER_H
31 #include "galois/config.h"
51 "LOOPNAME, STEP, PARALLELISM, WORKLIST_SIZE, NEIGHBORHOOD_SIZE\n");
54 static inline void dump(FILE* out,
const char*
loopname,
size_t step,
55 size_t parallelism,
size_t wlSize,
size_t nhSize) {
56 assert(out &&
"StepStatsBase::dump() file handle is null");
57 fprintf(out,
"%s, %zu, %zu, %zu, %zu\n", loopname, step, parallelism,
111 template <
typename T>
142 template <
typename T>
143 class RAND_WL :
public FIFO_WL<T> {
144 using Base = FIFO_WL<T>;
152 std::random_device r;
153 std::mt19937 rng(r());
154 std::shuffle(lwl.begin(), lwl.end(), rng);
162 template <
typename T>
173 std::reverse(lwl.begin(), lwl.end());
183 template <
typename T, SchedType SCHED>
186 template <
typename T>
191 template <
typename T>
196 template <
typename T>
201 template <
class T,
class FunctionTy,
class ArgsTy>
204 using value_type = T;
206 using WorkListTy =
typename GenericWL::template retype<T>;
209 constexpr
static bool needsStats = !has_trait<no_stats_tag, ArgsTy>();
210 constexpr
static bool needsPush = !has_trait<no_pushes_tag, ArgsTy>();
211 constexpr
static bool needsAborts = !has_trait<no_conflicts_tag, ArgsTy>();
212 constexpr
static bool needsPia = has_trait<per_iter_alloc_tag, ArgsTy>();
213 constexpr
static bool needsBreak = has_trait<parallel_break_tag, ArgsTy>();
221 explicit IterationContext(
const T& v) : item(v), doabort(
false) {}
229 facing.getPushBuffer().clear();
243 IterationContext* newIteration(
const T& item) {
244 IterationContext* it = m_iterAlloc.
allocate(1);
245 assert(it &&
"IterationContext allocation failed");
253 unsigned abortIteration(IterationContext* it) {
254 assert(it &&
"nullptr arg");
255 assert(it->doabort &&
256 "aborting an iteration without setting its doabort flag");
258 unsigned numLocks = it->ctx.cancelIteration();
265 unsigned commitIteration(IterationContext* it) {
266 assert(it &&
"nullptr arg");
269 for (
const auto& item : it->facing.getPushBuffer()) {
270 IterationContext* child = newIteration(item);
271 m_wl.pushNext(child);
275 unsigned numLocks = it->ctx.commitIteration();
288 [&,
this](IterationContext* it) {
293 m_func(it->item, it->facing.data());
295 unsigned nh = commitIteration(it);
305 [&,
this](IterationContext* it) {
312 it->facing.setBreakFlag(&broke);
314 #ifdef GALOIS_USE_LONGJMP_ABORT
317 m_func(it->item, it->facing.data());
320 #elif GALOIS_USE_EXCEPTION_ABORT
322 m_func(it->item, it->facing.data());
336 if (needsBreak && broke) {
346 [&,
this](IterationContext* it) {
352 unsigned nh = commitIteration(it);
359 template <
typename R>
360 void execute(
const R& range) {
363 [&,
this](
const unsigned,
const unsigned) {
364 auto p = range.local_pair();
366 for (
auto i = p.first; i != p.second; ++i) {
375 while (!m_wl.empty()) {
380 runCautiousStep(stats);
383 runSimpleStep(stats);
388 assert(stats.parallelism.reduce() &&
"ERROR: No Progress");
393 if (needsBreak && m_broken.
reduce()) {
404 : m_func(f),
loopname(galois::internal::getLoopName(args)),
408 template <
typename RangeTy>
409 void init(
const RangeTy& range) {
414 template <
typename RangeTy>
424 namespace worklists {
430 template <
bool _concurrent>
433 template <
typename _T>
451 template <
class T,
class FunctionTy,
class ArgsTy>
454 using SuperTy = ParaMeter::ParaMeterExecutor<T, FunctionTy, ArgsTy>;
459 template <
typename R,
typename F,
typename ArgsTuple>
461 const ArgsTuple& argsTuple) {
463 using T =
typename R::values_type;
466 argsTuple, std::make_tuple(wl_tag{}),
467 std::make_tuple(
wl<galois::worklists::ParaMeter<>>()));
469 using Tpl_ty = decltype(tpl);
471 using Exec = runtime::ParaMeter::ParaMeterExecutor<T, F, Tpl_ty>;
472 Exec exec(func, tpl);
void pushNext(const T &item)
Definition: Executor_ParaMeter.h:132
GAccumulator< size_t > parallelism
Definition: Executor_ParaMeter.h:86
const size_t wlSize
Definition: Executor_ParaMeter.h:67
Definition: Executor_ParaMeter.h:122
auto iterateCurr(void)
Definition: Executor_ParaMeter.h:130
void setThreadContext(SimpleRuntimeContext *n)
used by the parallel code to set up conflict detection per thread
Definition: Context.cpp:31
static void dump(FILE *out, const char *loopname, size_t step, size_t parallelism, size_t wlSize, size_t nhSize)
Definition: Executor_ParaMeter.h:54
GAccumulator< size_t > wlSize
Definition: Executor_ParaMeter.h:87
void reset()
Definition: Reduction.h:113
~FIFO_WL(void)
Definition: Executor_ParaMeter.h:123
const size_t step
Definition: Executor_ParaMeter.h:65
void for_each_ParaMeter(const R &range, const F &func, const ArgsTuple &argsTuple)
invoke ParaMeter tool to execute a for_each style loop
Definition: Executor_ParaMeter.h:460
thread_local std::jmp_buf execFrame
Definition: Context.cpp:29
size_t step
Definition: Executor_ParaMeter.h:85
void init(const RangeTy &range)
Definition: Executor_ParaMeter.h:409
void nextStep(void)
Definition: Executor_ParaMeter.h:92
container_type & get()
Definition: PerThreadContainer.h:315
void closeStatsFile(void)
Definition: ParaMeter.cpp:100
Definition: Executor_ParaMeter.h:82
GAccumulator< size_t > parallelism
Definition: Executor_ParaMeter.h:66
void initThread(const RangeTy &) const
Definition: Executor_ParaMeter.h:415
Definition: Executor_ParaMeter.h:62
LocalRange< T > makeLocalRange(T &obj)
Definition: Range.h:75
Definition: Executor_ParaMeter.h:143
static void printHeader(FILE *out)
Definition: Executor_ParaMeter.h:49
auto iterateCurr(void)
Definition: Executor_ParaMeter.h:147
GAccumulator< size_t > nhSize
Definition: Executor_ParaMeter.h:88
Returns the type associated with the given trait in a tuple.
Definition: Traits.h:121
void nextStep(void)
Definition: Executor_ParaMeter.h:134
ParaMeterExecutor(const FunctionTy &f, const ArgsTy &args)
Definition: Executor_ParaMeter.h:403
void clear_all_parallel(void)
Definition: PerThreadContainer.h:423
ForEachExecutor(const FunctionTy &f, const ArgsTy &args)
Definition: Executor_ParaMeter.h:455
void on_each_gen(FunctionTy &&fn, const TupleTy &tpl)
Definition: Executor_OnEach.h:74
ParaMeter::ParaMeterExecutor< T, FunctionTy, ArgsTy > SuperTy
Definition: Executor_ParaMeter.h:454
void construct(U *p, Args &&...args) const
Definition: runtime/Mem.h:766
SchedType
Definition: Executor_ParaMeter.h:181
bool empty_all() const
Definition: PerThreadContainer.h:429
pointer allocate(size_type size)
Definition: runtime/Mem.h:754
OrderedStepStats(size_t _step, size_t _wlsz)
Definition: Executor_ParaMeter.h:69
s_wl< T, Args...> wl(Args &&...args)
Definition: Traits.h:219
Definition: Executor_ParaMeter.h:184
T value_type
Definition: Executor_ParaMeter.h:436
void do_all_gen(const R &range, F &&func, const ArgsTuple &argsTuple)
Definition: Executor_DoAll.h:530
bool empty(void) const
Definition: Executor_ParaMeter.h:139
PTcont * curr
Definition: Executor_ParaMeter.h:117
void dump(FILE *out, const char *loopname)
Definition: Executor_ParaMeter.h:99
ConflictFlag
Definition: libgalois/include/galois/runtime/Context.h:41
void destroy(pointer ptr) const
Definition: runtime/Mem.h:770
Definition: Executor_ParaMeter.h:112
void reset(Ty &var, Ty val)
Definition: AtomicHelpers.h:202
void operator()(void)
Definition: Executor_ParaMeter.h:417
void dump(FILE *out, const char *loopname)
Definition: Executor_ParaMeter.h:77
auto iterateCurr(void)
Definition: Executor_ParaMeter.h:167
Definition: libgalois/include/galois/runtime/Context.h:135
IterationContext(const T &v)
Definition: Executor_ParaMeter.h:128
T & reduce()
Returns the final reduction value.
Definition: Reduction.h:102
void deallocate(pointer ptr, size_type GALOIS_USED_ONLY_IN_DEBUG(len))
Definition: runtime/Mem.h:760
Definition: libgalois/include/galois/runtime/Context.h:42
Wrapper< T, std::deque< T >, true > LIFO
Definition: Simple.h:89
PTcont * next
Definition: Executor_ParaMeter.h:118
Wrapper< T, std::deque< T >, false > FIFO
Definition: Simple.h:83
OrderedStepStats(size_t _step, size_t par, size_t _wlsz)
Definition: Executor_ParaMeter.h:72
Definition: PerThreadContainer.h:454
Definition: Executor_ParaMeter.h:48
logical OR reduction
Definition: Reduction.h:217
FIFO_WL(void)
Definition: Executor_ParaMeter.h:121
void update(T &&rhs)
Updates the thread local value by applying the reduction operator to current and newly provided value...
Definition: Reduction.h:90
Definition: Executor_ParaMeter.h:202
FILE * getStatsFile(void)
Definition: ParaMeter.cpp:96
Definition: Executor_ParaMeter.h:163
Definition: Executor_ParaMeter.h:428
constexpr auto get_default_trait_values(std::index_sequence<> GALOIS_UNUSED(seq), S GALOIS_UNUSED(source), T GALOIS_UNUSED(tags), D GALOIS_UNUSED(defaults))
Returns a tuple that has an element from defaults[i] for every type from tags[i] missing in source...
Definition: Traits.h:148
UnorderedStepStats(void)
Definition: Executor_ParaMeter.h:90