Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f99ad4d
debug 4749
iProzd Aug 14, 2025
ba8f52e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 14, 2025
aa8b3a8
fix cmake
iProzd Aug 14, 2025
4dab5d8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 14, 2025
4a2027e
fix bugs
iProzd Aug 26, 2025
a4f565f
Update DeepPotPT.cc
iProzd Aug 27, 2025
58e340c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 27, 2025
e0626dd
Update DeepPotPT.cc
iProzd Aug 27, 2025
73ad268
wrapped a func
iProzd Aug 27, 2025
7167591
fix const
iProzd Aug 27, 2025
619b158
Merge branch 'devel' into D0814_debug_c_nlist
iProzd Aug 27, 2025
e8b889e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 27, 2025
2114514
Update test_lammps_dpa_pt.py
iProzd Aug 27, 2025
af2411d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 27, 2025
69a9086
Merge branch 'master' into D0814_debug_c_nlist
wanghan-iapcm Feb 20, 2026
bb13cdf
revert old fix
iProzd Feb 25, 2026
0411338
use own comm data for remapped sendlist
iProzd Feb 25, 2026
b415c67
Update common.cc
iProzd Feb 25, 2026
3068a24
Revert commit
iProzd Mar 3, 2026
c8e4be1
Merge branch 'master' into D0814_debug_c_nlist
iProzd Mar 3, 2026
5875158
update fix, ref to #5268
iProzd Mar 3, 2026
78fdc64
Delete test_select_real_atoms_sendlist.cc
iProzd Mar 3, 2026
773c4e6
Create test_select_real_atoms_sendlist.cc
iProzd Mar 3, 2026
b061270
Update DeepSpinPT.cc
iProzd Mar 3, 2026
9afc5c0
fix PD
iProzd Mar 3, 2026
280729f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 80 additions & 10 deletions source/api_cc/src/DeepPotPT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
#include "device.h"
#include "errors.h"

#ifdef USE_MPI
Comment thread
iProzd marked this conversation as resolved.
Outdated
#include <mpi.h>
#ifdef OMPI_MPI_H
#include <mpi-ext.h>
Comment thread
iProzd marked this conversation as resolved.
Outdated
#endif
#endif
Comment thread
iProzd marked this conversation as resolved.
Outdated

using namespace deepmd;

void DeepPotPT::translate_error(std::function<void()> f) {
Expand Down Expand Up @@ -174,16 +181,79 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
nlist_data.padding();
if (do_message_passing) {
int nswap = lmp_list.nswap;

std::vector<int> sendnum_new(nswap, 0);
std::vector<int> sendlist_new;
sendlist_new.reserve(
std::accumulate(lmp_list.sendnum, lmp_list.sendnum + nswap, 0)
);
for (int s = 0; s < nswap; ++s) {
int cnt = 0;
for (int k = 0; k < lmp_list.sendnum[s]; ++k) {
const int old_idx = lmp_list.sendlist[s][k];
int mapped = (old_idx >= 0 && old_idx < (int)fwd_map.size())
? fwd_map[old_idx]
: -1;
if (mapped >= 0) {
sendlist_new.push_back(mapped);
++cnt;
}
}
sendnum_new[s] = cnt;
}

std::vector<int> recvnum_new(nswap, 0);
#ifdef MPI_FOUND
if (lmp_list.world) {
MPI_Comm comm = *static_cast<MPI_Comm*>(lmp_list.world);
const int TAG_BASE = 0x7a31;
for (int s = 0; s < nswap; ++s) {
const int send_to = lmp_list.sendproc[s];
const int recv_from = lmp_list.recvproc[s];
int send_cnt = sendnum_new[s];
int recv_cnt = 0;
MPI_Sendrecv(&send_cnt, 1, MPI_INT, send_to, TAG_BASE + s,
&recv_cnt, 1, MPI_INT, recv_from, TAG_BASE + s,
comm, MPI_STATUS_IGNORE);
recvnum_new[s] = recv_cnt;
}
} else
#endif
{
for (int s = 0; s < nswap; ++s) recvnum_new[s] = sendnum_new[s];
}

Comment thread
iProzd marked this conversation as resolved.
Outdated
std::vector<int> firstrecv_new(nswap, 0);
int acc = 0;
for (int s = 0; s < nswap; ++s) {
firstrecv_new[s] = acc;
acc += recvnum_new[s];
}

torch::Tensor sendproc_tensor =
torch::from_blob(lmp_list.sendproc, {nswap}, int32_option);
torch::Tensor recvproc_tensor =
torch::from_blob(lmp_list.recvproc, {nswap}, int32_option);
torch::Tensor firstrecv_tensor =
torch::from_blob(lmp_list.firstrecv, {nswap}, int32_option);
torch::Tensor recvnum_tensor =
torch::from_blob(lmp_list.recvnum, {nswap}, int32_option);
torch::Tensor sendnum_tensor =
torch::from_blob(lmp_list.sendnum, {nswap}, int32_option);

torch::Tensor firstrecv_tensor =
torch::from_blob(firstrecv_new.data(), {nswap}, int32_option).clone();
torch::Tensor recvnum_tensor =
torch::from_blob(recvnum_new.data(), {nswap}, int32_option).clone();
torch::Tensor sendnum_tensor =
torch::from_blob(sendnum_new.data(), {nswap}, int32_option).clone();

torch::Tensor sendlist_tensor =
torch::from_blob(sendlist_new.data(),
{ static_cast<long>(sendlist_new.size()) },
int32_option).clone();

Comment thread
iProzd marked this conversation as resolved.
Outdated

// torch::Tensor firstrecv_tensor =
// torch::from_blob(lmp_list.firstrecv, {nswap}, int32_option);
// torch::Tensor recvnum_tensor =
// torch::from_blob(lmp_list.recvnum, {nswap}, int32_option);
// torch::Tensor sendnum_tensor =
// torch::from_blob(lmp_list.sendnum, {nswap}, int32_option);
torch::Tensor communicator_tensor;
if (lmp_list.world == 0) {
communicator_tensor = torch::empty({1}, torch::kInt64);
Expand All @@ -193,10 +263,10 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
}

torch::Tensor nswap_tensor = torch::tensor(nswap, int32_option);
int total_send =
std::accumulate(lmp_list.sendnum, lmp_list.sendnum + nswap, 0);
torch::Tensor sendlist_tensor =
torch::from_blob(lmp_list.sendlist, {total_send}, int32_option);
// int total_send =
// std::accumulate(lmp_list.sendnum, lmp_list.sendnum + nswap, 0);
// torch::Tensor sendlist_tensor =
// torch::from_blob(lmp_list.sendlist, {total_send}, int32_option);
comm_dict.insert_or_assign("send_list", sendlist_tensor);
comm_dict.insert_or_assign("send_proc", sendproc_tensor);
comm_dict.insert_or_assign("recv_proc", recvproc_tensor);
Expand Down
Loading