From f0d02e4e5a49c48e4557de01895f627df1c4c9b7 Mon Sep 17 00:00:00 2001 From: Hiroshi Horii Date: Thu, 23 Mar 2023 10:20:51 +0900 Subject: [PATCH] use `omp_set_max_active_levels` instead of `omp_set_nested` (#1752) omp_set_nested was deprecated since OpenMP 3.0 and this commit replaces it with omp_set_max_active_levels. * use omp_set_max_active_levels instead of omp_set_nested * use omp_set_nested in WIN * Update releasenotes/notes/use_omp_set_max_active_levels-7e6c1d301c4434a6.yaml * use _OPENMP to select omp_set_max_active_levels or omp_set_nested --------- Co-authored-by: Jake Lishman --- .../notes/use_omp_set_max_active_levels-7e6c1d301c4434a6.yaml | 4 ++++ src/controllers/aer_controller.hpp | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 releasenotes/notes/use_omp_set_max_active_levels-7e6c1d301c4434a6.yaml diff --git a/releasenotes/notes/use_omp_set_max_active_levels-7e6c1d301c4434a6.yaml b/releasenotes/notes/use_omp_set_max_active_levels-7e6c1d301c4434a6.yaml new file mode 100644 index 0000000000..faa4c650b1 --- /dev/null +++ b/releasenotes/notes/use_omp_set_max_active_levels-7e6c1d301c4434a6.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Aer will now use ``omp_set_max_active_levels()`` instead of the deprecated ``omp_set_nested()`` when compiled against recent versions of OpenMP. diff --git a/src/controllers/aer_controller.hpp b/src/controllers/aer_controller.hpp index f0ee3acd31..704de9c501 100644 --- a/src/controllers/aer_controller.hpp +++ b/src/controllers/aer_controller.hpp @@ -963,7 +963,11 @@ Result Controller::execute(std::vector &circuits, parallel_nested_ = true; // nested should be set to zero if num_threads clause will be used +#if _OPENMP >= 200805 + omp_set_max_active_levels(0); +#else omp_set_nested(0); +#endif result.metadata.add(parallel_nested_, "omp_nested"); } else {