Skip to content

Fix #7959 #7956, remove useless file. - #7962

Open
mohanchen wants to merge 3 commits into
deepmodeling:developfrom
mohanchen:2026-09-14-line1
Open

mohanchen wants to merge 3 commits into
deepmodeling:developfrom
mohanchen:2026-09-14-line1

Conversation

@mohanchen

Copy link
Copy Markdown
Collaborator

Fix #7959 #7956 , remove useless file.

abacus_fixer added 3 commits September 14, 2026 09:18
module_lr is built whenever ENABLE_LCAO is on, but lr_io_krlist.cpp
unconditionally included module_ri/ri_util.h, which pulls in LibRI
headers (<RI/global/Array_Operator.h>) and fails to compile when
ENABLE_LIBRI is off (regression from deepmodeling#7849).

Move the LibRI-free Born-von Karmen helpers (get_Born_vonKarmen_period,
get_Born_von_Karmen_cells) into a new header ri_util_bvk.h; ri_util.h
now includes it, and lr_io_krlist.cpp includes only the new header.

Verified: target lr builds with ENABLE_LIBRI=OFF (build/), target ri
builds with ENABLE_LIBRI=ON (build_std_para/).
__USE_NVTX was defined only on the final executable target, whose sole
translation unit main.cpp contains no NVTX code. The two OBJECT libraries
that actually guard NVTX calls with the macro -- base (source_base/timer.cpp)
and driver (source_main/driver.cpp) -- never saw it, so every NVTX block was
preprocessed away and timer_enable_nvtx had no effect in any CUDA build.

Move the definition onto base and driver, and link CUDA::nvToolsExt for
CUDA toolkits older than 12.9 (NVTX is header-only since 12.9).

Verified with build_pw_gpu (USE_CUDA=ON): base/driver targets compile with
NVTX symbols present in timer.cpp.o, driver.cpp.o references
timer::enable_nvtx_, and the full abacus_pw_gpu executable links
(v3.11.0-beta9).
@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT GPU & DCU & HPC GPU and DCU and HPC related any issues Refactor Refactor ABACUS codes labels Sep 14, 2026
Comment on lines +26 to +56
// cell index c folded into [0, period) like (c % period + period) % period
template<typename Tcell>
std::vector<std::array<Tcell,1>>
get_Born_von_Karmen_cells( const std::array<Tcell,1> &Born_von_Karman_period )
{
std::vector<std::array<Tcell,1>> Born_von_Karman_cells;
for( Tcell c=0; c<Born_von_Karman_period[0]; ++c )
Born_von_Karman_cells.emplace_back( std::array<Tcell,1>{c} );
return Born_von_Karman_cells;
}

template<typename Tcell, size_t Ndim>
std::vector<std::array<Tcell,Ndim>>
get_Born_von_Karmen_cells( const std::array<Tcell,Ndim> &Born_von_Karman_period )
{
std::array<Tcell,Ndim-1> sub_Born_von_Karman_period;
for(size_t i=0; i<Ndim-1; ++i)
sub_Born_von_Karman_period[i] = Born_von_Karman_period[i];

std::vector<std::array<Tcell,Ndim>> Born_von_Karman_cells;
for( const std::array<Tcell,Ndim-1> &sub_cell : get_Born_von_Karmen_cells(sub_Born_von_Karman_period) )
for( Tcell c=0; c<Born_von_Karman_period.back(); ++c )
{
std::array<Tcell,Ndim> cell;
for(size_t i=0; i<Ndim-1; ++i)
cell[i] = sub_cell[i];
cell.back() = c;
Born_von_Karman_cells.emplace_back(std::move(cell));
}
return Born_von_Karman_cells;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LibRI's integer % operator actually uses (i % n + 3 * n / 2) % n - n / 2, which produces centered cell coordinates. Replacing it with c changes the returned coordinates, for example:

Period Before After
1 0 0
2 0, -1 0, 1
3 0, 1, -1 0, 1, 2
4 0, 1, -2, -1 0, 1, 2, 3

Callers rely on exact coordinate keys. For example, 58_KP_LR_BSE uses a (2,2,2) grid and reads (-1,-1,-1), which is now absent from Rlist; CPU CI fails with R coordinates ... are not in Rlist. Please preserve the original mapping in both the 1D and recursive cases when removing the LibRI dependency.

Comment thread source/CMakeLists.txt
Comment on lines +561 to +566
target_compile_definitions(base PRIVATE __USE_NVTX)
target_compile_definitions(driver PRIVATE __USE_NVTX)
# NVTX is header-only since CUDA 12.9; older toolkits need libnvToolsExt.
if(CUDAToolkit_VERSION VERSION_LESS 12.9)
target_link_libraries(${ABACUS_BIN_NAME} PRIVATE CUDA::nvToolsExt)
endif()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defining __USE_NVTX on base makes timer.cpp.o require NVTX symbols, but linking CUDA::nvToolsExt only to the main executable leaves other base consumers without that dependency. CUDA 12.2 CI already fails to link tests such as MODULE_CELL_SYMMETRY_analysis with undefined references to nvtxRangePushA and nvtxRangePop.

@AsTonyshment AsTonyshment linked an issue Sep 14, 2026 that may be closed by this pull request
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Bugs that only solvable with sufficient knowledge of DFT GPU & DCU & HPC GPU and DCU and HPC related any issues Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

timer_enable_nvtx has no effect in CUDA builds lr_io_krlist.cpp being compiled unconditionally while including LibRI header file

2 participants