Skip to content

Commit f89c91e

Browse files
authored
Merge pull request #107 from issp-center-dev/fix_link_error
Fix HPC build: missing explicit instantiation, and icpx fast-math breaking Inf/NaN handling
2 parents 9d1b7a0 + 131cc97 commit f89c91e

5 files changed

Lines changed: 20 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ set(CMAKE_CXX_EXTENSIONS OFF)
99

1010
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1111

12+
# icpx defaults to -fp-model=fast, whose finite-math-only assumption breaks
13+
# Inf/NaN handling (e.g. divergent correlation lengths and std::isinf/isnan).
14+
# Force the precise model; add_compile_options here also covers mptensor.
15+
# The path match is a fallback for CMake < 3.20, which does not know the
16+
# IntelLLVM compiler id.
17+
if(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" OR CMAKE_CXX_COMPILER MATCHES "icpx")
18+
add_compile_options(-fp-model=precise)
19+
endif()
20+
1221
option(GIT_SUBMODULE "Check submodules during build" ON)
1322
option(MPTENSOR_ROOT "External directory where mptensor is installed into" OFF)
1423
option(CPPTOML_ROOT "External directory where cpptoml is download into" OFF)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ The following tools are required for building TeNeS.
4545

4646
- C++17 compiler
4747
- For Intel compilers, use the newer `icpx`; the classic `icpc` cannot compile mptensor.
48+
`icpx` enables `-fp-model=fast` by default, which breaks Inf/NaN handling; the TeNeS build
49+
automatically adds `-fp-model=precise`.
4850
- CMake (>=3.6.0)
4951
- BLAS/LAPACK
5052

docs/sphinx/en/install.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ The following tools are required for building TeNeS.
1717
1. C++17 compiler
1818

1919
- For Intel compilers, use the newer ``icpx``; the classic ``icpc`` cannot compile mptensor.
20+
Note that ``icpx`` enables ``-fp-model=fast`` by default, which breaks Inf/NaN handling;
21+
the TeNeS build automatically adds ``-fp-model=precise`` to avoid this.
2022

2123
2. CMake (>=3.6.0)
2224
3. BLAS and LAPACK

docs/sphinx/ja/install.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ TeNeSをコンパイルするには以下のライブラリ・環境が必要で
1717
1. C++17 compiler
1818

1919
- Intel コンパイラの場合、古い ``icpc`` では mptensor をビルドできないため、新しい ``icpx`` を利用してください。
20+
なお、 ``icpx`` はデフォルトで ``-fp-model=fast`` が有効になっており Inf/NaN の扱いが壊れるため、
21+
TeNeS のビルドでは自動的に ``-fp-model=precise`` を付加します。
2022

2123
2. CMake (>=3.6.0)
2224
3. BLAS, LAPACK

src/iTPS/core/ctm_single.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,11 @@ int Calc_CTM_Environment_density(std::vector<tensor> &C1, std::vector<tensor> &C
10571057

10581058
// template instantiate
10591059

1060+
template std::vector<real_tensor> Make_single_tensor_density(
1061+
const std::vector<real_tensor> &Tn);
1062+
template std::vector<complex_tensor> Make_single_tensor_density(
1063+
const std::vector<complex_tensor> &Tn);
1064+
10601065
template void Calc_projector_left_block_single(
10611066
const real_tensor &C1, const real_tensor &C4, const real_tensor &eT1,
10621067
const real_tensor &eT6, const real_tensor &eT7, const real_tensor &eT8,

0 commit comments

Comments
 (0)