Skip to content

Commit

Permalink
Tests: supplementing some tests with OPENMP check directives (#5504)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Cstandardlib authored Nov 16, 2024
1 parent 5816785 commit 376f28e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/module_base/module_mixing/test/mixing_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifdef _OPENMP
#include <omp.h>
#endif

#include "../broyden_mixing.h"
#include "../plain_mixing.h"
Expand Down Expand Up @@ -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<double> x_in = xd_ref;
std::vector<double> x_out(3);
Expand Down Expand Up @@ -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<double> x_in = xd_ref;
std::vector<double> x_out(3);
Expand Down Expand Up @@ -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<double> x_in = xd_ref;
std::vector<double> x_out(3);
Expand Down
7 changes: 7 additions & 0 deletions source/module_elecstate/test/charge_mixing_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <omp.h>
#endif

int FUNC_TYPE = 1;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 376f28e

Please sign in to comment.