Skip to content

Commit 14ebd2d

Browse files
gitpeterwindilfreddy
authored andcommitted
bug fix for omp in serial case (race condition)
1 parent 66a35fa commit 14ebd2d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/utils/CompFunction.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,13 +1031,15 @@ void rotate_cplx(CompFunctionVector &Phi, const ComplexMatrix &U, CompFunctionVe
10311031
int node_ix = indexVec_ref[n]; // SerialIx for this node in the reference tree
10321032
// 4a) make a dense contiguous matrix with the coefficient from all the orbitals using node n
10331033
std::vector<int> orbjVec; // to remember which orbital correspond to each orbVec.size();
1034+
if (node2orbVec.count(node_ix) == 0) continue;
10341035
if (node2orbVec[node_ix].size() <= 0) continue;
10351036
csize = sizecoeffW;
10361037
if (parindexVec_ref[n] < 0) csize = sizecoeff; // for root nodes we include scaling coeff
10371038

10381039
int shift = sizecoeff - sizecoeffW; // to copy only wavelet part
10391040
if (parindexVec_ref[n] < 0) shift = 0;
10401041
ComplexMatrix coeffBlock(csize, node2orbVec[node_ix].size());
1042+
10411043
for (int j : node2orbVec[node_ix]) { // loop over indices of the orbitals using this node
10421044
int orb_node_ix = orb2node[j][node_ix];
10431045
for (int k = 0; k < csize; k++) coeffBlock(k, orbjVec.size()) = coeffVec[j][orb_node_ix][k + shift];
@@ -1319,6 +1321,7 @@ void rotate(CompFunctionVector &Phi, const ComplexMatrix &U, CompFunctionVector
13191321
int node_ix = indexVec_ref[n]; // SerialIx for this node in the reference tree
13201322
// 4a) make a dense contiguous matrix with the coefficient from all the orbitals using node n
13211323
std::vector<int> orbjVec; // to remember which orbital correspond to each orbVec.size();
1324+
if (node2orbVec.count(node_ix) == 0) continue;
13221325
if (node2orbVec[node_ix].size() <= 0) continue;
13231326
csize = sizecoeffW;
13241327
if (parindexVec_ref[n] < 0) csize = sizecoeff; // for root nodes we include scaling coeff
@@ -1680,6 +1683,7 @@ CompFunctionVector multiply(CompFunctionVector &Phi, RepresentableFunction<3> &f
16801683
for (int n = 0; n < max_n; n++) {
16811684
MWNode<D> node(*(refNodes[n]), false);
16821685
int node_ix = indexVec_ref[n]; // SerialIx for this node in the reference tree
1686+
if (node2orbVec.count(node_ix) == 0) continue;
16831687

16841688
// 3a) make values for f at this node
16851689
// 3a1) get coordinates of quadrature points for this node
@@ -2001,6 +2005,7 @@ ComplexMatrix calc_overlap_matrix_cplx(CompFunctionVector &BraKet) {
20012005
int csize;
20022006
int node_ix = indexVec_ref[n]; // SerialIx for this node in the reference tree
20032007
std::vector<int> orbVec; // identifies which orbitals use this node
2008+
if (serial and node2orbVec.count(node_ix) == 0) continue;
20042009
if (serial and node2orbVec[node_ix].size() <= 0) continue;
20052010
if (parindexVec_ref[n] < 0)
20062011
csize = sizecoeff;
@@ -2149,6 +2154,7 @@ ComplexMatrix calc_overlap_matrix(CompFunctionVector &BraKet) {
21492154
int csize;
21502155
int node_ix = indexVec_ref[n]; // SerialIx for this node in the reference tree
21512156
std::vector<int> orbVec; // identifies which orbitals use this node
2157+
if (serial and node2orbVec.count(node_ix) == 0) continue;
21522158
if (serial and node2orbVec[node_ix].size() <= 0) continue;
21532159
if (parindexVec_ref[n] < 0)
21542160
csize = sizecoeff;
@@ -2361,6 +2367,8 @@ ComplexMatrix calc_overlap_matrix_cplx(CompFunctionVector &Bra, CompFunctionVect
23612367
csize = sizecoeffW;
23622368
if (serial) {
23632369
int node_ix = indexVec_ref[n]; // SerialIx for this node in the reference tree
2370+
if (node2orbVecBra.count(node_ix) == 0) continue;
2371+
if (node2orbVecKet.count(node_ix) == 0) continue;
23642372
int shift = sizecoeff - sizecoeffW; // to copy only wavelet part
23652373
ComplexMatrix coeffBlockBra(csize, node2orbVecBra[node_ix].size());
23662374
ComplexMatrix coeffBlockKet(csize, node2orbVecKet[node_ix].size());
@@ -2587,6 +2595,8 @@ ComplexMatrix calc_overlap_matrix(CompFunctionVector &Bra, CompFunctionVector &K
25872595
csize = sizecoeffW;
25882596
if (serial) {
25892597
int node_ix = indexVec_ref[n]; // SerialIx for this node in the reference tree
2598+
if (node2orbVecBra.count(node_ix) == 0) continue;
2599+
if (node2orbVecKet.count(node_ix) == 0) continue;
25902600
int shift = sizecoeff - sizecoeffW; // to copy only wavelet part
25912601
DoubleMatrix coeffBlockBra(csize, node2orbVecBra[node_ix].size());
25922602
DoubleMatrix coeffBlockKet(csize, node2orbVecKet[node_ix].size());

0 commit comments

Comments
 (0)