Skip to content

Commit 3718c7c

Browse files
authored
Merge pull request #231 from denghuilu/master
add max nbor size from 256 to 1024
2 parents 07c42c1 + 7f2bc85 commit 3718c7c

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

source/lib/src/NNPInter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "SimulationRegion.h"
44
#include <stdexcept>
55

6-
#define MAGIC_NUMBER 256
6+
#define MAGIC_NUMBER 1024
77
typedef double compute_t;
88

99
#ifdef USE_CUDA_TOOLKIT

source/op/cuda/descrpt_se_a.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818
#include <cub/block/block_radix_sort.cuh>
1919
#include <cuda_runtime.h>
2020

21-
#define MAGIC_NUMBER 256
21+
#define MAGIC_NUMBER 1024
2222

2323
#ifdef HIGH_PREC
2424
typedef double VALUETYPE;
@@ -339,8 +339,8 @@ void DescrptSeALauncher(const VALUETYPE* coord,
339339
key,
340340
i_idx
341341
);
342-
const int ITEMS_PER_THREAD = 4;
343-
const int BLOCK_THREADS = 64;
342+
const int ITEMS_PER_THREAD = 8;
343+
const int BLOCK_THREADS = MAGIC_NUMBER / ITEMS_PER_THREAD;
344344
// BlockSortKernel<NeighborInfo, BLOCK_THREADS, ITEMS_PER_THREAD><<<g_grid_size, BLOCK_THREADS>>> (
345345
BlockSortKernel<int_64, BLOCK_THREADS, ITEMS_PER_THREAD> <<<nloc, BLOCK_THREADS>>> (key, key + nloc * MAGIC_NUMBER);
346346

source/op/cuda/descrpt_se_r.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ limitations under the License.
1919
#include <cuda_runtime.h>
2020
#include <fstream>
2121

22-
#define MAGIC_NUMBER 256
22+
#define MAGIC_NUMBER 1024
2323

2424
#ifdef HIGH_PREC
2525
typedef double VALUETYPE;
@@ -311,8 +311,8 @@ void DescrptSeRLauncher(const VALUETYPE* coord,
311311
key,
312312
i_idx
313313
);
314-
const int ITEMS_PER_THREAD = 4;
315-
const int BLOCK_THREADS = 64;
314+
const int ITEMS_PER_THREAD = 8;
315+
const int BLOCK_THREADS = MAGIC_NUMBER / ITEMS_PER_THREAD;
316316
BlockSortKernel<int_64, BLOCK_THREADS, ITEMS_PER_THREAD> <<<nloc, BLOCK_THREADS>>> (key, key + nloc * MAGIC_NUMBER);
317317
format_nlist_fill_b_se_r<<<nblock, LEN>>> (
318318
nlist,

source/op/descrpt_se_a_gpu.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "tensorflow/core/framework/shape_inference.h"
88

99
using namespace tensorflow; // NOLINT(build/namespaces)
10-
#define MAGIC_NUMBER 256
10+
#define MAGIC_NUMBER 1024
1111

1212
#ifdef HIGH_PREC
1313
typedef double VALUETYPE ;
@@ -159,6 +159,7 @@ class DescrptSeAOp : public OpKernel {
159159

160160
OP_REQUIRES (context, (ntypes == int(sel_a.size())), errors::InvalidArgument ("number of types should match the length of sel array"));
161161
OP_REQUIRES (context, (ntypes == int(sel_r.size())), errors::InvalidArgument ("number of types should match the length of sel array"));
162+
OP_REQUIRES (context, (nnei <= 1024), errors::InvalidArgument ("Assert failed, max neighbor size of atom(nnei) " + std::to_string(nnei) + " is larger than 1024, which currently is not supported by deepmd-kit."));
162163

163164
// Create output tensors
164165
TensorShape descrpt_shape ;

source/op/descrpt_se_r_gpu.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class DescrptSeROp : public OpKernel {
148148
OP_REQUIRES (context, (9 == box_tensor.shape().dim_size(1)), errors::InvalidArgument ("number of box should be 9"));
149149
OP_REQUIRES (context, (ndescrpt == avg_tensor.shape().dim_size(1)), errors::InvalidArgument ("number of avg should be ndescrpt"));
150150
OP_REQUIRES (context, (ndescrpt == std_tensor.shape().dim_size(1)), errors::InvalidArgument ("number of std should be ndescrpt"));
151+
OP_REQUIRES (context, (nnei <= 1024), errors::InvalidArgument ("Assert failed, max neighbor size of atom(nnei) " + std::to_string(nnei) + " is larger than 1024, which currently is not supported by deepmd-kit."));
151152

152153
// Create output tensors
153154
TensorShape descrpt_shape ;

0 commit comments

Comments
 (0)