Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5d1ba70
Merge pull request #15 from deepmodeling/devel
denghuilu Apr 13, 2020
e4e1ac7
add customized op for gelu activation function
Apr 13, 2020
7b0c12e
remove shared library LIB_DEEPMD_OP_CUDA, instead use static library
Apr 13, 2020
60634f9
Merge pull request #215 from denghuilu/devel
amcadmus Apr 13, 2020
5bf6f16
Merge pull request #17 from deepmodeling/devel
denghuilu May 8, 2020
7c34c58
fix bugs of gelu activation function
May 8, 2020
8ef6453
set rpath for libdeepmd_op_cuda.so
May 12, 2020
c3cafcf
install setuptools_scm before sdist
njzjz May 13, 2020
2d2ff4b
set library rpath for both 'pip install .'
May 13, 2020
a6f76b7
Merge branch 'devel-submit' of https://github.com/denghuilu/deepmd-ki…
May 13, 2020
3d77e59
Merge pull request #224 from denghuilu/devel-submit
amcadmus May 13, 2020
848e1f4
add max nbor size from 1024 to 4096
May 26, 2020
c7f8473
Merge pull request #227 from denghuilu/devel-submit
amcadmus May 27, 2020
7730cc6
fix bug of memory leak
May 28, 2020
93aa907
Merge pull request #229 from denghuilu/devel-submit
amcadmus May 28, 2020
f342c35
fix bug ase calculator None-PBC system
haidi-ustc Jun 25, 2020
0a9646c
Merge pull request #232 from haidi-ustc/devel
amcadmus Jun 30, 2020
43fd8bf
Update transform.py
GeiduanLiu Jul 3, 2020
ddcf17c
Merge pull request #234 from GeiduanLiu/devel
amcadmus Jul 4, 2020
c0e0a14
Update transform.py
GeiduanLiu Jul 6, 2020
8e28cf8
Update Fitting.py
GeiduanLiu Jul 6, 2020
e141573
Update transform.py
GeiduanLiu Jul 6, 2020
604ced7
Merge pull request #235 from GeiduanLiu/devel
amcadmus Jul 7, 2020
f280cc0
add one-sided embedding net
Jul 20, 2020
6b3d014
Merge pull request #237 from amcadmus/devel
amcadmus Jul 20, 2020
f209b4f
fix bug of loading coord when data has only one frame
Jul 20, 2020
360e7cf
Merge pull request #239 from amcadmus/devel
amcadmus Jul 21, 2020
6ba9779
raise exception when det(cell) < 0
Jul 23, 2020
088d3b0
Merge remote-tracking branch 'upstream/devel' into devel
Jul 23, 2020
6cd18cc
Merge pull request #240 from amcadmus/devel
amcadmus Jul 23, 2020
a57d605
add missing c++ header for std except
Jul 23, 2020
b0f11a9
Merge pull request #241 from amcadmus/devel
amcadmus Aug 4, 2020
14091c3
implement external efield in fix/dplr
May 23, 2020
2362a2f
add energy calculation in fix/dplr
Aug 10, 2020
7a0b41b
Merge pull request #243 from amcadmus/devel
amcadmus Aug 10, 2020
b449a4e
fix bug of parsing fix/dplr
Aug 12, 2020
9912a79
Merge pull request #244 from amcadmus/devel
amcadmus Aug 12, 2020
2a76ca4
append detail file when testing multi systems
Aug 13, 2020
128f86d
fix bug: requiring atomic ener computation when requiring detail report
Aug 13, 2020
7b44d39
Merge pull request #245 from amcadmus/devel
amcadmus Aug 13, 2020
846a78e
fix bug of computing total force in fix/dplr
Aug 14, 2020
385c847
Merge pull request #246 from amcadmus/devel
amcadmus Aug 14, 2020
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
- CXX=g++-7
- TENSORFLOW_VERSION=2.1
install:
- python -m pip install twine cibuildwheel==1.1.0 scikit-build
- python -m pip install twine cibuildwheel==1.1.0 scikit-build setuptools_scm
script:
- python -m cibuildwheel --output-dir wheelhouse
- python setup.py sdist
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "scikit-build", "cmake", "ninja", "m2r"]
requires = ["setuptools", "setuptools_scm", "wheel", "scikit-build", "cmake", "ninja", "m2r"]

18 changes: 17 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
from skbuild import setup
from skbuild.exceptions import SKBuildError
from skbuild.cmaker import get_cmake_version
from setuptools_scm import get_version
from packaging.version import LegacyVersion
from os import path, makedirs
import imp
import imp, sys, platform

def get_dp_install_path() :
site_packages_path = path.join(path.dirname(path.__file__), 'site-packages')
dp_scm_version = get_version(root="./", relative_to=__file__)
python_version = 'py' + str(sys.version_info.major + sys.version_info.minor * 0.1)
os_info = sys.platform
machine_info = platform.machine()
dp_pip_install_path = site_packages_path + '/deepmd'
dp_setup_install_path = site_packages_path + '/deepmd_kit-' + dp_scm_version + '-' + python_version + '-' + os_info + '-' + machine_info + '.egg/deepmd'

return dp_pip_install_path, dp_setup_install_path

readme_file = path.join(path.dirname(path.abspath(__file__)), 'README.md')
try:
Expand Down Expand Up @@ -34,6 +46,8 @@
except OSError:
pass

dp_pip_install_path, dp_setup_install_path = get_dp_install_path()

setup(
name="deepmd-kit",
setup_requires=setup_requires,
Expand All @@ -56,6 +70,8 @@
'-DBUILD_PY_IF:BOOL=TRUE',
'-DBUILD_CPP_IF:BOOL=FALSE',
'-DFLOAT_PREC:STRING=high',
'-DDP_PIP_INSTALL_PATH=%s' % dp_pip_install_path,
'-DDP_SETUP_INSTALL_PATH=%s' % dp_setup_install_path,
],
cmake_source_dir='source',
cmake_minimum_required_version='3.0',
Expand Down
2 changes: 1 addition & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ if (BUILD_CPP_IF)
set (LIB_DEEPMD_OP "deepmd_op")
if (USE_CUDA_TOOLKIT)
set (LIB_DEEPMD_OP_CUDA "deepmd_op_cuda")
else()
else ()
set (LIB_DEEPMD_OP_CUDA "deepmd_op")
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.9)
Expand Down
11 changes: 3 additions & 8 deletions source/lib/include/NNPInter.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ class NNPInter
compute_t *array_double;
InternalNeighborList nlist;
NNPAtomMap<VALUETYPE> nnpmap;
unsigned long long *array_longlong;
int *ilist, *jrange, *jlist, *array_int;
int *ilist, *jrange, *jlist;
int ilist_size, jrange_size, jlist_size;
int arr_int_size, arr_ll_size, arr_dou_size;

// function used for neighbor list copy
vector<int> get_sel_a() const;
Expand Down Expand Up @@ -191,13 +189,10 @@ class NNPInterModelDevi
vector<vector<int> > sec;
InternalNeighborList nlist;
NNPAtomMap<VALUETYPE> nnpmap;
unsigned long long *array_longlong;
int max_sec_size = 0, max_sec_back = 0;
int *ilist, *jrange, *jlist, *array_int;
int ilist_size, jrange_size, jlist_size, arr_int_size, arr_ll_size, arr_dou_size;
int *ilist, *jrange, *jlist;
int ilist_size, jrange_size, jlist_size;

// function used for nborlist copy
void get_max_sec();
vector<vector<int> > get_sel() const;
void cum_sum(const std::vector<std::vector<int32> > n_sel);
#ifdef USE_CUDA_TOOLKIT
Expand Down
4 changes: 4 additions & 0 deletions source/lib/include/SimulationRegion_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <iostream>
#include <limits>
#include <typeinfo>
#include <stdexcept>

using namespace std;

Expand Down Expand Up @@ -500,6 +501,9 @@ computeVolume()
boxt[0*3+1] * (boxt[1*3+0]*boxt[2*3+2] - boxt[2*3+0]*boxt[1*3+2]) +
boxt[0*3+2] * (boxt[1*3+0]*boxt[2*3+1] - boxt[2*3+0]*boxt[1*3+1]);
volumei = static_cast<double>(1.)/volume;
if (volume < 0) {
throw std::runtime_error("Negative volume detected. Please make sure the simulation cell obeys the right-hand rule.");
}
}

template<typename VALUETYPE>
Expand Down
3 changes: 0 additions & 3 deletions source/lib/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ session_input_tensors (vector<std::pair<string, Tensor>>& input_tensors,
const int * ilist,
const int * jrange,
const int * jlist,
int * array_int,
unsigned long long * array_longlong,
double * array_double,
const vector<VALUETYPE> & fparam_,
const vector<VALUETYPE> & aparam_,
const NNPAtomMap<VALUETYPE> & nnpmap,
Expand Down
112 changes: 10 additions & 102 deletions source/lib/src/NNPInter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "SimulationRegion.h"
#include <stdexcept>

#define MAGIC_NUMBER 1024

#ifdef USE_CUDA_TOOLKIT
#include "cuda_runtime.h"
Expand All @@ -14,7 +13,7 @@
#define cudaErrcheck(res) { cudaAssert((res), __FILE__, __LINE__); }
inline void cudaAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
if (code != cudaSuccess)
{
fprintf(stderr,"cuda assert: %s %s %d\n", cudaGetErrorString(code), file, line);
if (abort) exit(code);
Expand Down Expand Up @@ -273,33 +272,19 @@ NNPInter::~NNPInter() {
cudaErrcheck(cudaFree(ilist));
cudaErrcheck(cudaFree(jrange));
cudaErrcheck(cudaFree(jlist));
cudaErrcheck(cudaFree(array_int));
cudaErrcheck(cudaFree(array_longlong));
cudaErrcheck(cudaFree(array_double));
}
#endif
}

#ifdef USE_CUDA_TOOLKIT
void NNPInter::update_nbor(const InternalNeighborList & nlist, const int nloc) {
if (!init_nbor) {
sec_a = cum_sum(get_sel_a());
cudaErrcheck(cudaMalloc((void**)&ilist, sizeof(int) * nlist.ilist.size()));
cudaErrcheck(cudaMalloc((void**)&jrange, sizeof(int) * nlist.jrange.size()));
cudaErrcheck(cudaMalloc((void**)&jlist, sizeof(int) * nlist.jlist.size()));
cudaErrcheck(cudaMalloc((void**)&array_int, sizeof(int) * (sec_a.size() + nloc * sec_a.size() + nloc)));
cudaErrcheck(cudaMalloc((void**)&array_longlong, sizeof(unsigned long long) * nloc * MAGIC_NUMBER * 2));
#ifdef HIGH_PREC
cudaErrcheck(cudaMalloc((void**)&array_double, sizeof(compute_t) * nloc * sec_a.back() * 3));
#else
cudaErrcheck(cudaMalloc((void**)&array_double, sizeof(compute_t) * nloc * sec_a.back() * 3));
#endif
ilist_size = nlist.ilist.size();
jrange_size = nlist.jrange.size();
jlist_size = nlist.jlist.size();
arr_int_size = sec_a.size() + nloc * sec_a.size() + nloc;
arr_ll_size = nloc * MAGIC_NUMBER * 2;
arr_dou_size = nloc * sec_a.back() * 3;
init_nbor = true;
}
if (ilist_size < nlist.ilist.size()) {
Expand All @@ -317,25 +302,7 @@ void NNPInter::update_nbor(const InternalNeighborList & nlist, const int nloc) {
cudaErrcheck(cudaMalloc((void**)&jlist, sizeof(int) * nlist.jlist.size()));
jlist_size = nlist.jlist.size();
}
if (arr_int_size < sec_a.size() + nloc * sec_a.size() + nloc) {
cudaErrcheck(cudaFree(array_int));
cudaErrcheck(cudaMalloc((void**)&array_int, sizeof(int) * (sec_a.size() + nloc * sec_a.size() + nloc)));
arr_int_size = sec_a.size() + nloc * sec_a.size() + nloc;
}
if (arr_ll_size < nloc * MAGIC_NUMBER * 2) {
cudaErrcheck(cudaFree(array_longlong));
cudaErrcheck(cudaMalloc((void**)&array_longlong, sizeof(unsigned long long) * nloc * MAGIC_NUMBER * 2));
arr_ll_size = nloc * MAGIC_NUMBER * 2;
}
if (arr_dou_size < nloc * sec_a.back() * 3) {
cudaErrcheck(cudaFree(array_double));
#ifdef HIGH_PREC
cudaErrcheck(cudaMalloc((void**)&array_double, sizeof(compute_t) * nloc * sec_a.back() * 3));
#else
cudaErrcheck(cudaMalloc((void**)&array_double, sizeof(compute_t) * nloc * sec_a.back() * 3));
#endif
arr_dou_size = nloc * sec_a.back() * 3;
}

cudaErrcheck(cudaMemcpy(ilist, &nlist.ilist[0], sizeof(int) * nlist.ilist.size(), cudaMemcpyHostToDevice));
cudaErrcheck(cudaMemcpy(jrange, &nlist.jrange[0], sizeof(int) * nlist.jrange.size(), cudaMemcpyHostToDevice));
cudaErrcheck(cudaMemcpy(jlist, &nlist.jlist[0], sizeof(int) * nlist.jlist.size(), cudaMemcpyHostToDevice));
Expand Down Expand Up @@ -378,14 +345,10 @@ init (const string & model, const int & gpu_rank)
if (dfparam < 0) dfparam = 0;
if (daparam < 0) daparam = 0;
inited = true;

init_nbor = false;
array_int = NULL;
array_double = NULL;
array_longlong = NULL;
ilist = NULL; jrange = NULL; jlist = NULL;
ilist_size = 0; jrange_size = 0; jlist_size = 0;
arr_int_size = 0; arr_ll_size = 0; arr_dou_size = 0;
}
#else
void
Expand Down Expand Up @@ -415,12 +378,8 @@ init (const string & model, const int & gpu_rank)
inited = true;

init_nbor = false;
array_int = NULL;
array_double = NULL;
array_longlong = NULL;
ilist = NULL; jrange = NULL; jlist = NULL;
ilist_size = 0; jrange_size = 0; jlist_size = 0;
arr_int_size = 0; arr_ll_size = 0; arr_dou_size = 0;
}
#endif

Expand Down Expand Up @@ -602,7 +561,7 @@ compute_inner (ENERGYTYPE & dener,
}

#ifdef USE_CUDA_TOOLKIT
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, fparam, aparam, nnpmap, nghost);
#else
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
#endif
Expand Down Expand Up @@ -669,7 +628,7 @@ compute (ENERGYTYPE & dener,
}

#ifdef USE_CUDA_TOOLKIT
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, fparam, aparam, nnpmap, nghost);
#else
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
#endif
Expand Down Expand Up @@ -710,9 +669,6 @@ NNPInterModelDevi::~NNPInterModelDevi() {
cudaErrcheck(cudaFree(ilist));
cudaErrcheck(cudaFree(jrange));
cudaErrcheck(cudaFree(jlist));
cudaErrcheck(cudaFree(array_int));
cudaErrcheck(cudaFree(array_longlong));
cudaErrcheck(cudaFree(array_double));
}
#endif
}
Expand Down Expand Up @@ -761,14 +717,10 @@ init (const vector<string> & models, const int & gpu_rank)
// cell_size = rcut;
// ntypes = get_ntypes();
inited = true;

init_nbor = false;
array_int = NULL;
array_double = NULL;
array_longlong = NULL;
ilist = NULL; jrange = NULL; jlist = NULL;
ilist_size = 0; jrange_size = 0; jlist_size = 0;
arr_int_size = 0; arr_ll_size = 0; arr_dou_size = 0;
}
#else
void
Expand Down Expand Up @@ -798,14 +750,10 @@ init (const vector<string> & models, const int & gpu_rank)
// cell_size = rcut;
// ntypes = get_ntypes();
inited = true;

init_nbor = false;
array_int = NULL;
array_double = NULL;
array_longlong = NULL;
ilist = NULL; jrange = NULL; jlist = NULL;
ilist_size = 0; jrange_size = 0; jlist_size = 0;
arr_int_size = 0; arr_ll_size = 0; arr_dou_size = 0;
}
#endif

Expand Down Expand Up @@ -873,40 +821,18 @@ cum_sum (const std::vector<std::vector<int32> > n_sel)
}
}

void
NNPInterModelDevi::
get_max_sec()
{
for (int ii = 0; ii < numb_models; ii++) {
this->max_sec_size = max_sec_size < sec[ii].size() ? sec[ii].size() : max_sec_size;
this->max_sec_back = max_sec_back < sec[ii].back() ? sec[ii].back() : max_sec_back;
}
}

#ifdef USE_CUDA_TOOLKIT
void
NNPInterModelDevi::
update_nbor(const InternalNeighborList & nlist, const int nloc)
{
if (!init_nbor) {
cum_sum(get_sel());
get_max_sec();
cudaErrcheck(cudaMalloc((void**)&ilist, sizeof(int) * nlist.ilist.size()));
cudaErrcheck(cudaMalloc((void**)&jrange, sizeof(int) * nlist.jrange.size()));
cudaErrcheck(cudaMalloc((void**)&jlist, sizeof(int) * nlist.jlist.size()));
cudaErrcheck(cudaMalloc((void**)&array_int, sizeof(int) * (max_sec_size + nloc * max_sec_size + nloc)));
cudaErrcheck(cudaMalloc((void**)&array_longlong, sizeof(unsigned long long) * nloc * MAGIC_NUMBER * 2));
#ifdef HIGH_PREC
cudaErrcheck(cudaMalloc((void**)&array_double, sizeof(compute_t) * nloc * max_sec_back * 3));
#else
cudaErrcheck(cudaMalloc((void**)&array_double, sizeof(compute_t) * nloc * max_sec_back * 3));
#endif
ilist_size = nlist.ilist.size();
jrange_size = nlist.jrange.size();
jlist_size = nlist.jlist.size();
arr_int_size = max_sec_size + nloc * max_sec_size + nloc;
arr_ll_size = nloc * MAGIC_NUMBER * 2;
arr_dou_size = nloc * max_sec_back * 3;
init_nbor = true;
}
if (ilist_size < nlist.ilist.size()) {
Expand All @@ -924,25 +850,7 @@ update_nbor(const InternalNeighborList & nlist, const int nloc)
cudaErrcheck(cudaMalloc((void**)&jlist, sizeof(int) * nlist.jlist.size()));
jlist_size = nlist.jlist.size();
}
if (arr_int_size < max_sec_size + nloc * max_sec_size + nloc) {
cudaErrcheck(cudaFree(array_int));
cudaErrcheck(cudaMalloc((void**)&array_int, sizeof(int) * (max_sec_size + nloc * max_sec_size + nloc)));
arr_int_size = max_sec_size + nloc * max_sec_size + nloc;
}
if (arr_ll_size < nloc * MAGIC_NUMBER * 2) {
cudaErrcheck(cudaFree(array_longlong));
cudaErrcheck(cudaMalloc((void**)&array_longlong, sizeof(unsigned long long) * nloc * MAGIC_NUMBER * 2));
arr_ll_size = nloc * MAGIC_NUMBER * 2;
}
if (arr_dou_size < nloc * max_sec_back * 3) {
cudaErrcheck(cudaFree(array_double));
#ifdef HIGH_PREC
cudaErrcheck(cudaMalloc((void**)&array_double, sizeof(compute_t) * nloc * max_sec_back * 3));
#else
cudaErrcheck(cudaMalloc((void**)&array_double, sizeof(compute_t) * nloc * max_sec_back * 3));
#endif
arr_dou_size = nloc * max_sec_back * 3;
}

cudaErrcheck(cudaMemcpy(ilist, &nlist.ilist[0], sizeof(int) * nlist.ilist.size(), cudaMemcpyHostToDevice));
cudaErrcheck(cudaMemcpy(jrange, &nlist.jrange[0], sizeof(int) * nlist.jrange.size(), cudaMemcpyHostToDevice));
cudaErrcheck(cudaMemcpy(jlist, &nlist.jlist[0], sizeof(int) * nlist.jlist.size(), cudaMemcpyHostToDevice));
Expand Down Expand Up @@ -1044,7 +952,7 @@ compute (vector<ENERGYTYPE> & all_energy,

}
#ifdef USE_CUDA_TOOLKIT
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, fparam, aparam, nnpmap, nghost);
#else
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
#endif
Expand Down Expand Up @@ -1094,7 +1002,7 @@ compute (vector<ENERGYTYPE> & all_energy,

}
#ifdef USE_CUDA_TOOLKIT
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, fparam, aparam, nnpmap, nghost);
#else
int ret = session_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
#endif
Expand Down
Loading