forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 218
Add gtest support for Sunway builds #7197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
A-006
wants to merge
7
commits into
deepmodeling:develop
Choose a base branch
from
A-006:scal
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d811fdc
add gtest for the sunway
A-006 d2df2fc
update compile file
A-006 bfdf9ae
Update tools/gtest_on_sunway/gtest_on_sunway.sh
A-006 78935fc
Update tools/gtest_on_sunway/gtest_on_sunway.sh
A-006 83a2ac3
Update tools/gtest_on_sunway/gtest_on_sunway.sh
A-006 c5044c8
Merge branch 'develop' into scal
A-006 8c99a3b
remove file
A-006 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| Title: Add gtest support for Sunway builds | ||
|
|
||
| Summary: | ||
| - Add a Sunway-specific gtest build script and documentation under tools. | ||
| - Update CMake test definitions to better handle Sunway constraints and selective test enabling. | ||
| - Register additional unit test CMakeLists for hsolver and LCAO RT modules. | ||
|
|
||
| Files Changed: | ||
| - CMakeLists.txt | ||
| - source/source_base/module_container/ATen/kernels/test/CMakeLists.txt | ||
| - source/source_base/module_container/test/CMakeLists.txt | ||
| - source/source_hsolver/test/CMakeLists.txt | ||
| - source/source_lcao/module_rt/test/CMakeLists.txt | ||
| - tools/README.md | ||
| - tools/gtest_on_sunway/gtest_on_sunway.sh | ||
|
|
||
| Testing: | ||
| - Not run (please confirm if you ran any tests) |
18 changes: 11 additions & 7 deletions
18
source/source_base/module_container/ATen/kernels/test/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| AddTest( | ||
| TARGET MODULE_BASE_container_kernels_uts | ||
| LIBS parameter ${math_libs} | ||
| SOURCES blas_test.cpp lapack_test.cpp | ||
| memory_test.cpp linalg_test.cpp | ||
| ) | ||
| if(USE_SW) | ||
| message(WARNING "Skip MODULE_BASE_container_kernels_uts on USE_SW.") | ||
| else() | ||
| AddTest( | ||
| TARGET MODULE_BASE_container_kernels_uts | ||
| LIBS parameter ${math_libs} | ||
| SOURCES blas_test.cpp lapack_test.cpp | ||
| memory_test.cpp linalg_test.cpp | ||
| ) | ||
|
|
||
| target_link_libraries(MODULE_BASE_container_kernels_uts container base device) | ||
| target_link_libraries(MODULE_BASE_container_kernels_uts container base device) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,14 @@ | ||
| remove_definitions(-D__MPI) | ||
|
|
||
| AddTest( | ||
| TARGET MODULE_BASE_CONTAINER_Unittests | ||
| LIBS parameter container base device ${math_libs} | ||
| SOURCES tensor_test.cpp tensor_shape_test.cpp allocator_test.cpp | ||
| tensor_buffer_test.cpp tensor_map_test.cpp | ||
| tensor_utils_test.cpp tensor_accessor_test.cpp | ||
| ) | ||
| # Disable this test on Sunway (USE_SW) due to LAPACK symbol issues. | ||
| if(USE_SW) | ||
| message(WARNING "Skip MODULE_BASE_CONTAINER_Unittests on USE_SW.") | ||
| else() | ||
| AddTest( | ||
| TARGET MODULE_BASE_CONTAINER_Unittests | ||
| LIBS parameter container base device ${math_libs} | ||
| SOURCES tensor_test.cpp tensor_shape_test.cpp allocator_test.cpp | ||
| tensor_buffer_test.cpp tensor_map_test.cpp | ||
| tensor_utils_test.cpp tensor_accessor_test.cpp | ||
| ) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Build ABACUS in two modes: | ||
| # 1) no-tests mode (default): preserve original build flow without GTest | ||
| # 2) with-tests mode: build and use local/offline GoogleTest | ||
| # Usage: | ||
| # bash tools/gtest_on_sunway/gtest_on_sunway.sh --no-tests [abacus_root] | ||
| # bash tools/gtest_on_sunway/gtest_on_sunway.sh --with-tests [abacus_root] /path/to/googletest | ||
| # GTEST_SRC=/path/to/googletest bash tools/gtest_on_sunway/gtest_on_sunway.sh --with-tests [abacus_root] | ||
| # CC=mpicc CXX=mpic++ bash tools/gtest_on_sunway/gtest_on_sunway.sh --with-tests /path/to/googletest | ||
| # bash tools/gtest_on_sunway/gtest_on_sunway.sh --with-tests --cc mpicc --cxx mpic++ /path/to/googletest | ||
| # bash tools/gtest_on_sunway/gtest_on_sunway.sh --with-tests --install /path/to/googletest | ||
| # bash tools/gtest_on_sunway/gtest_on_sunway.sh --with-tests --use-elpa /path/to/googletest | ||
| # Defaults are aligned with your known-good build command and can be overridden | ||
| # by environment variables: USE_OPENMP_FLAG, ENABLE_LCAO_FLAG, USE_SW_FLAG, | ||
| # SW_MATH_PATH, SW_FFT_PATH, CEREAL_INCLUDE_DIR, CXX_FLAGS_EXTRA. | ||
|
|
||
| # Recommended usage for SW platform: | ||
| # CC=mpicc CXX=mpic++ bash tools/gtest_on_sunway/gtest_on_sunway.sh --with-tests /path/to/googletest/googletest/ | ||
|
|
||
| ABACUS_ROOT="$PWD" | ||
| GTEST_SRC="${GTEST_SRC:-}" | ||
| ENABLE_TESTING="OFF" | ||
| C_COMPILER="${CC:-}" | ||
| CXX_COMPILER="${CXX:-}" | ||
| DO_INSTALL="OFF" | ||
| USE_ELPA_FLAG="OFF" | ||
| USE_OPENMP_FLAG="${USE_OPENMP_FLAG:-OFF}" | ||
| ENABLE_LCAO_FLAG="${ENABLE_LCAO_FLAG:-ON}" | ||
| USE_SW_FLAG="${USE_SW_FLAG:-ON}" | ||
| SW_MATH_PATH="${SW_MATH_PATH:-/usr/sw/yyzlib/xMath-SACA}" | ||
| SW_FFT_PATH="${SW_FFT_PATH:-/usr/sw/yyzlib/fftw-3.3.8}" | ||
| CEREAL_INCLUDE_DIR="${CEREAL_INCLUDE_DIR:-}" | ||
| CXX_FLAGS_EXTRA="${CXX_FLAGS_EXTRA:--I/usr/sw/yyzlib/xMath-SACA/include}" | ||
|
|
||
| POSITIONAL_ARGS=() | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --with-tests) | ||
| ENABLE_TESTING="ON" | ||
| shift | ||
| ;; | ||
| --no-tests) | ||
| ENABLE_TESTING="OFF" | ||
| shift | ||
| ;; | ||
| --cc) | ||
| C_COMPILER="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| --cxx) | ||
| CXX_COMPILER="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| --install) | ||
| DO_INSTALL="ON" | ||
| shift | ||
| ;; | ||
| --no-install) | ||
| DO_INSTALL="OFF" | ||
| shift | ||
| ;; | ||
| --use-elpa) | ||
| USE_ELPA_FLAG="ON" | ||
| shift | ||
| ;; | ||
| --no-elpa) | ||
| USE_ELPA_FLAG="OFF" | ||
| shift | ||
| ;; | ||
| *) | ||
| POSITIONAL_ARGS+=("$1") | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ ${#POSITIONAL_ARGS[@]} -ge 2 ]]; then | ||
| ABACUS_ROOT="${POSITIONAL_ARGS[0]}" | ||
| GTEST_SRC="${POSITIONAL_ARGS[1]}" | ||
| elif [[ ${#POSITIONAL_ARGS[@]} -eq 1 ]]; then | ||
| # Single-argument mode: | ||
| # - with-tests: argument is googletest path | ||
| # - no-tests: argument is ABACUS root | ||
| if [[ "${ENABLE_TESTING}" == "ON" ]]; then | ||
| GTEST_SRC="${POSITIONAL_ARGS[0]}" | ||
| else | ||
| ABACUS_ROOT="${POSITIONAL_ARGS[0]}" | ||
| fi | ||
| fi | ||
|
|
||
| CMAKE_COMPILER_ARGS=() | ||
| if [[ -n "${C_COMPILER}" ]]; then | ||
| CMAKE_COMPILER_ARGS+=("-DCMAKE_C_COMPILER=${C_COMPILER}") | ||
| fi | ||
| if [[ -n "${CXX_COMPILER}" ]]; then | ||
| CMAKE_COMPILER_ARGS+=("-DCMAKE_CXX_COMPILER=${CXX_COMPILER}") | ||
| fi | ||
|
|
||
| ABACUS_CMAKE_ARGS=() | ||
| ABACUS_CMAKE_ARGS+=("-DUSE_ELPA=${USE_ELPA_FLAG}") | ||
| ABACUS_CMAKE_ARGS+=("-DUSE_OPENMP=${USE_OPENMP_FLAG}") | ||
| ABACUS_CMAKE_ARGS+=("-DENABLE_LCAO=${ENABLE_LCAO_FLAG}") | ||
| ABACUS_CMAKE_ARGS+=("-DUSE_SW=${USE_SW_FLAG}") | ||
| ABACUS_CMAKE_ARGS+=("-DSW_MATH=${SW_MATH_PATH}") | ||
| ABACUS_CMAKE_ARGS+=("-DSW_FFT=${SW_FFT_PATH}") | ||
| ABACUS_CMAKE_ARGS+=("-DCEREAL_INCLUDE_DIR=${CEREAL_INCLUDE_DIR}") | ||
|
|
||
| ABACUS_CMAKE_ARGS+=("-DCMAKE_CXX_FLAGS=${CXX_FLAGS_EXTRA}") | ||
|
|
||
| if [[ ! -f "${ABACUS_ROOT}/CMakeLists.txt" ]]; then | ||
| echo "Error: invalid ABACUS root: ${ABACUS_ROOT}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| NPROC="$(command -v nproc >/dev/null 2>&1 && nproc || getconf _NPROCESSORS_ONLN || echo 4)" | ||
|
|
||
| GTEST_PREFIX="${ABACUS_ROOT}/_local/gtest" | ||
| GTEST_BUILD_DIR="${ABACUS_ROOT}/_build_gtest" | ||
| ABACUS_BUILD_DIR="${ABACUS_ROOT}/build_local_gtest" | ||
| ABACUS_INSTALL_PREFIX="${ABACUS_BUILD_DIR}/install" | ||
|
|
||
| if [[ "${ENABLE_TESTING}" == "ON" ]]; then | ||
| if [[ -z "${GTEST_SRC}" ]]; then | ||
| echo "Error: with-tests mode requires googletest source path (arg or GTEST_SRC)" | ||
| exit 1 | ||
| fi | ||
| if [[ ! -f "${GTEST_SRC}/CMakeLists.txt" ]]; then | ||
| echo "Error: invalid googletest source path: ${GTEST_SRC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # If user passed repo subdir .../googletest, normalize to repo root so gmock is built too. | ||
| if [[ -d "${GTEST_SRC}/../googlemock" && -f "${GTEST_SRC}/../CMakeLists.txt" ]]; then | ||
| GTEST_SRC="$(cd "${GTEST_SRC}/.." && pwd)" | ||
| fi | ||
|
|
||
| echo "== [1/5] Build and install googletest to ${GTEST_PREFIX}" | ||
| cmake -S "${GTEST_SRC}" -B "${GTEST_BUILD_DIR}" \ | ||
| "${CMAKE_COMPILER_ARGS[@]}" \ | ||
| -DBUILD_GTEST=ON \ | ||
| -DBUILD_GMOCK=ON \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_INSTALL_PREFIX="${GTEST_PREFIX}" | ||
|
|
||
| cmake --build "${GTEST_BUILD_DIR}" -j"${NPROC}" | ||
|
|
||
| # Always install googletest to a user-writable local prefix. | ||
| cmake --install "${GTEST_BUILD_DIR}" | ||
|
|
||
| # Use install-tree package config for stable imported targets. | ||
| GTEST_CMAKE_DIR="" | ||
| for d in "${GTEST_PREFIX}/lib/cmake/GTest" "${GTEST_PREFIX}/lib64/cmake/GTest"; do | ||
| if [[ -f "${d}/GTestConfig.cmake" ]]; then | ||
| GTEST_CMAKE_DIR="${d}" | ||
| break | ||
| fi | ||
| done | ||
|
|
||
| if [[ -z "${GTEST_CMAKE_DIR}" ]]; then | ||
| echo "Error: GTestConfig.cmake not found in build or install tree" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "== [2/5] Configure ABACUS with local GTest (offline mode)" | ||
| cmake -S "${ABACUS_ROOT}" -B "${ABACUS_BUILD_DIR}" \ | ||
| "${CMAKE_COMPILER_ARGS[@]}" \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_INSTALL_PREFIX="${ABACUS_INSTALL_PREFIX}" \ | ||
| "${ABACUS_CMAKE_ARGS[@]}" \ | ||
| -DBUILD_TESTING=ON \ | ||
| -DGTest_DIR="${GTEST_CMAKE_DIR}" \ | ||
| -DGTEST_DIR="${GTEST_CMAKE_DIR}" \ | ||
| -DCMAKE_PREFIX_PATH="${GTEST_PREFIX}" \ | ||
| -DFETCHCONTENT_FULLY_DISCONNECTED=ON | ||
| else | ||
| echo "== [1/3] Configure ABACUS without tests (original mode)" | ||
| cmake -S "${ABACUS_ROOT}" -B "${ABACUS_BUILD_DIR}" \ | ||
| "${CMAKE_COMPILER_ARGS[@]}" \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_INSTALL_PREFIX="${ABACUS_INSTALL_PREFIX}" \ | ||
| "${ABACUS_CMAKE_ARGS[@]}" \ | ||
| -DBUILD_TESTING=OFF | ||
| fi | ||
|
|
||
| echo "== Build ABACUS" | ||
| cmake --build "${ABACUS_BUILD_DIR}" -j"${NPROC}" | ||
|
|
||
| if [[ "${DO_INSTALL}" == "ON" ]]; then | ||
| echo "== Install ABACUS" | ||
| cmake --install "${ABACUS_BUILD_DIR}" | ||
| else | ||
| echo "== Skip install (use --install to enable)" | ||
| fi | ||
|
|
||
| if [[ "${ENABLE_TESTING}" == "ON" ]]; then | ||
| echo "== [5/5] List tests" | ||
| cd "${ABACUS_BUILD_DIR}" | ||
| ctest -N || true | ||
| fi | ||
|
|
||
| if [[ "${ENABLE_TESTING}" == "ON" ]]; then | ||
| echo "Done. ABACUS is configured to use local GTest at: ${GTEST_CMAKE_DIR}" | ||
| else | ||
| echo "Done. ABACUS is built in original mode without GTest (BUILD_TESTING=OFF)." | ||
| fi | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.