File size: 22,672 Bytes
d1be154 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | // reference:
// - gomp: https://github.com/gcc-mirror/gcc/blob/master/libgomp/iter.c
// - komp: https://github.com/llvm-mirror/openmp/blob/master/runtime/src/kmp_dispatch.cpp
#pragma once
/**
@file partitioner.hpp
@brief partitioner include file
*/
namespace tf {
/**
@enum PartitionerType
@brief enumeration of all partitioner types
*/
enum class PartitionerType : int {
/** @brief static partitioner type */
STATIC,
/** @brief dynamic partitioner type */
DYNAMIC
};
//template <typename C>
//class PartitionInvoker : public PartitionerBase {
//
// protected
//
// C _closure;
//
// template <typename... ArgsT>
// auto operator()(ArgsT&&... args) {
// return std::invoke(closure, std::forward<ArgsT>(args)...);
// }
//
// template <typename... ArgsT>
// auto operator()(ArgsT&&... args) const {
// return std::invoke(closure, std::forward<ArgsT>(args)...);
// }
//
//};
/**
@class DefaultClosureWrapper
@brief class to create a default closure wrapper
*/
class DefaultClosureWrapper {};
/**
@private
*/
struct IsPartitioner {
};
// ----------------------------------------------------------------------------
// Partitioner Base
// ----------------------------------------------------------------------------
/**
@class PartitionerBase
@brief class to derive a partitioner for scheduling parallel algorithms
@tparam C closure wrapper type
The class provides base methods to derive a partitioner that can be used
to schedule parallel iterations (e.g., tf::Taskflow::for_each).
An partitioner defines the scheduling method for running parallel algorithms,
such tf::Taskflow::for_each, tf::Taskflow::reduce, and so on.
By default, we provide the following partitioners:
+ tf::GuidedPartitioner to enable guided scheduling algorithm of adaptive chunk size
+ tf::DynamicPartitioner to enable dynamic scheduling algorithm of equal chunk size
+ tf::StaticPartitioner to enable static scheduling algorithm of static chunk size
+ tf::RandomPartitioner to enable random scheduling algorithm of random chunk size
Depending on applications, partitioning algorithms can impact the performance
a lot.
For example, if a parallel-iteration workload contains a regular work unit per
iteration, tf::StaticPartitioner can deliver the best performance.
On the other hand, if the work unit per iteration is irregular and unbalanced,
tf::GuidedPartitioner or tf::DynamicPartitioner can outperform tf::StaticPartitioner.
In most situations, tf::GuidedPartitioner can deliver decent performance and
is thus used as our default partitioner.
@attention
Giving the partition size of 0 lets the %Taskflow runtime automatically determines
the partition size for the given partitioner.
In addition to partition size, the application can specify a closure wrapper
for a partitioner.
A closure wrapper allows the application to wrapper a partitioned task
(i.e., closure) with a custom function object that performs additional tasks.
For example:
@code{.cpp}
std::atomic<int> count = 0;
tf::Taskflow taskflow;
taskflow.for_each_index(0, 100, 1,
[](){
printf("%d\n", i);
},
tf::StaticPartitioner(0, [](auto&& closure){
// do something before invoking the partitioned task
// ...
// invoke the partitioned task
closure();
// do something else after invoking the partitioned task
// ...
}
);
executor.run(taskflow).wait();
@endcode
@attention
The default closure wrapper (tf::DefaultClosureWrapper) does nothing but invoke
the partitioned task (closure).
*/
template <typename C = DefaultClosureWrapper>
class PartitionerBase : public IsPartitioner {
public:
/**
@brief indicating if the given closure wrapper is a default wrapper (i.e., empty)
*/
constexpr static bool is_default_wrapper_v = std::is_same_v<C, DefaultClosureWrapper>;
/**
@brief the closure type
*/
using closure_wrapper_type = C;
/**
@brief default constructor
*/
PartitionerBase() = default;
/**
@brief construct a partitioner with the given chunk size
*/
explicit PartitionerBase(size_t chunk_size) : _chunk_size {chunk_size} {}
/**
@brief construct a partitioner with the given chunk size and closure wrapper
*/
PartitionerBase(size_t chunk_size, C&& closure_wrapper) :
_chunk_size {chunk_size},
_closure_wrapper {std::forward<C>(closure_wrapper)} {
}
/**
@brief query the chunk size of this partitioner
*/
size_t chunk_size() const { return _chunk_size; }
/**
@brief update the chunk size of this partitioner
*/
void chunk_size(size_t cz) { _chunk_size = cz; }
/**
@brief acquire an immutable access to the closure wrapper object
*/
const C& closure_wrapper() const { return _closure_wrapper; }
/**
@brief acquire a mutable access to the closure wrapper object
*/
C& closure_wrapper() { return _closure_wrapper; }
/**
@brief modify the closure wrapper object
*/
template <typename F>
void closure_wrapper(F&& fn) { _closure_wrapper = std::forward<F>(fn); }
/**
@brief wraps the given callable with the associated closure wrapper
*/
template <typename F>
TF_FORCE_INLINE decltype(auto) operator () (F&& callable) {
if constexpr(is_default_wrapper_v) {
return std::forward<F>(callable);
}
else {
// closure wrapper is stateful - capture it by reference
return [this, c=std::forward<F>(callable)]() mutable { _closure_wrapper(c); };
}
}
protected:
/**
@brief chunk size
*/
size_t _chunk_size{0};
/**
@brief closure wrapper
*/
C _closure_wrapper;
};
// ----------------------------------------------------------------------------
// Guided Partitioner
// ----------------------------------------------------------------------------
/**
@class GuidedPartitioner
@tparam C closure wrapper type (default tf::DefaultClosureWrapper)
@brief class to create a guided partitioner for scheduling parallel algorithms
The size of a partition is proportional to the number of unassigned iterations
divided by the number of workers,
and the size will gradually decrease to the given chunk size.
The last partition may be smaller than the chunk size.
In addition to partition size, the application can specify a closure wrapper
for a guided partitioner.
A closure wrapper allows the application to wrapper a partitioned task
(i.e., closure) with a custom function object that performs additional tasks.
For example:
@code{.cpp}
std::atomic<int> count = 0;
tf::Taskflow taskflow;
taskflow.for_each_index(0, 100, 1,
[](){
printf("%d\n", i);
},
tf::GuidedPartitioner(0, [](auto&& closure){
// do something before invoking the partitioned task
// ...
// invoke the partitioned task
closure();
// do something else after invoking the partitioned task
// ...
}
);
executor.run(taskflow).wait();
@endcode
*/
template <typename C = DefaultClosureWrapper>
class GuidedPartitioner : public PartitionerBase<C> {
public:
/**
@brief queries the partition type (dynamic)
*/
static constexpr PartitionerType type() { return PartitionerType::DYNAMIC; }
/**
@brief default constructor
*/
GuidedPartitioner() = default;
/**
@brief construct a guided partitioner with the given chunk size
*/
explicit GuidedPartitioner(size_t sz) : PartitionerBase<C> (sz) {}
/**
@brief construct a guided partitioner with the given chunk size and the closure
*/
explicit GuidedPartitioner(size_t sz, C&& closure) :
PartitionerBase<C>(sz, std::forward<C>(closure)) {
}
// --------------------------------------------------------------------------
// scheduling methods
// --------------------------------------------------------------------------
/**
@private
*/
template <typename F,
std::enable_if_t<std::is_invocable_r_v<void, F, size_t, size_t>, void>* = nullptr
>
void loop(
size_t N, size_t W, std::atomic<size_t>& next, F&& func
) const {
size_t chunk_size = (this->_chunk_size == 0) ? size_t{1} : this->_chunk_size;
size_t p1 = 2 * W * (chunk_size + 1);
float p2 = 0.5f / static_cast<float>(W);
size_t curr_b = next.load(std::memory_order_relaxed);
while(curr_b < N) {
size_t r = N - curr_b;
// fine-grained
if(r < p1) {
while(1) {
curr_b = next.fetch_add(chunk_size, std::memory_order_relaxed);
if(curr_b >= N) {
return;
}
func(curr_b, (std::min)(curr_b + chunk_size, N));
}
break;
}
// coarse-grained
else {
size_t q = static_cast<size_t>(p2 * r);
if(q < chunk_size) {
q = chunk_size;
}
//size_t curr_e = (q <= r) ? curr_b + q : N;
size_t curr_e = (std::min)(curr_b + q, N);
if(next.compare_exchange_strong(curr_b, curr_e, std::memory_order_relaxed,
std::memory_order_relaxed)) {
func(curr_b, curr_e);
curr_b = next.load(std::memory_order_relaxed);
}
}
}
}
/**
@private
*/
template <typename F,
std::enable_if_t<std::is_invocable_r_v<bool, F, size_t, size_t>, void>* = nullptr
>
void loop_until(
size_t N, size_t W, std::atomic<size_t>& next, F&& func
) const {
size_t chunk_size = (this->_chunk_size == 0) ? size_t{1} : this->_chunk_size;
size_t p1 = 2 * W * (chunk_size + 1);
float p2 = 0.5f / static_cast<float>(W);
size_t curr_b = next.load(std::memory_order_relaxed);
while(curr_b < N) {
size_t r = N - curr_b;
// fine-grained
if(r < p1) {
while(1) {
curr_b = next.fetch_add(chunk_size, std::memory_order_relaxed);
if(curr_b >= N) {
return;
}
if(func(curr_b, (std::min)(curr_b + chunk_size, N))) {
return;
}
}
break;
}
// coarse-grained
else {
size_t q = static_cast<size_t>(p2 * r);
if(q < chunk_size) {
q = chunk_size;
}
//size_t curr_e = (q <= r) ? curr_b + q : N;
size_t curr_e = (std::min)(curr_b + q, N);
if(next.compare_exchange_strong(curr_b, curr_e, std::memory_order_relaxed,
std::memory_order_relaxed)) {
if(func(curr_b, curr_e)) {
return;
}
curr_b = next.load(std::memory_order_relaxed);
}
}
}
}
};
// ----------------------------------------------------------------------------
// Dynamic Partitioner
// ----------------------------------------------------------------------------
/**
@class DynamicPartitioner
@brief class to create a dynamic partitioner for scheduling parallel algorithms
@tparam C closure wrapper type (default tf::DefaultClosureWrapper)
The partitioner splits iterations into many partitions each of size equal to
the given chunk size.
Different partitions are distributed dynamically to workers
without any specific order.
In addition to partition size, the application can specify a closure wrapper
for a dynamic partitioner.
A closure wrapper allows the application to wrapper a partitioned task
(i.e., closure) with a custom function object that performs additional tasks.
For example:
@code{.cpp}
std::atomic<int> count = 0;
tf::Taskflow taskflow;
taskflow.for_each_index(0, 100, 1,
[](){
printf("%d\n", i);
},
tf::DynamicPartitioner(0, [](auto&& closure){
// do something before invoking the partitioned task
// ...
// invoke the partitioned task
closure();
// do something else after invoking the partitioned task
// ...
}
);
executor.run(taskflow).wait();
@endcode
*/
template <typename C = DefaultClosureWrapper>
class DynamicPartitioner : public PartitionerBase<C> {
public:
/**
@brief queries the partition type (dynamic)
*/
static constexpr PartitionerType type() { return PartitionerType::DYNAMIC; }
/**
@brief default constructor
*/
DynamicPartitioner() = default;
/**
@brief construct a dynamic partitioner with the given chunk size
*/
explicit DynamicPartitioner(size_t sz) : PartitionerBase<C>(sz) {}
/**
@brief construct a dynamic partitioner with the given chunk size and the closure
*/
explicit DynamicPartitioner(size_t sz, C&& closure) :
PartitionerBase<C>(sz, std::forward<C>(closure)) {
}
// --------------------------------------------------------------------------
// scheduling methods
// --------------------------------------------------------------------------
/**
@private
*/
template <typename F,
std::enable_if_t<std::is_invocable_r_v<void, F, size_t, size_t>, void>* = nullptr
>
void loop(
size_t N, size_t, std::atomic<size_t>& next, F&& func
) const {
size_t chunk_size = (this->_chunk_size == 0) ? size_t{1} : this->_chunk_size;
size_t curr_b = next.fetch_add(chunk_size, std::memory_order_relaxed);
while(curr_b < N) {
func(curr_b, (std::min)(curr_b + chunk_size, N));
curr_b = next.fetch_add(chunk_size, std::memory_order_relaxed);
}
}
/**
@private
*/
template <typename F,
std::enable_if_t<std::is_invocable_r_v<bool, F, size_t, size_t>, void>* = nullptr
>
void loop_until(
size_t N, size_t, std::atomic<size_t>& next, F&& func
) const {
size_t chunk_size = (this->_chunk_size == 0) ? size_t{1} : this->_chunk_size;
size_t curr_b = next.fetch_add(chunk_size, std::memory_order_relaxed);
while(curr_b < N) {
if(func(curr_b, (std::min)(curr_b + chunk_size, N))) {
return;
}
curr_b = next.fetch_add(chunk_size, std::memory_order_relaxed);
}
}
};
// ----------------------------------------------------------------------------
// Static Partitioner
// ----------------------------------------------------------------------------
/**
@class StaticPartitioner
@brief class to construct a static partitioner for scheduling parallel algorithms
@tparam C closure wrapper type (default tf::DefaultClosureWrapper)
The partitioner divides iterations into chunks and distributes chunks
to workers in order.
If the chunk size is not specified (default @c 0), the partitioner resorts to a chunk size
that equally distributes iterations into workers.
@code{.cpp}
std::vector<int> data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
taskflow.for_each(
data.begin(), data.end(), [](int i){}, StaticPartitioner(0)
);
executor.run(taskflow).run();
@endcode
In addition to partition size, the application can specify a closure wrapper
for a static partitioner.
A closure wrapper allows the application to wrapper a partitioned task
(i.e., closure) with a custom function object that performs additional tasks.
For example:
@code{.cpp}
std::atomic<int> count = 0;
tf::Taskflow taskflow;
taskflow.for_each_index(0, 100, 1,
[](){
printf("%d\n", i);
},
tf::StaticPartitioner(0, [](auto&& closure){
// do something before invoking the partitioned task
// ...
// invoke the partitioned task
closure();
// do something else after invoking the partitioned task
// ...
}
);
executor.run(taskflow).wait();
@endcode
*/
template <typename C = DefaultClosureWrapper>
class StaticPartitioner : public PartitionerBase<C> {
public:
/**
@brief queries the partition type (static)
*/
static constexpr PartitionerType type() { return PartitionerType::STATIC; }
/**
@brief default constructor
*/
StaticPartitioner() = default;
/**
@brief construct a static partitioner with the given chunk size
*/
explicit StaticPartitioner(size_t sz) : PartitionerBase<C>(sz) {}
/**
@brief construct a static partitioner with the given chunk size and the closure
*/
explicit StaticPartitioner(size_t sz, C&& closure) :
PartitionerBase<C>(sz, std::forward<C>(closure)) {
}
/**
@brief queries the adjusted chunk size
Returns the given chunk size if it is not zero, or returns
<tt>N/W + (w < N%W)</tt>, where @c N is the number of iterations,
@c W is the number of workers, and @c w is the worker ID.
*/
size_t adjusted_chunk_size(size_t N, size_t W, size_t w) const {
return this->_chunk_size ? this->_chunk_size : N/W + (w < N%W);
}
// --------------------------------------------------------------------------
// scheduling methods
// --------------------------------------------------------------------------
/**
@private
*/
template <typename F,
std::enable_if_t<std::is_invocable_r_v<void, F, size_t, size_t>, void>* = nullptr
>
void loop(
size_t N, size_t W, size_t curr_b, size_t chunk_size, F&& func
) {
size_t stride = W * chunk_size;
while(curr_b < N) {
size_t curr_e = (std::min)(curr_b + chunk_size, N);
func(curr_b, curr_e);
curr_b += stride;
}
}
/**
@private
*/
template <typename F,
std::enable_if_t<std::is_invocable_r_v<bool, F, size_t, size_t>, void>* = nullptr
>
void loop_until(
size_t N, size_t W, size_t curr_b, size_t chunk_size, F&& func
) {
size_t stride = W * chunk_size;
while(curr_b < N) {
size_t curr_e = (std::min)(curr_b + chunk_size, N);
if(func(curr_b, curr_e)) {
return;
}
curr_b += stride;
}
}
};
// ----------------------------------------------------------------------------
// RandomPartitioner
// ----------------------------------------------------------------------------
/**
@class RandomPartitioner
@brief class to construct a random partitioner for scheduling parallel algorithms
@tparam C closure wrapper type (default tf::DefaultClosureWrapper)
Similar to tf::DynamicPartitioner,
the partitioner splits iterations into many partitions but each with a random
chunk size in the range, <tt>c = [alpha * N * W, beta * N * W]</tt>.
By default, @c alpha is <tt>0.01</tt> and @c beta is <tt>0.5</tt>, respectively.
In addition to partition size, the application can specify a closure wrapper
for a random partitioner.
A closure wrapper allows the application to wrapper a partitioned task
(i.e., closure) with a custom function object that performs additional tasks.
For example:
@code{.cpp}
std::atomic<int> count = 0;
tf::Taskflow taskflow;
taskflow.for_each_index(0, 100, 1,
[](){
printf("%d\n", i);
},
tf::RandomPartitioner(0, [](auto&& closure){
// do something before invoking the partitioned task
// ...
// invoke the partitioned task
closure();
// do something else after invoking the partitioned task
// ...
}
);
executor.run(taskflow).wait();
@endcode
*/
template <typename C = DefaultClosureWrapper>
class RandomPartitioner : public PartitionerBase<C> {
public:
/**
@brief queries the partition type (dynamic)
*/
static constexpr PartitionerType type() { return PartitionerType::DYNAMIC; }
/**
@brief default constructor
*/
RandomPartitioner() = default;
/**
@brief construct a dynamic partitioner with the given chunk size
*/
explicit RandomPartitioner(size_t sz) : PartitionerBase<C>(sz) {}
/**
@brief construct a random partitioner with the given chunk size and the closure
*/
explicit RandomPartitioner(size_t sz, C&& closure) :
PartitionerBase<C>(sz, std::forward<C>(closure)) {
}
/**
@brief constructs a random partitioner with the given parameters
*/
RandomPartitioner(float alpha, float beta) : _alpha{alpha}, _beta{beta} {}
/**
@brief constructs a random partitioner with the given parameters and the closure
*/
RandomPartitioner(float alpha, float beta, C&& closure) :
_alpha {alpha}, _beta {beta},
PartitionerBase<C>(0, std::forward<C>(closure)) {
}
/**
@brief queries the @c alpha value
*/
float alpha() const { return _alpha; }
/**
@brief queries the @c beta value
*/
float beta() const { return _beta; }
/**
@brief queries the range of chunk size
@param N number of iterations
@param W number of workers
*/
std::pair<size_t, size_t> chunk_size_range(size_t N, size_t W) const {
size_t b1 = static_cast<size_t>(_alpha * N * W);
size_t b2 = static_cast<size_t>(_beta * N * W);
if(b1 > b2) {
std::swap(b1, b2);
}
b1 = (std::max)(b1, size_t{1});
b2 = (std::max)(b2, b1 + 1);
return {b1, b2};
}
// --------------------------------------------------------------------------
// scheduling methods
// --------------------------------------------------------------------------
/**
@private
*/
template <typename F,
std::enable_if_t<std::is_invocable_r_v<void, F, size_t, size_t>, void>* = nullptr
>
void loop(
size_t N, size_t W, std::atomic<size_t>& next, F&& func
) const {
auto [b1, b2] = chunk_size_range(N, W);
std::default_random_engine engine {std::random_device{}()};
std::uniform_int_distribution<size_t> dist(b1, b2);
size_t chunk_size = dist(engine);
size_t curr_b = next.fetch_add(chunk_size, std::memory_order_relaxed);
while(curr_b < N) {
func(curr_b, (std::min)(curr_b + chunk_size, N));
chunk_size = dist(engine);
curr_b = next.fetch_add(chunk_size, std::memory_order_relaxed);
}
}
/**
@private
*/
template <typename F,
std::enable_if_t<std::is_invocable_r_v<bool, F, size_t, size_t>, void>* = nullptr
>
void loop_until(
size_t N, size_t W, std::atomic<size_t>& next, F&& func
) const {
auto [b1, b2] = chunk_size_range(N, W);
std::default_random_engine engine {std::random_device{}()};
std::uniform_int_distribution<size_t> dist(b1, b2);
size_t chunk_size = dist(engine);
size_t curr_b = next.fetch_add(chunk_size, std::memory_order_relaxed);
while(curr_b < N) {
if(func(curr_b, (std::min)(curr_b + chunk_size, N))){
return;
}
chunk_size = dist(engine);
curr_b = next.fetch_add(chunk_size, std::memory_order_relaxed);
}
}
private:
float _alpha {0.01f};
float _beta {0.50f};
};
/**
@brief default partitioner set to tf::GuidedPartitioner
Guided partitioning algorithm can achieve stable and decent performance
for most parallel algorithms.
*/
using DefaultPartitioner = GuidedPartitioner<>;
/**
@brief determines if a type is a partitioner
A partitioner is a derived type from tf::PartitionerBase.
*/
template <typename P>
inline constexpr bool is_partitioner_v = std::is_base_of<IsPartitioner, P>::value;
} // end of namespace tf -----------------------------------------------------
|