Skip to content

Commit

Permalink
Fix: ELPA test compile (#3774)
Browse files Browse the repository at this point in the history
* include genelpa header instead seperate header for elpa test

* fix "\'gtest/gtest.h\' not found"

* add my_elpa back to pass compile.
It is strange that using standard c++ header <complex>(from elpa/elpa.h) instead of <complex.h>(in module_hsolver/my_elpa.h) would cause compile error.

* old elpa compatibility macros
  • Loading branch information
yizeyi18 committed Mar 25, 2024
1 parent 91ed1df commit bdf0a59
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions source/module_hamilt_lcao/module_tddft/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
remove_definitions(-D __MPI)

add_library(tddft_test_lib tddft_test.cpp)
target_link_libraries(tddft_test_lib Threads::Threads GTest::gtest_main GTest::gmock_main)
#target_include_directories(tddft_test_lib PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${GTEST_INCLUDE_DIRS}>)

AddTest(
TARGET tddft_middle_hamilt_test
Expand Down
15 changes: 14 additions & 1 deletion source/module_hsolver/my_elpa.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include <elpa/elpa_version.h>
#include <limits.h>

#if ELPA_API_VERSION < 20221101
extern "C"
{
#endif

struct elpa_struct;
typedef struct elpa_struct *elpa_t;

Expand All @@ -19,15 +24,23 @@ typedef struct elpa_autotune_struct *elpa_autotune_t;
// between C99 (e.g. double complex) and C++11 (std::complex).
// Thus, we have to define a wrapper of complex over the c api
// for compatiability.
#if ELPA_API_VERSION < 20221101
#define complex _Complex
#endif
#include <elpa/elpa_generated.h>
#if ELPA_API_VERSION < 20221101
#undef complex
#endif
#include <elpa/elpa_generic.h>

#define ELPA_2STAGE_REAL_GPU ELPA_2STAGE_REAL_NVIDIA_GPU
#define ELPA_2STAGE_COMPLEX_GPU ELPA_2STAGE_COMPLEX_NVIDIA_GPU

const char *elpa_strerr(int elpa_error);

#if ELPA_API_VERSION < 20221101
}//extern "C"
#endif
#endif

#endif //__ELPA
#endif //ELPA_H
3 changes: 0 additions & 3 deletions source/module_hsolver/test/diago_elpa_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
#include <vector>

#ifdef __ELPA
extern "C"
{
#include "module_hsolver/my_elpa.h"
}
#endif

namespace LCAO_DIAGO_TEST
Expand Down

0 comments on commit bdf0a59

Please sign in to comment.