From 376f28e53c931d6310576c1e731947b8f4a34621 Mon Sep 17 00:00:00 2001 From: Chen Nuo <49788094+Cstandardlib@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:09:43 +0800 Subject: [PATCH] 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 7728162c56a54ae1f237bbc3e06a6601320e790a. * Update elecstate test to remove commands of omp macro definition * Correct __OPENMP macro spell of #include --- source/module_base/module_mixing/test/mixing_test.cpp | 8 ++++++++ source/module_elecstate/test/charge_mixing_test.cpp | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/source/module_base/module_mixing/test/mixing_test.cpp b/source/module_base/module_mixing/test/mixing_test.cpp index 91e9f51866..67c627462b 100755 --- a/source/module_base/module_mixing/test/mixing_test.cpp +++ b/source/module_base/module_mixing/test/mixing_test.cpp @@ -1,4 +1,6 @@ +#ifdef _OPENMP #include +#endif #include "../broyden_mixing.h" #include "../plain_mixing.h" @@ -151,7 +153,9 @@ class Mixing_Test : public testing::Test TEST_F(Mixing_Test, BroydenSolveLinearEq) { +#ifdef _OPENMP omp_set_num_threads(1); +#endif init_method("broyden"); std::vector x_in = xd_ref; std::vector x_out(3); @@ -196,7 +200,9 @@ TEST_F(Mixing_Test, BroydenSolveLinearEq) TEST_F(Mixing_Test, PulaySolveLinearEq) { +#ifdef _OPENMP omp_set_num_threads(1); +#endif init_method("pulay"); std::vector x_in = xd_ref; std::vector x_out(3); @@ -242,7 +248,9 @@ TEST_F(Mixing_Test, PulaySolveLinearEq) TEST_F(Mixing_Test, PlainSolveLinearEq) { +#ifdef _OPENMP omp_set_num_threads(1); +#endif init_method("plain"); std::vector x_in = xd_ref; std::vector x_out(3); diff --git a/source/module_elecstate/test/charge_mixing_test.cpp b/source/module_elecstate/test/charge_mixing_test.cpp index 907596808c..4a113cf88f 100644 --- a/source/module_elecstate/test/charge_mixing_test.cpp +++ b/source/module_elecstate/test/charge_mixing_test.cpp @@ -10,7 +10,10 @@ #include "module_basis/module_pw/pw_basis.h" #include "module_hamilt_general/module_xc/xc_functional.h" #undef private + +#ifdef _OPENMP #include +#endif int FUNC_TYPE = 1; @@ -116,7 +119,9 @@ class ChargeMixingTest : public ::testing::Test TEST_F(ChargeMixingTest, SetMixingTest) { +#ifdef _OPENMP omp_set_num_threads(1); +#endif PARAM.input.nspin = 1; Charge_Mixing CMtest; CMtest.set_rhopw(&pw_basis, &pw_basis); @@ -214,7 +219,9 @@ TEST_F(ChargeMixingTest, SetMixingTest) TEST_F(ChargeMixingTest, InitMixingTest) { +#ifdef _OPENMP omp_set_num_threads(1); +#endif PARAM.input.nspin = 1; FUNC_TYPE = 1; Charge_Mixing CMtest;