MCPcopy Create free account
hub / github.com/dmlc/xgboost / Sort

Function Sort

src/common/algorithm.h:58–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56
57template <typename Iter, typename Comp>
58void Sort(Context const *ctx, Iter begin, Iter end, Comp comp) {
59 if (ctx->Threads() > 1) {
60#if defined(GCC_HAS_PARALLEL)
61 __gnu_parallel::sort(begin, end, comp, __gnu_parallel::default_parallel_tag(ctx->Threads()));
62#elif defined(MSVC_HAS_PARALLEL)
63 auto n = std::distance(begin, end);
64 // use chunk size as hint to number of threads. No local policy/scheduler input with the
65 // concurrency module.
66 std::size_t chunk_size = n / ctx->Threads();
67 // 2048 is the default of msvc ppl as of v2022.
68 chunk_size = std::max(chunk_size, static_cast<std::size_t>(2048));
69 concurrency::parallel_sort(begin, end, comp, chunk_size);
70#else
71 std::sort(begin, end, comp);
72#endif // GLIBC VERSION
73 } else {
74 std::sort(begin, end, comp);
75 }
76}
77
78template <typename Idx, typename Iter, typename V = typename std::iterator_traits<Iter>::value_type,
79 typename Comp = std::less<V>>

Callers 3

EvalMethod · 0.85
CalcRegAbsGradFunction · 0.85
TESTFunction · 0.85

Calls 1

ThreadsMethod · 0.80

Tested by 1

TESTFunction · 0.68