Skip to content

Commit 414f59a

Browse files
authored
Change some int to long long. (#6743)
1 parent 7d7c750 commit 414f59a

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

source/source_base/parallel_reduce.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ void Parallel_Reduce::reduce_all<int>(int& object)
1313
return;
1414
}
1515

16+
template <>
17+
void Parallel_Reduce::reduce_all<long long>(long long& object)
18+
{
19+
#ifdef __MPI
20+
MPI_Allreduce(MPI_IN_PLACE, &object, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
21+
#endif
22+
return;
23+
}
24+
1625
void Parallel_Reduce::reduce_int_diag(int& object)
1726
{
1827
#ifdef __MPI
@@ -48,6 +57,15 @@ void Parallel_Reduce::reduce_all<int>(int* object, const int n)
4857
return;
4958
}
5059

60+
template <>
61+
void Parallel_Reduce::reduce_all<long long>(long long* object, const int n)
62+
{
63+
#ifdef __MPI
64+
MPI_Allreduce(MPI_IN_PLACE, object, n, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
65+
#endif
66+
return;
67+
}
68+
5169
void Parallel_Reduce::reduce_int_grid(int* object, const int n)
5270
{
5371
#ifdef __MPI

source/source_io/single_R_io.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void ModuleIO::output_single_R(std::ofstream& ofs,
2323
const bool& reduce)
2424
{
2525
T* line = nullptr;
26-
std::vector<int> indptr;
26+
std::vector<long long> indptr;
2727
indptr.reserve(PARAM.globalv.nlocal + 1);
2828
indptr.push_back(0);
2929

source/source_io/write_HS_sparse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ void ModuleIO::save_sparse(
716716
ModuleBase::timer::tick("ModuleIO", "save_sparse");
717717

718718
int total_R_num = all_R_coor.size();
719-
std::vector<int> nonzero_num(total_R_num, 0);
719+
std::vector<long long> nonzero_num(total_R_num, 0);
720720
int count = 0;
721721
for (auto& R_coor: all_R_coor) {
722722
auto iter = smat.find(R_coor);

0 commit comments

Comments
 (0)