OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[CPU][OMP] Handle exception outside parallel region (#27303)
Nikolay Shchegolev9036b592d36a
diff --git a/src/plugins/intel_cpu/src/graph.cpp b/src/plugins/intel_cpu/src/graph.cppindex f9bfa9334ea..f3f3a379fc2 100644--- a/src/plugins/intel_cpu/src/graph.cpp+++ b/src/plugins/intel_cpu/src/graph.cpp@@ -1297,23 +1297,40 @@ public:if (origin_nested_levels < 2) {set_max_nested_levels(2);}+ // In OpenMP, an exception that is thrown in a parallel region must be caught and handled in the same region by the same thread.+ // Therefore, need to pass the error message and throw a new exception outside the parallel region.+ const char* what = nullptr;#pragma omp parallel#pragma omp sections{#pragma omp section{- updateDynParams(startCounter, stopIndx);+ try {+ updateDynParams(startCounter, stopIndx);+ } catch (std::exception& e) {+ what = e.what();+ } catch (...) {+ what = "[ CPU ] Could not update dynamic parameters.";+ }}#pragma omp section{- updateShapes(startCounter, stopIndx);+ try {+ updateShapes(startCounter, stopIndx);+ } catch (std::exception& e) {+ what = e.what();+ } catch (...) {+ what = "[ CPU ] Could not update shapes.";+ }}}if (origin_nested_levels != 2) {set_max_nested_levels(origin_nested_levels);}++ OPENVINO_ASSERT(what == nullptr, what);}};#endif