Provide trace output for all reneighboring steps
Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
This commit is contained in:
parent
2889577a3b
commit
749c4d55ab
40
src/force.c
40
src/force.c
@ -32,11 +32,20 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TRACER_CONDITION
|
||||||
|
# define TRACER_CONDITION (!(timestep % every))
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MEM_TRACER
|
#ifdef MEM_TRACER
|
||||||
# define MEM_TRACER_INIT FILE *mem_tracer_fp; \
|
# define MEM_TRACER_INIT FILE *mem_tracer_fp; \
|
||||||
if(first_exec) { mem_tracer_fp = fopen("mem_tracer.out", "w"); }
|
if(TRACER_CONDITION) { \
|
||||||
# define MEM_TRACER_END if(first_exec) { fclose(mem_tracer_fp); }
|
char mem_tracer_fn[128]; \
|
||||||
# define MEM_TRACE(addr, op) if(first_exec) { fprintf(mem_tracer_fp, "%c: %p\n", op, (void *)(&(addr))); }
|
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
|
#else
|
||||||
# define MEM_TRACER_INIT
|
# define MEM_TRACER_INIT
|
||||||
# define MEM_TRACER_END
|
# define MEM_TRACER_END
|
||||||
@ -49,11 +58,16 @@
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define INDEX_TRACER_INIT FILE *index_tracer_fp; \
|
# define INDEX_TRACER_INIT FILE *index_tracer_fp; \
|
||||||
if(first_exec) { index_tracer_fp = fopen("index_tracer.out", "w"); }
|
if(TRACER_CONDITION) { \
|
||||||
# define INDEX_TRACER_END if(first_exec) { fclose(index_tracer_fp); }
|
char index_tracer_fn[128]; \
|
||||||
# define INDEX_TRACE_NATOMS(nl, ng, mn) if(first_exec) { fprintf(index_tracer_fp, "N: %d %d %d\n", nl, ng, mn); }
|
snprintf(index_tracer_fn, sizeof index_tracer_fn, "index_tracer_%d.out", timestep); \
|
||||||
# define INDEX_TRACE_ATOM(a) if(first_exec) { fprintf(index_tracer_fp, "A: %d\n", a); }
|
index_tracer_fp = fopen(index_tracer_fn, "w"); \
|
||||||
# define INDEX_TRACE(l, e) if(first_exec) { \
|
}
|
||||||
|
|
||||||
|
# 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) { \
|
for(int __i = 0; __i < (e); __i += VECTOR_WIDTH) { \
|
||||||
int __e = (((e) - __i) < VECTOR_WIDTH) ? ((e) - __i) : VECTOR_WIDTH; \
|
int __e = (((e) - __i) < VECTOR_WIDTH) ? ((e) - __i) : VECTOR_WIDTH; \
|
||||||
fprintf(index_tracer_fp, "I: "); \
|
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) { \
|
for(int __i = 0; __i < (e); __i += VECTOR_WIDTH) { \
|
||||||
int __e = (((e) - __i) < VECTOR_WIDTH) ? ((e) - __i) : VECTOR_WIDTH; \
|
int __e = (((e) - __i) < VECTOR_WIDTH) ? ((e) - __i) : VECTOR_WIDTH; \
|
||||||
if(__e > 1) { \
|
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) { \
|
for(int __i = 0; __i < (e); __i += VECTOR_WIDTH) { \
|
||||||
int __e = (((e) - __i) < VECTOR_WIDTH) ? ((e) - __i) : VECTOR_WIDTH; \
|
int __e = (((e) - __i) < VECTOR_WIDTH) ? ((e) - __i) : VECTOR_WIDTH; \
|
||||||
if(__e > 1) { \
|
if(__e > 1) { \
|
||||||
@ -104,7 +118,7 @@
|
|||||||
# define DIST_TRACE(l, e)
|
# define DIST_TRACE(l, e)
|
||||||
#endif
|
#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;
|
MEM_TRACER_INIT;
|
||||||
INDEX_TRACER_INIT;
|
INDEX_TRACER_INIT;
|
||||||
double S = getTimeStamp();
|
double S = getTimeStamp();
|
||||||
@ -152,9 +166,9 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor, int first_
|
|||||||
for(int n = 0; n < nmax; n++) {
|
for(int n = 0; n < nmax; n++) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DIST_TRACE_SORT(neighs, numneighs);
|
//DIST_TRACE_SORT(neighs, numneighs);
|
||||||
INDEX_TRACE(neighs, numneighs);
|
INDEX_TRACE(neighs, numneighs);
|
||||||
DIST_TRACE(neighs, numneighs);
|
//DIST_TRACE(neighs, numneighs);
|
||||||
|
|
||||||
for(int k = 0; k < numneighs; k++) {
|
for(int k = 0; k < numneighs; k++) {
|
||||||
int j = neighs[k];
|
int j = neighs[k];
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#define LATTICE_DISTANCE 10.0
|
#define LATTICE_DISTANCE 10.0
|
||||||
#define NEIGH_DISTANCE 1.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) {
|
void init(Parameter *param) {
|
||||||
param->epsilon = 1.0;
|
param->epsilon = 1.0;
|
||||||
@ -207,12 +207,12 @@ int main(int argc, const char *argv[]) {
|
|||||||
DEBUG("Building neighbor lists...\n");
|
DEBUG("Building neighbor lists...\n");
|
||||||
buildNeighbor(atom, &neighbor);
|
buildNeighbor(atom, &neighbor);
|
||||||
DEBUG("Computing forces...\n");
|
DEBUG("Computing forces...\n");
|
||||||
computeForce(¶m, atom, &neighbor, 1);
|
computeForce(¶m, atom, &neighbor, 1, 0, param.every);
|
||||||
|
|
||||||
double S, E;
|
double S, E;
|
||||||
S = getTimeStamp();
|
S = getTimeStamp();
|
||||||
for(int i = 0; i < param.ntimes; i++) {
|
for(int i = 0; i < param.ntimes; i++) {
|
||||||
computeForce(¶m, atom, &neighbor, 0);
|
computeForce(¶m, atom, &neighbor, 0, param.every);
|
||||||
}
|
}
|
||||||
E = getTimeStamp();
|
E = getTimeStamp();
|
||||||
double T_accum = E-S;
|
double T_accum = E-S;
|
||||||
|
@ -47,7 +47,7 @@ typedef enum {
|
|||||||
NUMTIMER
|
NUMTIMER
|
||||||
} timertype;
|
} timertype;
|
||||||
|
|
||||||
extern double computeForce(Parameter*, Atom*, Neighbor*, int);
|
extern double computeForce(Parameter*, Atom*, Neighbor*, int, int, int);
|
||||||
|
|
||||||
void init(Parameter *param)
|
void init(Parameter *param)
|
||||||
{
|
{
|
||||||
@ -206,7 +206,7 @@ int main (int argc, char** argv)
|
|||||||
|
|
||||||
setup(¶m, &atom, &neighbor);
|
setup(¶m, &atom, &neighbor);
|
||||||
computeThermo(0, ¶m, &atom);
|
computeThermo(0, ¶m, &atom);
|
||||||
computeForce(¶m, &atom, &neighbor, 1);
|
computeForce(¶m, &atom, &neighbor, 1, 0, param.every);
|
||||||
|
|
||||||
timer[FORCE] = 0.0;
|
timer[FORCE] = 0.0;
|
||||||
timer[NEIGH] = 0.0;
|
timer[NEIGH] = 0.0;
|
||||||
@ -222,7 +222,7 @@ int main (int argc, char** argv)
|
|||||||
timer[NEIGH] += reneighbour(¶m, &atom, &neighbor);
|
timer[NEIGH] += reneighbour(¶m, &atom, &neighbor);
|
||||||
}
|
}
|
||||||
|
|
||||||
timer[FORCE] += computeForce(¶m, &atom, &neighbor, 0);
|
timer[FORCE] += computeForce(¶m, &atom, &neighbor, 0, n + 1, param.every);
|
||||||
finalIntegrate(¶m, &atom);
|
finalIntegrate(¶m, &atom);
|
||||||
|
|
||||||
if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) {
|
if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) {
|
||||||
|
Loading…
Reference in New Issue
Block a user