From d248f8a29a5c31d6ce10c3cde558b43180f00352 Mon Sep 17 00:00:00 2001 From: Lu Date: Fri, 9 Oct 2020 18:32:58 +0800 Subject: [PATCH] fix conflict between master and devel branch --- setup.py | 14 +----------- source/op/CMakeLists.txt | 2 +- source/op/cuda/descrpt_se_a.cu | 41 ++++++++++++++++++---------------- 3 files changed, 24 insertions(+), 33 deletions(-) diff --git a/setup.py b/setup.py index 98bcfded26..858f84aa5a 100644 --- a/setup.py +++ b/setup.py @@ -6,15 +6,6 @@ from os import path, makedirs import os, imp, sys, platform, sysconfig -def get_dp_install_path() : - site_packages_path = sysconfig.get_paths()['purelib'] - 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 = os.path.join(site_packages_path, 'deepmd') - dp_setup_install_path = os.path.join(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: @@ -31,7 +22,7 @@ def get_dp_install_path() : tf_install_dir = imp.find_module('tensorflow', [site_packages_path])[1] install_requires=['numpy', 'scipy'] -setup_requires=['setuptools_scm', 'scikit-build'] +setup_requires=['setuptools_scm', 'scikit-build', 'cmake'] # add cmake as a build requirement if cmake>3.0 is not installed try: @@ -45,7 +36,6 @@ def get_dp_install_path() : except OSError: pass -dp_pip_install_path, dp_setup_install_path = get_dp_install_path() setup( name="deepmd-kit", @@ -69,8 +59,6 @@ def get_dp_install_path() : '-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', diff --git a/source/op/CMakeLists.txt b/source/op/CMakeLists.txt index 993a1b6fd4..e73e5dcb49 100644 --- a/source/op/CMakeLists.txt +++ b/source/op/CMakeLists.txt @@ -25,7 +25,7 @@ endif (BUILD_CPP_IF) if (BUILD_PY_IF) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - set(CMAKE_INSTALL_RPATH DESTINATION ${DP_PIP_INSTALL_PATH} ${DP_SETUP_INSTALL_PATH} ${CMAKE_BINARY_DIR}/op/cuda) + set(CMAKE_INSTALL_RPATH $ORIGIN) if (USE_CUDA_TOOLKIT) add_library(op_abi SHARED ${OP_PY_CUDA_SRC} ${OP_LIB}) add_library(op_grads SHARED ${OP_GRADS_SRC}) diff --git a/source/op/cuda/descrpt_se_a.cu b/source/op/cuda/descrpt_se_a.cu index 1dd255fff2..09b2ed2638 100644 --- a/source/op/cuda/descrpt_se_a.cu +++ b/source/op/cuda/descrpt_se_a.cu @@ -24,6 +24,8 @@ limitations under the License. typedef float VALUETYPE; #endif +typedef double compute_t; + typedef unsigned long long int_64; #define cudaErrcheck(res) { cudaAssert((res), __FILE__, __LINE__); } @@ -132,12 +134,12 @@ __global__ void format_nlist_fill_a_se_a(const VALUETYPE * coord, int_64 * key_in = key + idx * MAGIC_NUMBER; - VALUETYPE diff[3]; + compute_t diff[3]; const int & j_idx = nei_idx[idy]; for (int dd = 0; dd < 3; dd++) { diff[dd] = coord[j_idx * 3 + dd] - coord[idx * 3 + dd]; } - VALUETYPE rr = sqrt(dev_dot(diff, diff)); + compute_t rr = sqrt(dev_dot(diff, diff)); if (rr <= rcut) { key_in[idy] = type[j_idx] * 1E15+ (int_64)(rr * 1.0E13) / 100000 * 100000 + j_idx; } @@ -179,18 +181,19 @@ __global__ void format_nlist_fill_b_se_a(int * nlist, } //it's ok! -__global__ void compute_descriptor_se_a (VALUETYPE* descript, +template +__global__ void compute_descriptor_se_a (FPTYPE* descript, const int ndescrpt, - VALUETYPE* descript_deriv, + FPTYPE* descript_deriv, const int descript_deriv_size, - VALUETYPE* rij, + FPTYPE* rij, const int rij_size, const int* type, - const VALUETYPE* avg, - const VALUETYPE* std, + const FPTYPE* avg, + const FPTYPE* std, int* nlist, const int nlist_size, - const VALUETYPE* coord, + const FPTYPE* coord, const float rmin, const float rmax, const int sec_a_size) @@ -203,9 +206,9 @@ __global__ void compute_descriptor_se_a (VALUETYPE* descript, if (idy >= sec_a_size) {return;} // else {return;} - VALUETYPE * row_descript = descript + idx * ndescrpt; - VALUETYPE * row_descript_deriv = descript_deriv + idx * descript_deriv_size; - VALUETYPE * row_rij = rij + idx * rij_size; + FPTYPE * row_descript = descript + idx * ndescrpt; + FPTYPE * row_descript_deriv = descript_deriv + idx * descript_deriv_size; + FPTYPE * row_rij = rij + idx * rij_size; int * row_nlist = nlist + idx * nlist_size; if (row_nlist[idy] >= 0) { @@ -213,14 +216,14 @@ __global__ void compute_descriptor_se_a (VALUETYPE* descript, for (int kk = 0; kk < 3; kk++) { row_rij[idy * 3 + kk] = coord[j_idx * 3 + kk] - coord[idx * 3 + kk]; } - const VALUETYPE * rr = &row_rij[idy * 3 + 0]; - VALUETYPE nr2 = dev_dot(rr, rr); - VALUETYPE inr = 1./sqrt(nr2); - VALUETYPE nr = nr2 * inr; - VALUETYPE inr2 = inr * inr; - VALUETYPE inr4 = inr2 * inr2; - VALUETYPE inr3 = inr4 * nr; - VALUETYPE sw, dsw; + const FPTYPE * rr = &row_rij[idy * 3 + 0]; + FPTYPE nr2 = dev_dot(rr, rr); + FPTYPE inr = 1./sqrt(nr2); + FPTYPE nr = nr2 * inr; + FPTYPE inr2 = inr * inr; + FPTYPE inr4 = inr2 * inr2; + FPTYPE inr3 = inr4 * nr; + FPTYPE sw, dsw; spline5_switch(sw, dsw, nr, rmin, rmax); row_descript[idx_value + 0] = (1./nr) ;//* sw; row_descript[idx_value + 1] = (rr[0] / nr2) ;//* sw;