Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Foundation/Execution/Common.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Execution_Common_h_
5#define _Stroika_Foundation_Execution_Common_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <execution>
10
12
14
15 /**
16 * \brief equivalent which of 4 types being used std::execution::sequenced_policy, parallel_policy, etc...
17 *
18 * Much simpler to just have a single enum rather than these 4 classes. STL choice based on (probably more historical)
19 * C++ limitations with overloading (no constexpr) - not much point in that anymore, I don't think.
20 */
21 enum class SequencePolicy {
22 /**
23 * \brief default case - not parallelized
24 *
25 * Equivalent to std::seq, std::execution::sequenced_policy
26 *
27 * ..."a parallel algorithm's execution may not be parallelized.
28 * The invocations of element access functions in parallel algorithms invoked with this policy
29 * (usually specified as std::execution::seq) are indeterminately sequenced in the calling thread."
30 */
31 eSeq,
32
33 /**
34 * \brief must synchronize shared data, can use mutex (or atomics), cuz each parallel execution in real thread
35 *
36 * Equivalent to std::par, std::execution::parallel_policy
37 *
38 * ..."parallel algorithm's execution may be parallelized. The invocations of element access
39 * functions in parallel algorithms invoked with this policy (usually specified as std::execution::par)
40 * are permitted to execute in either the invoking thread or in a thread implicitly created by the
41 * library to support parallel algorithm execution. Any such invocations executing in the same
42 * thread are indeterminately sequenced with respect to each other.
43 */
44 ePar,
45
46 /**
47 * \brief Unclear how this differs from eUnseq, but no locks allowed
48 *
49 * Equivalent to std::par_unseq , std::execution::parallel_unsequenced_policy
50 *
51 * ..."a parallel algorithm's execution may be parallelized, vectorized,
52 * or migrated across threads (such as by a parent-stealing scheduler). The invocations of
53 * element access functions in parallel algorithms invoked with this policy are permitted
54 * to execute in an unordered fashion in unspecified threads, and unsequenced with respect
55 * to one another within each thread..
56 */
58
59 /**
60 * \brief SIMD, no locks allowed
61 *
62 * Equivalent to std::unseq, std::execution::unsequenced_policy
63 *
64 * ..."a parallel algorithm's execution may be parallelized, vectorized,
65 * or migrated across threads (such as by a parent-stealing scheduler). The invocations of
66 * element access functions in parallel algorithms invoked with this policy are permitted
67 * to execute in an unordered fashion in unspecified threads, and unsequenced with respect
68 * to one another within each thread..
69 */
70 eUnseq,
71
73
74 // consider losing eDEFAULT, cuz probably will lead to more confusion than prosperity...
75 // or define to pull value from some TLS variable??? that maybe BEST... SO LEAVE FOR NOW...
76 eDEFAULT = eSeq,
77 };
78
79}
80
81/*
82 ********************************************************************************
83 ***************************** Implementation Details ***************************
84 ********************************************************************************
85 */
86
87#endif /*_Stroika_Foundation_Execution_Common_h_*/
#define Stroika_Define_Enum_Bounds(FIRST_ITEM, LAST_ITEM)
SequencePolicy
equivalent which of 4 types being used std::execution::sequenced_policy, parallel_policy,...
@ eParUnseq
Unclear how this differs from eUnseq, but no locks allowed.
@ ePar
must synchronize shared data, can use mutex (or atomics), cuz each parallel execution in real thread
@ eSeq
default case - not parallelized