Provide trace output for all reneighboring steps

Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
This commit is contained in:
Rafael Ravedutti 2021-10-04 16:47:07 +02:00
parent 2889577a3b
commit 749c4d55ab
3 changed files with 33 additions and 19 deletions

View File

@ -32,11 +32,20 @@
#include <stdlib.h>
#endif
#ifndef TRACER_CONDITION
# define TRACER_CONDITION (!(timestep % every))
#endif
#ifdef MEM_TRACER
# define MEM_TRACER_INIT FILE *mem_tracer_fp; \
if(first_exec) { mem_tracer_fp = fopen("mem_tracer.out", "w"); }
# define MEM_TRACER_END if(first_exec) { fclose(mem_tracer_fp); }
# define MEM_TRACE(addr, op) if(first_exec) { fprintf(mem_tracer_fp, "%c: %p\n", op, (void *)(&(addr))); }
if(TRACER_CONDITION) { \
char mem_tracer_fn[128]; \
snprintf(mem_tracer_fn, sizeof mem_tracer_fn, "mem_tracer_%d.out", timestep); \
mem_tracer_fp = fopen(mem_tracer_fn, "w");
}
# define MEM_TRACER_END if(TRACER_CONDITION) { fclose(mem_tracer_fp); }
# define MEM_TRACE(addr, op) if(TRACER_CONDITION) { fprintf(mem_tracer_fp, "%c: %p\n", op, (void *)(&(addr))); }
#else
# define MEM_TRACER_INIT
# define MEM_TRACER_END
@ -49,11 +58,16 @@
# endif
# define INDEX_TRACER_INIT FILE *index_tracer_fp; \
if(first_exec) { index_tracer_fp = fopen("index_tracer.out", "w"); }
# define INDEX_TRACER_END if(first_exec) { fclose(index_tracer_fp); }
# define INDEX_TRACE_NATOMS(nl, ng, mn) if(first_exec) { fprintf(index_tracer_fp, "N: %d %d %d\n", nl, ng, mn); }
# define INDEX_TRACE_ATOM(a) if(first_exec) { fprintf(index_tracer_fp, "A: %d\n", a); }
# define INDEX_TRACE(l, e) if(first_exec) { \
if(TRACER_CONDITION) { \
char index_tracer_fn[128]; \
snprintf(index_tracer_fn, sizeof index_tracer_fn, "index_tracer_%d.out", timestep); \
index_tracer_fp = fopen(index_tracer_fn, "w"); \
}
# define INDEX_TRACER_END if(TRACER_CONDITION) { fclose(index_tracer_fp); }
# define INDEX_TRACE_NATOMS(nl, ng, mn) if(TRACER_CONDITION) { fprintf(index_tracer_fp, "N: %d %d %d\n", nl, ng, mn); }
# define INDEX_TRACE_ATOM(a) if(TRACER_CONDITION) { fprintf(index_tracer_fp, "A: %d\n", a); }
# define INDEX_TRACE(l, e) if(TRACER_CONDITION) { \
for(int __i = 0; __i < (e); __i += VECTOR_WIDTH) { \
int __e = (((e) - __i) < VECTOR_WIDTH) ? ((e) - __i) : VECTOR_WIDTH; \
fprintf(index_tracer_fp, "I: "); \
@ -64,7 +78,7 @@
} \
}
# define DIST_TRACE_SORT(l, e) if(first_exec) { \
# define DIST_TRACE_SORT(l, e) if(TRACER_CONDITION) { \
for(int __i = 0; __i < (e); __i += VECTOR_WIDTH) { \
int __e = (((e) - __i) < VECTOR_WIDTH) ? ((e) - __i) : VECTOR_WIDTH; \
if(__e > 1) { \
@ -81,7 +95,7 @@
} \
}
# define DIST_TRACE(l, e) if(first_exec) { \
# define DIST_TRACE(l, e) if(TRACER_CONDITION) { \
for(int __i = 0; __i < (e); __i += VECTOR_WIDTH) { \
int __e = (((e) - __i) < VECTOR_WIDTH) ? ((e) - __i) : VECTOR_WIDTH; \
if(__e > 1) { \
@ -104,7 +118,7 @@
# define DIST_TRACE(l, e)
#endif
double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor, int first_exec) {
double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor, int first_exec, int timestep, int every) {
MEM_TRACER_INIT;
INDEX_TRACER_INIT;
double S = getTimeStamp();
@ -152,9 +166,9 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor, int first_
for(int n = 0; n < nmax; n++) {
#endif
DIST_TRACE_SORT(neighs, numneighs);
//DIST_TRACE_SORT(neighs, numneighs);
INDEX_TRACE(neighs, numneighs);
DIST_TRACE(neighs, numneighs);
//DIST_TRACE(neighs, numneighs);
for(int k = 0; k < numneighs; k++) {
int j = neighs[k];

View File

@ -16,7 +16,7 @@
#define LATTICE_DISTANCE 10.0
#define NEIGH_DISTANCE 1.0
extern double computeForce(Parameter*, Atom*, Neighbor*, int);
extern double computeForce(Parameter*, Atom*, Neighbor*, int, int, int);
void init(Parameter *param) {
param->epsilon = 1.0;
@ -207,12 +207,12 @@ int main(int argc, const char *argv[]) {
DEBUG("Building neighbor lists...\n");
buildNeighbor(atom, &neighbor);
DEBUG("Computing forces...\n");
computeForce(&param, atom, &neighbor, 1);
computeForce(&param, atom, &neighbor, 1, 0, param.every);
double S, E;
S = getTimeStamp();
for(int i = 0; i < param.ntimes; i++) {
computeForce(&param, atom, &neighbor, 0);
computeForce(&param, atom, &neighbor, 0, param.every);
}
E = getTimeStamp();
double T_accum = E-S;

View File

@ -47,7 +47,7 @@ typedef enum {
NUMTIMER
} timertype;
extern double computeForce(Parameter*, Atom*, Neighbor*, int);
extern double computeForce(Parameter*, Atom*, Neighbor*, int, int, int);
void init(Parameter *param)
{
@ -206,7 +206,7 @@ int main (int argc, char** argv)
setup(&param, &atom, &neighbor);
computeThermo(0, &param, &atom);
computeForce(&param, &atom, &neighbor, 1);
computeForce(&param, &atom, &neighbor, 1, 0, param.every);
timer[FORCE] = 0.0;
timer[NEIGH] = 0.0;
@ -222,7 +222,7 @@ int main (int argc, char** argv)
timer[NEIGH] += reneighbour(&param, &atom, &neighbor);
}
timer[FORCE] += computeForce(&param, &atom, &neighbor, 0);
timer[FORCE] += computeForce(&param, &atom, &neighbor, 0, n + 1, param.every);
finalIntegrate(&param, &atom);
if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) {