From a23c6a81f372791fe8db65ca2ddc631cbafc1285 Mon Sep 17 00:00:00 2001 From: chillenb Date: Fri, 12 Jul 2024 17:40:46 -0400 Subject: [PATCH 1/3] make sure only the thread that holds the GIL does Python stuff --- src/dmrg/determinant.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/dmrg/determinant.hpp b/src/dmrg/determinant.hpp index 3f7c7ac3..3b066ae7 100644 --- a/src/dmrg/determinant.hpp +++ b/src/dmrg/determinant.hpp @@ -391,7 +391,11 @@ struct DeterminantTRIE #pragma omp parallel num_threads(ntg) // depth-first traverse of trie while (!ptrs.empty()) { +#pragma omp master + { check_signal_()(); + // the master thread holds the GIL + } int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) { @@ -772,7 +776,11 @@ struct DeterminantTRIE #pragma omp parallel num_threads(ntg) // depth-first traverse of trie while (!ptrs.empty()) { +#pragma omp master + { check_signal_()(); + // the master thread holds the GIL + } int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) { @@ -1080,7 +1088,11 @@ struct DeterminantTRIE #pragma omp parallel num_threads(ntg) // depth-first traverse of trie while (!ptrs.empty()) { +#pragma omp master + { check_signal_()(); + // the master thread holds the GIL + } int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) { @@ -1451,7 +1463,11 @@ struct DeterminantTRIE #pragma omp parallel num_threads(ntg) // depth-first traverse of trie while (!ptrs.empty()) { +#pragma omp master + { check_signal_()(); + // the master thread holds the GIL + } int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) { From 09435a93f2e94ed8de5c0a1314fa82e5251a9f84 Mon Sep 17 00:00:00 2001 From: chillenb Date: Sat, 13 Jul 2024 00:03:59 -0400 Subject: [PATCH 2/3] code style --- src/dmrg/determinant.hpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/dmrg/determinant.hpp b/src/dmrg/determinant.hpp index 3b066ae7..47e1e1a1 100644 --- a/src/dmrg/determinant.hpp +++ b/src/dmrg/determinant.hpp @@ -392,10 +392,7 @@ struct DeterminantTRIE // depth-first traverse of trie while (!ptrs.empty()) { #pragma omp master - { - check_signal_()(); - // the master thread holds the GIL - } + check_signal_()(); int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) { @@ -777,10 +774,7 @@ struct DeterminantTRIE // depth-first traverse of trie while (!ptrs.empty()) { #pragma omp master - { - check_signal_()(); - // the master thread holds the GIL - } + check_signal_()(); int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) { @@ -1089,10 +1083,7 @@ struct DeterminantTRIE // depth-first traverse of trie while (!ptrs.empty()) { #pragma omp master - { - check_signal_()(); - // the master thread holds the GIL - } + check_signal_()(); int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) { @@ -1464,10 +1455,7 @@ struct DeterminantTRIE // depth-first traverse of trie while (!ptrs.empty()) { #pragma omp master - { - check_signal_()(); - // the master thread holds the GIL - } + check_signal_()(); int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) { From 40f569e50cfd189f1d5ccbc8dd0f262bcddd93c1 Mon Sep 17 00:00:00 2001 From: Huanchen Zhai Date: Fri, 12 Jul 2024 23:02:39 -0700 Subject: [PATCH 3/3] fix indent --- src/dmrg/determinant.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dmrg/determinant.hpp b/src/dmrg/determinant.hpp index 47e1e1a1..fc197c4a 100644 --- a/src/dmrg/determinant.hpp +++ b/src/dmrg/determinant.hpp @@ -392,7 +392,7 @@ struct DeterminantTRIE // depth-first traverse of trie while (!ptrs.empty()) { #pragma omp master - check_signal_()(); + check_signal_()(); int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) { @@ -774,7 +774,7 @@ struct DeterminantTRIE // depth-first traverse of trie while (!ptrs.empty()) { #pragma omp master - check_signal_()(); + check_signal_()(); int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) { @@ -1083,7 +1083,7 @@ struct DeterminantTRIE // depth-first traverse of trie while (!ptrs.empty()) { #pragma omp master - check_signal_()(); + check_signal_()(); int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) { @@ -1455,7 +1455,7 @@ struct DeterminantTRIE // depth-first traverse of trie while (!ptrs.empty()) { #pragma omp master - check_signal_()(); + check_signal_()(); int pstart = max(0, (int)ptrs.size() - ngroup); #pragma omp for schedule(static) for (int ip = pstart; ip < (int)ptrs.size(); ip++) {