Skip to content

Commit a117ccc

Browse files
authored
Merge pull request brucefan1983#1339 from brucefan1983/box_speedup
box speedup
2 parents 6d82ea0 + 35f6ebc commit a117ccc

18 files changed

Lines changed: 33075 additions & 33017 deletions

src/force/nep.cu

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,10 @@ static __global__ void find_neighbor_list_large_box(
485485
continue;
486486
}
487487

488-
double x12double = g_x[n2] - x1;
489-
double y12double = g_y[n2] - y1;
490-
double z12double = g_z[n2] - z1;
491-
apply_mic(box, x12double, y12double, z12double);
492-
float x12 = float(x12double), y12 = float(y12double), z12 = float(z12double);
488+
float x12 = g_x[n2] - x1;
489+
float y12 = g_y[n2] - y1;
490+
float z12 = g_z[n2] - z1;
491+
apply_mic(box, x12, y12, z12);
493492
float d12_square = x12 * x12 + y12 * y12 + z12 * z12;
494493

495494
int t2 = g_type[n2];
@@ -549,11 +548,10 @@ static __global__ void find_descriptor(
549548
// get radial descriptors
550549
for (int i1 = 0; i1 < g_NN[n1]; ++i1) {
551550
int n2 = g_NL[n1 + N * i1];
552-
double x12double = g_x[n2] - x1;
553-
double y12double = g_y[n2] - y1;
554-
double z12double = g_z[n2] - z1;
555-
apply_mic(box, x12double, y12double, z12double);
556-
float x12 = float(x12double), y12 = float(y12double), z12 = float(z12double);
551+
float x12 = g_x[n2] - x1;
552+
float y12 = g_y[n2] - y1;
553+
float z12 = g_z[n2] - z1;
554+
apply_mic(box, x12, y12, z12);
557555
float d12 = sqrt(x12 * x12 + y12 * y12 + z12 * z12);
558556
float fc12;
559557
int t2 = g_type[n2];
@@ -579,11 +577,10 @@ static __global__ void find_descriptor(
579577
float s[NUM_OF_ABC] = {0.0f};
580578
for (int i1 = 0; i1 < g_NN_angular[n1]; ++i1) {
581579
int n2 = g_NL_angular[n1 + N * i1];
582-
double x12double = g_x[n2] - x1;
583-
double y12double = g_y[n2] - y1;
584-
double z12double = g_z[n2] - z1;
585-
apply_mic(box, x12double, y12double, z12double);
586-
float x12 = float(x12double), y12 = float(y12double), z12 = float(z12double);
580+
float x12 = g_x[n2] - x1;
581+
float y12 = g_y[n2] - y1;
582+
float z12 = g_z[n2] - z1;
583+
apply_mic(box, x12, y12, z12);
587584
float d12 = sqrt(x12 * x12 + y12 * y12 + z12 * z12);
588585
float fc12;
589586
int t2 = g_type[n2];
@@ -726,11 +723,11 @@ static __global__ void find_force_radial(
726723
for (int i1 = 0; i1 < g_NN[n1]; ++i1) {
727724
int n2 = g_NL[n1 + N * i1];
728725
int t2 = g_type[n2];
729-
double x12double = g_x[n2] - x1;
730-
double y12double = g_y[n2] - y1;
731-
double z12double = g_z[n2] - z1;
732-
apply_mic(box, x12double, y12double, z12double);
733-
float r12[3] = {float(x12double), float(y12double), float(z12double)};
726+
float x12 = g_x[n2] - x1;
727+
float y12 = g_y[n2] - y1;
728+
float z12 = g_z[n2] - z1;
729+
apply_mic(box, x12, y12, z12);
730+
float r12[3] = {x12, y12, z12};
734731
float d12 = sqrt(r12[0] * r12[0] + r12[1] * r12[1] + r12[2] * r12[2]);
735732
float d12inv = 1.0f / d12;
736733
float f12[3] = {0.0f};
@@ -838,11 +835,11 @@ static __global__ void find_partial_force_angular(
838835
for (int i1 = 0; i1 < g_NN_angular[n1]; ++i1) {
839836
int index = i1 * N + n1;
840837
int n2 = g_NL_angular[n1 + N * i1];
841-
double x12double = g_x[n2] - x1;
842-
double y12double = g_y[n2] - y1;
843-
double z12double = g_z[n2] - z1;
844-
apply_mic(box, x12double, y12double, z12double);
845-
float r12[3] = {float(x12double), float(y12double), float(z12double)};
838+
float x12 = g_x[n2] - x1;
839+
float y12 = g_y[n2] - y1;
840+
float z12 = g_z[n2] - z1;
841+
apply_mic(box, x12, y12, z12);
842+
float r12[3] = {x12, y12, z12};
846843
float d12 = sqrt(r12[0] * r12[0] + r12[1] * r12[1] + r12[2] * r12[2]);
847844
float f12[3] = {0.0f};
848845
float fc12, fcp12;
@@ -925,11 +922,11 @@ static __global__ void find_force_ZBL(
925922
float pow_zi = pow(float(zi), 0.23f);
926923
for (int i1 = 0; i1 < g_NN[n1]; ++i1) {
927924
int n2 = g_NL[n1 + N * i1];
928-
double x12double = g_x[n2] - x1;
929-
double y12double = g_y[n2] - y1;
930-
double z12double = g_z[n2] - z1;
931-
apply_mic(box, x12double, y12double, z12double);
932-
float r12[3] = {float(x12double), float(y12double), float(z12double)};
925+
float x12 = g_x[n2] - x1;
926+
float y12 = g_y[n2] - y1;
927+
float z12 = g_z[n2] - z1;
928+
apply_mic(box, x12, y12, z12);
929+
float r12[3] = {x12, y12, z12};
933930
float d12 = sqrt(r12[0] * r12[0] + r12[1] * r12[1] + r12[2] * r12[2]);
934931
float d12inv = 1.0f / d12;
935932
float f, fp;
@@ -1463,11 +1460,10 @@ static __global__ void find_descriptor(
14631460
// get radial descriptors
14641461
for (int i1 = 0; i1 < g_NN[n1]; ++i1) {
14651462
int n2 = g_NL[n1 + N * i1];
1466-
double x12double = g_x[n2] - x1;
1467-
double y12double = g_y[n2] - y1;
1468-
double z12double = g_z[n2] - z1;
1469-
apply_mic(box, x12double, y12double, z12double);
1470-
float x12 = float(x12double), y12 = float(y12double), z12 = float(z12double);
1463+
float x12 = g_x[n2] - x1;
1464+
float y12 = g_y[n2] - y1;
1465+
float z12 = g_z[n2] - z1;
1466+
apply_mic(box, x12, y12, z12);
14711467
float d12 = sqrt(x12 * x12 + y12 * y12 + z12 * z12);
14721468
float fc12;
14731469
int t2 = g_type[n2];
@@ -1492,11 +1488,10 @@ static __global__ void find_descriptor(
14921488
float s[NUM_OF_ABC] = {0.0f};
14931489
for (int i1 = 0; i1 < g_NN_angular[n1]; ++i1) {
14941490
int n2 = g_NL_angular[n1 + N * i1];
1495-
double x12double = g_x[n2] - x1;
1496-
double y12double = g_y[n2] - y1;
1497-
double z12double = g_z[n2] - z1;
1498-
apply_mic(box, x12double, y12double, z12double);
1499-
float x12 = float(x12double), y12 = float(y12double), z12 = float(z12double);
1491+
float x12 = g_x[n2] - x1;
1492+
float y12 = g_y[n2] - y1;
1493+
float z12 = g_z[n2] - z1;
1494+
apply_mic(box, x12, y12, z12);
15001495
float d12 = sqrt(x12 * x12 + y12 * y12 + z12 * z12);
15011496
float fc12;
15021497
int t2 = g_type[n2];

0 commit comments

Comments
 (0)