73 #define OV_CC_EXPAND OV_PP_EXPAND
74 #define OV_CC_CAT OV_PP_CAT
75 #define OV_CC_TOSTRING OV_PP_TOSTRING
77 #ifdef SELECTIVE_BUILD_ANALYZER
87 #ifndef SELECTIVE_BUILD_ANALYZER
91 template<
typename C,
typename T>
97 : value(std::forward<C>(val))
101 template<
typename T,
typename C>
106 template<
template<
typename...>
class Fn,
typename Ctx,
typename T,
typename Case>
107 bool match(Ctx && ctx, T && val, Case && cs) {
108 const bool is_matched = val == cs.value;
110 Fn<typename Case::type>()(std::forward<Ctx>(ctx));
114 template<
template<
typename...>
class Fn,
typename Ctx,
typename T,
typename Case,
typename ...Cases>
115 bool match(Ctx && ctx, T && val, Case && cs, Cases&&... cases) {
116 if (match<Fn>(std::forward<Ctx>(ctx), std::forward<T>(val), std::forward<Case>(cs)))
118 return match<Fn>(std::forward<Ctx>(ctx), std::forward<T>(val), std::forward<Cases>(cases)...);
125 #ifdef SELECTIVE_BUILD_ANALYZER
127 #define OV_CC_DOMAINS(Module) \
128 OV_ITT_DOMAIN(OV_PP_CAT(SIMPLE_, Module)); \
129 OV_ITT_DOMAIN(OV_PP_CAT(SWITCH_, Module)); \
130 OV_ITT_DOMAIN(OV_PP_CAT(FACTORY_, Module));
134 template<
typename C,
typename T>
135 struct case_wrapper {
138 const char *name =
nullptr;
140 case_wrapper(C && val,
const char *name)
141 : value(
std::forward<
C>(val))
146 template<
typename T,
typename C>
147 case_wrapper<C, T> make_case_wrapper(C && val,
const char *name) {
148 return case_wrapper<C, T>(std::forward<C>(val), name);
152 template<typename...>
class Fn,
156 bool match(
char const *region, Ctx && ctx, T && val, Case && cs) {
157 const bool is_matched = val == cs.value;
160 openvino::itt::handle(
161 std::string(region) +
"$" + cs.name));
162 Fn<typename Case::type>()(std::forward<Ctx>(ctx));
168 template<typename...>
class Fn,
171 typename Case,
typename ...Cases>
172 bool match(
char const *region, Ctx && ctx, T && val, Case && cs, Cases&&... cases) {
173 if (match<domain, Fn>(region, std::forward<Ctx>(ctx), std::forward<T>(val), std::forward<Case>(cs)))
175 return match<domain, Fn>(region, std::forward<Ctx>(ctx), std::forward<T>(val), std::forward<Cases>(cases)...);
180 #define OV_SCOPE(Module, region) \
181 OV_ITT_SCOPED_TASK(OV_PP_CAT(SIMPLE_, Module), OV_PP_TOSTRING(region));
183 #define OV_SWITCH(Module, fn, ctx, val, ...) \
184 openvino::cc::internal::match<OV_PP_CAT(SWITCH_, Module), fn> \
185 (OV_PP_TOSTRING(fn), ctx, val, __VA_ARGS__);
190 #define OV_CASE(Case, Type) \
191 openvino::cc::internal::make_case_wrapper<Type>(Case, OV_PP_TOSTRING(OV_CASE OV_CC_LBR Case, Type OV_CC_RBR))
193 #define OV_CASE2(Case1, Case2, Type1, Type2) \
194 openvino::cc::internal::make_case_wrapper<std::tuple<Type1, Type2>>( \
195 std::make_tuple(Case1, Case2), \
196 OV_PP_TOSTRING(OV_CASE2 OV_CC_LBR Case1, Case2, Type1, Type2 OV_CC_RBR))
198 #elif defined(SELECTIVE_BUILD)
200 #define OV_CC_DOMAINS(Module)
203 #define OV_CC_SCOPE_ARG_PLACEHOLDER_1 0,
206 #define OV_CC_SCOPE_SECOND_ARG(...) OV_PP_EXPAND(OV_CC_SCOPE_SECOND_ARG_(__VA_ARGS__, 0))
207 #define OV_CC_SCOPE_SECOND_ARG_(...) OV_PP_EXPAND(OV_CC_SCOPE_SECOND_ARG_GET(__VA_ARGS__))
208 #define OV_CC_SCOPE_SECOND_ARG_GET(ignored, val, ...) val
211 #define OV_CC_SCOPE_IS_ENABLED(x) OV_CC_SCOPE_IS_ENABLED1(x)
214 #define OV_CC_SCOPE_IS_ENABLED1(val) OV_CC_SCOPE_IS_ENABLED2(OV_PP_CAT(OV_CC_SCOPE_ARG_PLACEHOLDER_, val))
217 #define OV_CC_SCOPE_IS_ENABLED2(arg1_or_junk) OV_CC_SCOPE_SECOND_ARG(arg1_or_junk 1, 0)
219 #define OV_SCOPE(Module, region) \
220 if (OV_CC_SCOPE_IS_ENABLED(OV_PP_CAT3(Module, _, region)))
223 #define OV_CC_SWITCH_0(Module, fn, ctx, val)
226 #define OV_CC_SWITCH_1(Module, fn, ctx, val) openvino::cc::internal::match<fn>(ctx, val, OV_PP_CAT4(Module, _, fn, _cases));
228 #define OV_SWITCH(Module, fn, ctx, val, ...) \
229 OV_PP_EXPAND(OV_PP_CAT(OV_CC_SWITCH_, OV_CC_SCOPE_IS_ENABLED(OV_PP_CAT3(Module, _, fn)))(Module, fn, ctx, val))
231 #define OV_CASE(Case, Type) openvino::cc::internal::make_case_wrapper<Type>(Case)
233 #define OV_CASE2(Case1, Case2, Type1, Type2) openvino::cc::internal::make_case_wrapper<std::tuple<Type1, Type2>>(std::make_tuple(Case1, Case2))
237 #define OV_CC_DOMAINS(Module)
239 #define OV_SCOPE(Module, region)
241 #define OV_SWITCH(Module, fn, ctx, val, ...) \
242 openvino::cc::internal::match<fn>(ctx, val, __VA_ARGS__);
244 #define OV_CASE(Case, Type) openvino::cc::internal::make_case_wrapper<Type>(Case)
246 #define OV_CASE2(Case1, Case2, Type1, Type2) openvino::cc::internal::make_case_wrapper<std::tuple<Type1, Type2>>(std::make_tuple(Case1, Case2))
Defines API to trace using Intel ITT.
Set of macro used by openvino.
Definition: selective_build.h:92
Used to annotate section of code which would be named at runtime.
Definition: itt.hpp:121