Skip to content

Commit 9d65aa0

Browse files
authored
Merge pull request brucefan1983#912 from brucefan1983/neighbor-out-for-small-box
also output neighbor statistics for small boxes
2 parents 75b0ff8 + 70ebcb8 commit 9d65aa0

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/force/nep.cu

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,30 @@ void NEP::compute_small_box(
13661366
r12.data() + size_x12 * 5);
13671367
GPU_CHECK_KERNEL
13681368

1369+
static int num_calls = 0;
1370+
if (num_calls++ % 1000 == 0) {
1371+
std::vector<int> cpu_NN_radial(type.size());
1372+
std::vector<int> cpu_NN_angular(type.size());
1373+
NN_radial.copy_to_host(cpu_NN_radial.data());
1374+
NN_angular.copy_to_host(cpu_NN_angular.data());
1375+
int radial_actual = 0;
1376+
int angular_actual = 0;
1377+
for (int n = 0; n < N; ++n) {
1378+
if (radial_actual < cpu_NN_radial[n]) {
1379+
radial_actual = cpu_NN_radial[n];
1380+
}
1381+
if (angular_actual < cpu_NN_angular[n]) {
1382+
angular_actual = cpu_NN_angular[n];
1383+
}
1384+
}
1385+
std::ofstream output_file("neighbor.out", std::ios_base::app);
1386+
output_file << "Neighbor info at step " << num_calls - 1 << ": "
1387+
<< "radial(max=" << paramb.MN_radial << ",actual=" << radial_actual
1388+
<< "), angular(max=" << paramb.MN_angular << ",actual=" << angular_actual << ")."
1389+
<< std::endl;
1390+
output_file.close();
1391+
}
1392+
13691393
const bool is_polarizability = paramb.model_type == 2;
13701394
find_descriptor_small_box<<<grid_size, BLOCK_SIZE>>>(
13711395
paramb,
@@ -1939,6 +1963,30 @@ void NEP::compute_small_box(
19391963
r12.data() + size_x12 * 5);
19401964
GPU_CHECK_KERNEL
19411965

1966+
static int num_calls = 0;
1967+
if (num_calls++ % 1000 == 0) {
1968+
std::vector<int> cpu_NN_radial(type.size());
1969+
std::vector<int> cpu_NN_angular(type.size());
1970+
NN_radial.copy_to_host(cpu_NN_radial.data());
1971+
NN_angular.copy_to_host(cpu_NN_angular.data());
1972+
int radial_actual = 0;
1973+
int angular_actual = 0;
1974+
for (int n = 0; n < N; ++n) {
1975+
if (radial_actual < cpu_NN_radial[n]) {
1976+
radial_actual = cpu_NN_radial[n];
1977+
}
1978+
if (angular_actual < cpu_NN_angular[n]) {
1979+
angular_actual = cpu_NN_angular[n];
1980+
}
1981+
}
1982+
std::ofstream output_file("neighbor.out", std::ios_base::app);
1983+
output_file << "Neighbor info at step " << num_calls - 1 << ": "
1984+
<< "radial(max=" << paramb.MN_radial << ",actual=" << radial_actual
1985+
<< "), angular(max=" << paramb.MN_angular << ",actual=" << angular_actual << ")."
1986+
<< std::endl;
1987+
output_file.close();
1988+
}
1989+
19421990
find_descriptor_small_box<<<grid_size, BLOCK_SIZE>>>(
19431991
temperature,
19441992
paramb,

0 commit comments

Comments
 (0)