Skip to content

Commit

Permalink
Merge branch 'deepmodeling:develop' into ucell15
Browse files Browse the repository at this point in the history
  • Loading branch information
A-006 authored Dec 13, 2024
2 parents 58f3353 + ccd2874 commit 0bbc44f
Show file tree
Hide file tree
Showing 150 changed files with 2,442 additions and 3,259 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ option(ENABLE_CNPY "Enable cnpy usage." OFF)
option(ENABLE_PEXSI "Enable support for PEXSI." OFF)
option(ENABLE_CUSOLVERMP "Enable cusolvermp." OFF)
option(USE_DSP "Enable DSP usage." OFF)
option(USE_CUDA_ON_DCU "Enable CUDA on DCU" OFF)

# enable json support
if(ENABLE_RAPIDJSON)
Expand Down Expand Up @@ -126,6 +127,10 @@ if (USE_DSP)
set(ABACUS_BIN_NAME abacus_dsp)
endif()

if (USE_CUDA_ON_DCU)
add_compile_definitions(__CUDA_ON_DCU)
endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

if(ENABLE_COVERAGE)
Expand Down
3 changes: 0 additions & 3 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,11 @@ OBJS_DEEPKS=LCAO_deepks.o\
deepks_hmat.o\
LCAO_deepks_interface.o\
orbital_precalc.o\
orbital_precalc_k.o\
cal_gdmx.o\
cal_gdmx_k.o\
cal_gedm.o\
cal_gvx.o\
cal_descriptor.o\
v_delta_precalc.o\
v_delta_precalc_k.o\


OBJS_ELECSTAT=elecstate.o\
Expand Down
2 changes: 1 addition & 1 deletion source/module_base/module_device/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void record_device_memory(const Device* dev, std::ofstream& ofs_device, std::str
* @brief for compatibility with __CUDA_ARCH__ 600 and earlier
*
*/
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 600
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 600 && !defined(__CUDA_ON_DCU)
static __inline__ __device__ double atomicAdd(double* address, double val)
{
unsigned long long int* address_as_ull = (unsigned long long int*)address;
Expand Down
4 changes: 2 additions & 2 deletions source/module_base/tool_title.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void TITLE(const std::string &class_name,const std::string &function_name,const
{
if (disable)
{
return;//no output
return; // no output
}
#ifdef __NORMAL
std::cout<<" ==> "<<class_name<<"::"<<function_name<<"\t"
Expand All @@ -39,7 +39,7 @@ void TITLE(std::ofstream &ofs,const std::string &class_name,const std::string &f
{
if (disable)
{
return;//no output
return; // no output
}
#ifdef __NORMAL
std::cout<<"\n\n ==> "<<class_name<<"::"<<function_name<<"\t"
Expand Down
89 changes: 46 additions & 43 deletions source/module_cell/atom_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,51 +102,54 @@ void Atom::bcast_atom(void)
Parallel_Common::bcast_bool(this->flag_empty_element);
Parallel_Common::bcast_double(mass);

if (GlobalV::MY_RANK != 0)
if (na > 0)
{
assert(na != 0);
this->tau.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->dis.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->taud.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->vel.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->mag.resize(na, 0);
this->angle1.resize(na, 0);
this->angle2.resize(na, 0);
this->m_loc_.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->mbl.resize(na, ModuleBase::Vector3<int>(0, 0, 0));
this->lambda.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->constrain.resize(na, ModuleBase::Vector3<int>(0, 0, 0));
}
if (GlobalV::MY_RANK != 0)
{
assert(na != 0);
this->tau.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->dis.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->taud.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->vel.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->mag.resize(na, 0);
this->angle1.resize(na, 0);
this->angle2.resize(na, 0);
this->m_loc_.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->mbl.resize(na, ModuleBase::Vector3<int>(0, 0, 0));
this->lambda.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
this->constrain.resize(na, ModuleBase::Vector3<int>(0, 0, 0));
}

for (int i = 0; i < na; i++)
{
Parallel_Common::bcast_double(tau[i].x);
Parallel_Common::bcast_double(tau[i].y);
Parallel_Common::bcast_double(tau[i].z);
Parallel_Common::bcast_double(taud[i].x);
Parallel_Common::bcast_double(taud[i].y);
Parallel_Common::bcast_double(taud[i].z);
Parallel_Common::bcast_double(dis[i].x);
Parallel_Common::bcast_double(dis[i].y);
Parallel_Common::bcast_double(dis[i].z);
Parallel_Common::bcast_double(vel[i].x);
Parallel_Common::bcast_double(vel[i].y);
Parallel_Common::bcast_double(vel[i].z);
Parallel_Common::bcast_double(mag[i]);
Parallel_Common::bcast_double(angle1[i]);
Parallel_Common::bcast_double(angle2[i]);
Parallel_Common::bcast_double(m_loc_[i].x);
Parallel_Common::bcast_double(m_loc_[i].y);
Parallel_Common::bcast_double(m_loc_[i].z);
Parallel_Common::bcast_int(mbl[i].x);
Parallel_Common::bcast_int(mbl[i].y);
Parallel_Common::bcast_int(mbl[i].z);
Parallel_Common::bcast_double(lambda[i].x);
Parallel_Common::bcast_double(lambda[i].y);
Parallel_Common::bcast_double(lambda[i].z);
Parallel_Common::bcast_int(constrain[i].x);
Parallel_Common::bcast_int(constrain[i].y);
Parallel_Common::bcast_int(constrain[i].z);
for (int i = 0; i < na; i++)
{
Parallel_Common::bcast_double(tau[i].x);
Parallel_Common::bcast_double(tau[i].y);
Parallel_Common::bcast_double(tau[i].z);
Parallel_Common::bcast_double(taud[i].x);
Parallel_Common::bcast_double(taud[i].y);
Parallel_Common::bcast_double(taud[i].z);
Parallel_Common::bcast_double(dis[i].x);
Parallel_Common::bcast_double(dis[i].y);
Parallel_Common::bcast_double(dis[i].z);
Parallel_Common::bcast_double(vel[i].x);
Parallel_Common::bcast_double(vel[i].y);
Parallel_Common::bcast_double(vel[i].z);
Parallel_Common::bcast_double(mag[i]);
Parallel_Common::bcast_double(angle1[i]);
Parallel_Common::bcast_double(angle2[i]);
Parallel_Common::bcast_double(m_loc_[i].x);
Parallel_Common::bcast_double(m_loc_[i].y);
Parallel_Common::bcast_double(m_loc_[i].z);
Parallel_Common::bcast_int(mbl[i].x);
Parallel_Common::bcast_int(mbl[i].y);
Parallel_Common::bcast_int(mbl[i].z);
Parallel_Common::bcast_double(lambda[i].x);
Parallel_Common::bcast_double(lambda[i].y);
Parallel_Common::bcast_double(lambda[i].z);
Parallel_Common::bcast_int(constrain[i].x);
Parallel_Common::bcast_int(constrain[i].y);
Parallel_Common::bcast_int(constrain[i].z);
}
}

return;
Expand Down
28 changes: 1 addition & 27 deletions source/module_cell/module_neighbor/sltk_atom_arrange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,30 +162,4 @@ void atom_arrange::search(
}

return;
}


//2015-05-07
void atom_arrange::delete_vector(
std::ofstream &ofs_in,
const bool pbc_flag, // GlobalV::SEARCH_PBC
Grid_Driver &grid_d,
const UnitCell &ucell,
const double &search_radius_bohr,
const int &test_atom_in)
{
const double radius_lat0unit2 = search_radius_bohr / ucell.lat0;

Atom_input at2(
ofs_in,
ucell,
ucell.nat,
ucell.ntype,
pbc_flag,
radius_lat0unit2,
test_atom_in);

grid_d.delete_vector(at2.getGrid_layerX_minus(),at2.getGrid_layerY_minus(),at2.getGrid_layerZ_minus());

grid_d.delete_Cell();
}
}
11 changes: 0 additions & 11 deletions source/module_cell/module_neighbor/sltk_atom_arrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ class atom_arrange
const double& rcutmax_Beta,
const bool gamma_only_local);

//2015-05-07
static void delete_vector(
std::ofstream &ofs_in,
const bool pbc_flag,
Grid_Driver &grid_d,
const UnitCell &ucell,
const double &search_radius_bohr,
const int &test_atom_in);

private:

};

#endif
29 changes: 2 additions & 27 deletions source/module_cell/module_neighbor/sltk_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,9 @@ CellSet::CellSet()
in_grid[2] = 0;
}

Grid::Grid(const int& test_grid_in) : test_grid(test_grid_in)
{
// ModuleBase::TITLE("Grid","Grid");
//----------------------------------------------------------
// EXPLAIN : init_cell_flag (use this flag in case memory
// leak)
//----------------------------------------------------------
init_cell_flag = false;
}
Grid::Grid(const int& test_grid_in) : test_grid(test_grid_in) {}

Grid::~Grid()
{
this->delete_Cell();
}
Grid::~Grid() {}

void Grid::init(std::ofstream& ofs_in, const UnitCell& ucell, const Atom_input& input)
{
Expand All @@ -49,7 +38,6 @@ void Grid::setMemberVariables(std::ofstream& ofs_in, // output data to ofs
{
ModuleBase::TITLE("SLTK_Grid", "setMemberVariables");

this->delete_Cell();
// mohan add 2010-09-05
// AdjacentSet::call_times = 0;

Expand Down Expand Up @@ -96,8 +84,6 @@ void Grid::setMemberVariables(std::ofstream& ofs_in, // output data to ofs
Cell[i][j].resize(cell_nz);
}
}
this->init_cell_flag = true;

this->true_cell_x = input.getGrid_layerX_minus();
this->true_cell_y = input.getGrid_layerY_minus();
this->true_cell_z = input.getGrid_layerZ_minus();
Expand Down Expand Up @@ -508,14 +494,3 @@ void Grid::Construct_Adjacent_final(const int i,
fatom1.addAdjacent(fatom2);
}
}
// 2015-05-07
void Grid::delete_vector(int i, int j, int k)
{
if (expand_flag)
{
if (this->pbc)
{
this->Cell[i][j][k].atom_map.clear();
}
}
}
32 changes: 5 additions & 27 deletions source/module_cell/module_neighbor/sltk_grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ class Grid
Grid(const int& test_grid_in);
virtual ~Grid();

void init(std::ofstream& ofs, const UnitCell& ucell, const Atom_input& input);
Grid& operator=(Grid&&) = default;

// 2015-05-07
void delete_vector(int i, int j, int k);
void init(std::ofstream& ofs, const UnitCell& ucell, const Atom_input& input);

// Data
bool pbc; // periodic boundary condition
Expand All @@ -64,28 +63,7 @@ class Grid
int true_cell_z;

std::vector<std::vector<std::vector<CellSet>>> Cell; // dx , dy ,dz is cell number in each direction,respectly.
void delete_Cell() // it will replace by container soon!
{
if (this->init_cell_flag)
{
for (int i = 0; i < this->cell_nx; i++)
{
for (int j = 0; j < this->cell_ny; j++)
{
this->Cell[i][j].clear();
}
}

for (int i = 0; i < this->cell_nx; i++)
{
this->Cell[i].clear();
}

this->Cell.clear();
this->init_cell_flag = false;
}
}
bool init_cell_flag = false;

// LiuXh add 2019-07-15
double getD_minX() const
{
Expand Down Expand Up @@ -125,8 +103,8 @@ class Grid
return true_cell_z;
}

private:
const int test_grid;
private:
int test_grid = 0;
//==========================================================
// MEMBER FUNCTIONS :
// Three Main Steps:
Expand Down
16 changes: 5 additions & 11 deletions source/module_cell/module_neighbor/sltk_grid_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
#include <omp.h>
#endif

namespace GlobalC
{
Grid_Driver GridD;
}
Grid_Driver::Grid_Driver(
const int &test_d_in,
const int &test_grid_in)
Expand All @@ -25,13 +21,11 @@ Grid_Driver::~Grid_Driver()
{
}


void Grid_Driver::Find_atom(
const UnitCell &ucell,
const ModuleBase::Vector3<double> &cartesian_pos,
const int &ntype,
const int &nnumber,
AdjacentAtomInfo *adjs)
void Grid_Driver::Find_atom(const UnitCell& ucell,
const ModuleBase::Vector3<double>& cartesian_pos,
const int& ntype,
const int& nnumber,
AdjacentAtomInfo* adjs) const
{
ModuleBase::timer::tick("Grid_Driver","Find_atom");
// std::cout << "lenght in Find atom = " << atomlink[offset].fatom.getAdjacentSet()->getLength() << std::endl;
Expand Down
11 changes: 4 additions & 7 deletions source/module_cell/module_neighbor/sltk_grid_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Grid_Driver : public Grid

~Grid_Driver();

Grid_Driver& operator=(Grid_Driver&&) = default;

//==========================================================
// EXPLAIN FOR default parameter `adjs = nullptr`
//
Expand All @@ -68,7 +70,7 @@ class Grid_Driver : public Grid
const ModuleBase::Vector3<double>& cartesian_posi,
const int& ntype,
const int& nnumber,
AdjacentAtomInfo* adjs = nullptr);
AdjacentAtomInfo* adjs = nullptr) const;

//==========================================================
// EXPLAIN : The adjacent information for the input
Expand Down Expand Up @@ -103,7 +105,7 @@ class Grid_Driver : public Grid
private:
mutable AdjacentAtomInfo adj_info;

const int test_deconstructor; // caoyu reconst 2021-05-24
int test_deconstructor = 0;

//==========================================================
// MEMBER FUNCTIONS :
Expand All @@ -125,9 +127,4 @@ class Grid_Driver : public Grid
const short box_y,
const short box_z) const;
};

namespace GlobalC
{
extern Grid_Driver GridD;
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ Magnetism::~Magnetism()
void SetGlobalV()
{
PARAM.input.test_grid = false;
PARAM.input.test_deconstructor = false;
}

class SltkAtomArrangeTest : public testing::Test
Expand Down
Loading

0 comments on commit 0bbc44f

Please sign in to comment.