Skip to content

Commit 376f28e

Browse files
authored
Tests: supplementing some tests with OPENMP check directives (#5504)
* Tests: supplementing some tests with OPENMP check directives to successfully compile when OpenMP is not enabled * Correct __OPENMP macro spell * Revert "Correct __OPENMP macro spell" This reverts commit 7728162. * Update elecstate test to remove commands of omp macro definition * Correct __OPENMP macro spell of #include
1 parent 5816785 commit 376f28e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

source/module_base/module_mixing/test/mixing_test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#ifdef _OPENMP
12
#include <omp.h>
3+
#endif
24

35
#include "../broyden_mixing.h"
46
#include "../plain_mixing.h"
@@ -151,7 +153,9 @@ class Mixing_Test : public testing::Test
151153

152154
TEST_F(Mixing_Test, BroydenSolveLinearEq)
153155
{
156+
#ifdef _OPENMP
154157
omp_set_num_threads(1);
158+
#endif
155159
init_method("broyden");
156160
std::vector<double> x_in = xd_ref;
157161
std::vector<double> x_out(3);
@@ -196,7 +200,9 @@ TEST_F(Mixing_Test, BroydenSolveLinearEq)
196200

197201
TEST_F(Mixing_Test, PulaySolveLinearEq)
198202
{
203+
#ifdef _OPENMP
199204
omp_set_num_threads(1);
205+
#endif
200206
init_method("pulay");
201207
std::vector<double> x_in = xd_ref;
202208
std::vector<double> x_out(3);
@@ -242,7 +248,9 @@ TEST_F(Mixing_Test, PulaySolveLinearEq)
242248

243249
TEST_F(Mixing_Test, PlainSolveLinearEq)
244250
{
251+
#ifdef _OPENMP
245252
omp_set_num_threads(1);
253+
#endif
246254
init_method("plain");
247255
std::vector<double> x_in = xd_ref;
248256
std::vector<double> x_out(3);

source/module_elecstate/test/charge_mixing_test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
#include "module_basis/module_pw/pw_basis.h"
1111
#include "module_hamilt_general/module_xc/xc_functional.h"
1212
#undef private
13+
14+
#ifdef _OPENMP
1315
#include <omp.h>
16+
#endif
1417

1518
int FUNC_TYPE = 1;
1619

@@ -116,7 +119,9 @@ class ChargeMixingTest : public ::testing::Test
116119

117120
TEST_F(ChargeMixingTest, SetMixingTest)
118121
{
122+
#ifdef _OPENMP
119123
omp_set_num_threads(1);
124+
#endif
120125
PARAM.input.nspin = 1;
121126
Charge_Mixing CMtest;
122127
CMtest.set_rhopw(&pw_basis, &pw_basis);
@@ -214,7 +219,9 @@ TEST_F(ChargeMixingTest, SetMixingTest)
214219

215220
TEST_F(ChargeMixingTest, InitMixingTest)
216221
{
222+
#ifdef _OPENMP
217223
omp_set_num_threads(1);
224+
#endif
218225
PARAM.input.nspin = 1;
219226
FUNC_TYPE = 1;
220227
Charge_Mixing CMtest;

0 commit comments

Comments
 (0)