Skip to content

Commit 97c2b03

Browse files
committed
Rename module_base to source_base
1 parent fe44679 commit 97c2b03

File tree

1,276 files changed

+107921
-93245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,276 files changed

+107921
-93245
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ set(ABACUS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source)
167167
set(ABACUS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests)
168168
set(ABACUS_BIN_PATH ${CMAKE_CURRENT_BINARY_DIR}/${ABACUS_BIN_NAME})
169169
include_directories(${ABACUS_SOURCE_DIR})
170-
include_directories(${ABACUS_SOURCE_DIR}/module_base/module_container)
170+
include_directories(${ABACUS_SOURCE_DIR}/source_base/module_container)
171171

172172
set(CMAKE_CXX_STANDARD 11)
173173
set(CMAKE_CXX_STANDARD_REQUIRED ON)

docs/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The source code of ABACUS is based on several modules. Under the ABACUS root dir
3939
For those who are interested in the source code, the following figure shows the structure of the source code.
4040

4141
```text
42-
|-- module_base A basic module including
42+
|-- source_base A basic module including
4343
| | (1) Mathematical library interface functions: BLAS, LAPACK, Scalapack;
4444
| | (2) Custom data classes: matrix, vector definitions and related functions;
4545
| | (3) Parallelization functions: MPI, OpenMP;
@@ -183,7 +183,7 @@ pre-commit install
183183

184184
## Adding a unit test
185185

186-
We use [GoogleTest](https://github.com/google/googletest) as our test framework. Write your test under the corresponding module folder at `abacus-develop/tests`, then append the test to `tests/CMakeLists.txt`. If there are currently no unit tests provided for the module, do as follows. `module_base` provides a simple demonstration.
186+
We use [GoogleTest](https://github.com/google/googletest) as our test framework. Write your test under the corresponding module folder at `abacus-develop/tests`, then append the test to `tests/CMakeLists.txt`. If there are currently no unit tests provided for the module, do as follows. `source_base` provides a simple demonstration.
187187

188188
- Add a folder named `test` under the module.
189189
- Append the content below to `CMakeLists.txt` of the module:

python/pyabacus/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ find_package(pybind11 CONFIG REQUIRED)
1212

1313
# set source path
1414
set(ABACUS_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../source")
15-
set(BASE_PATH "${ABACUS_SOURCE_DIR}/module_base")
15+
set(BASE_PATH "${ABACUS_SOURCE_DIR}/source_base")
1616
set(NAO_PATH "${ABACUS_SOURCE_DIR}/module_basis/module_nao")
1717
set(HSOLVER_PATH "${ABACUS_SOURCE_DIR}/source_hsolver")
1818
set(PSI_PATH "${ABACUS_SOURCE_DIR}/module_psi")
@@ -69,14 +69,14 @@ endif()
6969
include_directories(
7070
${BASE_PATH}
7171
${ABACUS_SOURCE_DIR}
72-
${ABACUS_SOURCE_DIR}/module_base/module_container
72+
${ABACUS_SOURCE_DIR}/source_base/module_container
7373
)
7474

7575
# add basic libraries
7676
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
7777
# add base
7878
set(BASE_BINARY_DIR "${PROJECT_SOURCE_DIR}/build/base")
79-
add_subdirectory(${ABACUS_SOURCE_DIR}/module_base ${BASE_BINARY_DIR})
79+
add_subdirectory(${ABACUS_SOURCE_DIR}/source_base ${BASE_BINARY_DIR})
8080
# add parameter
8181
set(PARAMETER_BINARY_DIR "${PROJECT_SOURCE_DIR}/build/parameter")
8282
add_subdirectory(${ABACUS_SOURCE_DIR}/module_parameter ${PARAMETER_BINARY_DIR})

python/pyabacus/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ find_package(pybind11 CONFIG REQUIRED)
7272
```cmake
7373
# Set source path
7474
set(ABACUS_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../source")
75-
set(BASE_PATH "${ABACUS_SOURCE_DIR}/module_base")
75+
set(BASE_PATH "${ABACUS_SOURCE_DIR}/source_base")
7676
set(NAO_PATH "${ABACUS_SOURCE_DIR}/module_basis/module_nao")
7777
set(HSOLVER_PATH "${ABACUS_SOURCE_DIR}/source_hsolver")
7878
set(PSI_PATH "${ABACUS_SOURCE_DIR}/module_psi")
@@ -131,7 +131,7 @@ endif()
131131
include_directories(
132132
${BASE_PATH}
133133
${ABACUS_SOURCE_DIR}
134-
${ABACUS_SOURCE_DIR}/module_base/module_container
134+
${ABACUS_SOURCE_DIR}/source_base/module_container
135135
)
136136
```
137137
- This section adds the necessary include directories for the project.
@@ -141,7 +141,7 @@ include_directories(
141141
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
142142
# Add base
143143
set(BASE_BINARY_DIR "${PROJECT_SOURCE_DIR}/build/base")
144-
add_subdirectory(${ABACUS_SOURCE_DIR}/module_base ${BASE_BINARY_DIR})
144+
add_subdirectory(${ABACUS_SOURCE_DIR}/source_base ${BASE_BINARY_DIR})
145145
# Add parameter
146146
set(PARAMETER_BINARY_DIR "${PROJECT_SOURCE_DIR}/build/parameter")
147147
add_subdirectory(${ABACUS_SOURCE_DIR}/module_parameter ${PARAMETER_BINARY_DIR})

python/pyabacus/examples/indexmap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _index_map(ntype, natom, lmax, nzeta=None):
6060
6161
0, 1, -1, 2, -2, 3, -3, ..., l, -l
6262
63-
(see module_base/ylm.cpp and module_base/math_ylmreal.cpp
63+
(see source_base/ylm.cpp and source_base/math_ylmreal.cpp
6464
for details)
6565
6666
'''

python/pyabacus/src/ModuleBase/py_base_math.cpp

Lines changed: 161 additions & 156 deletions
Large diffs are not rendered by default.

python/pyabacus/src/ModuleNAO/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ list(APPEND _naos
1313
${NAO_PATH}/two_center_integrator.cpp
1414
${NAO_PATH}/two_center_table.cpp
1515
# dependency
16-
${ABACUS_SOURCE_DIR}/module_base/kernels/math_ylm_op.cpp
17-
${ABACUS_SOURCE_DIR}/module_base/kernels/math_kernel_op.cpp
18-
${ABACUS_SOURCE_DIR}/module_base/kernels/math_kernel_op_vec.cpp
16+
${ABACUS_SOURCE_DIR}/source_base/kernels/math_ylm_op.cpp
17+
${ABACUS_SOURCE_DIR}/source_base/kernels/math_kernel_op.cpp
18+
${ABACUS_SOURCE_DIR}/source_base/kernels/math_kernel_op_vec.cpp
1919
# ${ABACUS_SOURCE_DIR}/module_psi/kernels/psi_memory_op.cpp
20-
${ABACUS_SOURCE_DIR}/module_base/module_device/memory_op.cpp
21-
${ABACUS_SOURCE_DIR}/module_base/module_device/device.cpp
20+
${ABACUS_SOURCE_DIR}/source_base/module_device/memory_op.cpp
21+
${ABACUS_SOURCE_DIR}/source_base/module_device/device.cpp
2222
)
2323
add_library(naopack SHARED
2424
${_naos}

python/pyabacus/src/ModuleNAO/py_m_nao.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
#include "module_basis/module_nao/radial_collection.h"
2+
#include "module_basis/module_nao/two_center_integrator.h"
3+
#include "source_base/vector3.h"
4+
15
#include <pybind11/numpy.h>
26
#include <pybind11/pybind11.h>
37
#include <pybind11/stl.h>
48

5-
#include "module_base/vector3.h"
6-
#include "module_basis/module_nao/radial_collection.h"
7-
#include "module_basis/module_nao/two_center_integrator.h"
8-
99
namespace py = pybind11;
1010
using namespace pybind11::literals;
1111
template <typename... Args>

python/pyabacus/src/hsolver/py_diago_cg.hpp

Lines changed: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
#ifndef PYTHON_PYABACUS_SRC_PY_DIAGO_CG_HPP
22
#define PYTHON_PYABACUS_SRC_PY_DIAGO_CG_HPP
33

4+
#include "source_base/module_device/memory_op.h"
5+
#include "source_hsolver/diago_cg.h"
6+
7+
#include <ATen/core/tensor.h>
8+
#include <ATen/core/tensor_map.h>
9+
#include <ATen/core/tensor_types.h>
410
#include <complex>
511
#include <functional>
6-
7-
#include <pybind11/pybind11.h>
812
#include <pybind11/complex.h>
913
#include <pybind11/functional.h>
1014
#include <pybind11/numpy.h>
15+
#include <pybind11/pybind11.h>
1116
#include <pybind11/stl.h>
1217

13-
#include <ATen/core/tensor.h>
14-
#include <ATen/core/tensor_map.h>
15-
#include <ATen/core/tensor_types.h>
16-
17-
#include "source_hsolver/diago_cg.h"
18-
#include "module_base/module_device/memory_op.h"
19-
2018
namespace py = pybind11;
2119

2220
namespace py_hsolver
2321
{
2422

2523
class PyDiagoCG
2624
{
27-
public:
28-
PyDiagoCG(int dim, int num_eigs) : dim{dim}, num_eigs{num_eigs} { }
25+
public:
26+
PyDiagoCG(int dim, int num_eigs) : dim{dim}, num_eigs{num_eigs}
27+
{
28+
}
2929
PyDiagoCG(const PyDiagoCG&) = delete;
3030
PyDiagoCG& operator=(const PyDiagoCG&) = delete;
3131
PyDiagoCG(PyDiagoCG&& other)
@@ -37,9 +37,9 @@ class PyDiagoCG
3737
other.eig = nullptr;
3838
}
3939

40-
~PyDiagoCG()
40+
~PyDiagoCG()
4141
{
42-
if (psi != nullptr)
42+
if (psi != nullptr)
4343
{
4444
delete psi;
4545
psi = nullptr;
@@ -52,19 +52,20 @@ class PyDiagoCG
5252
}
5353
}
5454

55-
void init_eig()
55+
void init_eig()
5656
{
5757
eig = new ct::Tensor(ct::DataType::DT_DOUBLE, {num_eigs});
5858
eig->zero();
5959
}
6060

61-
py::array_t<double> get_eig()
61+
py::array_t<double> get_eig()
6262
{
6363
py::array_t<double> eig_out(eig->NumElements());
6464
py::buffer_info eig_buf = eig_out.request();
6565
double* eig_out_ptr = static_cast<double*>(eig_buf.ptr);
6666

67-
if (eig == nullptr) {
67+
if (eig == nullptr)
68+
{
6869
throw std::runtime_error("eig is not initialized");
6970
}
7071
double* eig_ptr = eig->data<double>();
@@ -78,12 +79,10 @@ class PyDiagoCG
7879
py::buffer_info psi_buf = psi_in.request();
7980
std::complex<double>* psi_ptr = static_cast<std::complex<double>*>(psi_buf.ptr);
8081

81-
psi = new ct::TensorMap(
82-
psi_ptr,
83-
ct::DataType::DT_COMPLEX_DOUBLE,
84-
ct::DeviceType::CpuDevice,
85-
ct::TensorShape({num_eigs, dim})
86-
);
82+
psi = new ct::TensorMap(psi_ptr,
83+
ct::DataType::DT_COMPLEX_DOUBLE,
84+
ct::DeviceType::CpuDevice,
85+
ct::TensorShape({num_eigs, dim}));
8786
}
8887

8988
py::array_t<std::complex<double>> get_psi()
@@ -92,7 +91,8 @@ class PyDiagoCG
9291
py::buffer_info psi_buf = psi_out.request();
9392
std::complex<double>* psi_out_ptr = static_cast<std::complex<double>*>(psi_buf.ptr);
9493

95-
if (psi == nullptr) {
94+
if (psi == nullptr)
95+
{
9696
throw std::runtime_error("psi is not initialized");
9797
}
9898
std::complex<double>* psi_ptr = psi->data<std::complex<double>>();
@@ -106,12 +106,7 @@ class PyDiagoCG
106106
py::buffer_info prec_buf = prec_in.request();
107107
double* prec_ptr = static_cast<double*>(prec_buf.ptr);
108108

109-
prec = new ct::TensorMap(
110-
prec_ptr,
111-
ct::DataType::DT_DOUBLE,
112-
ct::DeviceType::CpuDevice,
113-
ct::TensorShape({dim})
114-
);
109+
prec = new ct::TensorMap(prec_ptr, ct::DataType::DT_DOUBLE, ct::DeviceType::CpuDevice, ct::TensorShape({dim}));
115110
}
116111

117112
void diag(std::function<py::array_t<std::complex<double>>(py::array_t<std::complex<double>>)> mm_op,
@@ -120,23 +115,25 @@ class PyDiagoCG
120115
const std::vector<double>& diag_ethr,
121116
bool need_subspace,
122117
bool scf_type,
123-
int nproc_in_pool = 1
124-
) {
118+
int nproc_in_pool = 1)
119+
{
125120
const std::string basis_type = "pw";
126121
const std::string calculation = scf_type ? "scf" : "nscf";
127122

128-
auto hpsi_func = [mm_op] (const ct::Tensor& psi_in, ct::Tensor& hpsi_out) {
123+
auto hpsi_func = [mm_op](const ct::Tensor& psi_in, ct::Tensor& hpsi_out) {
129124
const auto ndim = psi_in.shape().ndim();
130125
REQUIRES_OK(ndim <= 2, "dims of psi_in should be less than or equal to 2");
131-
const int nvec = ndim == 1 ? 1 : psi_in.shape().dim_size(0);
126+
const int nvec = ndim == 1 ? 1 : psi_in.shape().dim_size(0);
132127
const int ld_psi = ndim == 1 ? psi_in.NumElements() : psi_in.shape().dim_size(1);
133128

134129
// Note: numpy's py::array_t is row-major, and
135130
// our tensor-array is row-major
136131
py::array_t<std::complex<double>> psi({ld_psi, nvec});
137132
py::buffer_info psi_buf = psi.request();
138133
std::complex<double>* psi_ptr = static_cast<std::complex<double>*>(psi_buf.ptr);
139-
std::copy(psi_in.data<std::complex<double>>(), psi_in.data<std::complex<double>>() + nvec * ld_psi, psi_ptr);
134+
std::copy(psi_in.data<std::complex<double>>(),
135+
psi_in.data<std::complex<double>>() + nvec * ld_psi,
136+
psi_ptr);
140137

141138
py::array_t<std::complex<double>> hpsi = mm_op(psi);
142139

@@ -145,34 +142,30 @@ class PyDiagoCG
145142
std::copy(hpsi_ptr, hpsi_ptr + nvec * ld_psi, hpsi_out.data<std::complex<double>>());
146143
};
147144

148-
auto subspace_func = [] (const ct::Tensor& psi_in, ct::Tensor& psi_out) { /*do nothing*/ };
145+
auto subspace_func = [](const ct::Tensor& psi_in, ct::Tensor& psi_out) { /*do nothing*/ };
149146

150-
auto spsi_func = [this] (const ct::Tensor& psi_in, ct::Tensor& spsi_out) {
147+
auto spsi_func = [this](const ct::Tensor& psi_in, ct::Tensor& spsi_out) {
151148
const auto ndim = psi_in.shape().ndim();
152149
REQUIRES_OK(ndim <= 2, "dims of psi_in should be less than or equal to 2");
153-
const int nrow = ndim == 1 ? psi_in.NumElements() : psi_in.shape().dim_size(1);
150+
const int nrow = ndim == 1 ? psi_in.NumElements() : psi_in.shape().dim_size(1);
154151
const int nbands = ndim == 1 ? 1 : psi_in.shape().dim_size(0);
155-
syncmem_z2z_h2h_op()(
156-
spsi_out.data<std::complex<double>>(),
157-
psi_in.data<std::complex<double>>(),
158-
static_cast<size_t>(nrow * nbands)
159-
);
152+
syncmem_z2z_h2h_op()(spsi_out.data<std::complex<double>>(),
153+
psi_in.data<std::complex<double>>(),
154+
static_cast<size_t>(nrow * nbands));
160155
};
161156

162-
cg = std::make_unique<hsolver::DiagoCG<std::complex<double>, base_device::DEVICE_CPU>>(
163-
basis_type,
164-
calculation,
165-
need_subspace,
166-
subspace_func,
167-
tol,
168-
diag_ndim,
169-
nproc_in_pool
170-
);
157+
cg = std::make_unique<hsolver::DiagoCG<std::complex<double>, base_device::DEVICE_CPU>>(basis_type,
158+
calculation,
159+
need_subspace,
160+
subspace_func,
161+
tol,
162+
diag_ndim,
163+
nproc_in_pool);
171164

172165
cg->diag(hpsi_func, spsi_func, *psi, *eig, diag_ethr, *prec);
173166
}
174167

175-
private:
168+
private:
176169
base_device::DEVICE_CPU* ctx = {};
177170

178171
int dim;

0 commit comments

Comments
 (0)