Update stubbed force calculation
Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
This commit is contained in:
parent
77a0774208
commit
706f1c38f2
@ -6,4 +6,4 @@ DATA_TYPE ?= DP
|
|||||||
DATA_LAYOUT ?= SOA
|
DATA_LAYOUT ?= SOA
|
||||||
|
|
||||||
#Feature options
|
#Feature options
|
||||||
OPTIONS += -DALIGNMENT=64
|
OPTIONS += -DALIGNMENT=64 -DLIKWID_PERFMON
|
||||||
|
@ -11,5 +11,7 @@ CFLAGS = -O3 -march=znver1 -ffast-math -funroll-loops # -fopenmp
|
|||||||
ASFLAGS = -masm=intel
|
ASFLAGS = -masm=intel
|
||||||
LFLAGS =
|
LFLAGS =
|
||||||
DEFINES = -D_GNU_SOURCE
|
DEFINES = -D_GNU_SOURCE
|
||||||
INCLUDES =
|
#INCLUDES =
|
||||||
LIBS = -lm
|
#LIBS = -lm
|
||||||
|
INCLUDES = $(LIKWID_INC)
|
||||||
|
LIBS = -lm $(LIKWID_LIB) -llikwid
|
||||||
|
@ -31,7 +31,8 @@ double computeForce(
|
|||||||
Parameter *param,
|
Parameter *param,
|
||||||
Atom *atom,
|
Atom *atom,
|
||||||
Neighbor *neighbor,
|
Neighbor *neighbor,
|
||||||
int profile)
|
int profile,
|
||||||
|
int ntimes)
|
||||||
{
|
{
|
||||||
int Nlocal = atom->Nlocal;
|
int Nlocal = atom->Nlocal;
|
||||||
int* neighs;
|
int* neighs;
|
||||||
@ -52,38 +53,40 @@ double computeForce(
|
|||||||
LIKWID_MARKER_START("force");
|
LIKWID_MARKER_START("force");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(int t = 0; t < ntimes; t++) {
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
for(int i = 0; i < Nlocal; i++) {
|
for(int i = 0; i < Nlocal; i++) {
|
||||||
neighs = &neighbor->neighbors[i * neighbor->maxneighs];
|
neighs = &neighbor->neighbors[i * neighbor->maxneighs];
|
||||||
int numneighs = neighbor->numneigh[i];
|
int numneighs = neighbor->numneigh[i];
|
||||||
MD_FLOAT xtmp = atom_x(i);
|
MD_FLOAT xtmp = atom_x(i);
|
||||||
MD_FLOAT ytmp = atom_y(i);
|
MD_FLOAT ytmp = atom_y(i);
|
||||||
MD_FLOAT ztmp = atom_z(i);
|
MD_FLOAT ztmp = atom_z(i);
|
||||||
|
|
||||||
MD_FLOAT fix = 0;
|
MD_FLOAT fix = 0;
|
||||||
MD_FLOAT fiy = 0;
|
MD_FLOAT fiy = 0;
|
||||||
MD_FLOAT fiz = 0;
|
MD_FLOAT fiz = 0;
|
||||||
|
|
||||||
for(int k = 0; k < numneighs; k++) {
|
for(int k = 0; k < numneighs; k++) {
|
||||||
int j = neighs[k];
|
int j = neighs[k];
|
||||||
MD_FLOAT delx = xtmp - atom_x(j);
|
MD_FLOAT delx = xtmp - atom_x(j);
|
||||||
MD_FLOAT dely = ytmp - atom_y(j);
|
MD_FLOAT dely = ytmp - atom_y(j);
|
||||||
MD_FLOAT delz = ztmp - atom_z(j);
|
MD_FLOAT delz = ztmp - atom_z(j);
|
||||||
MD_FLOAT rsq = delx * delx + dely * dely + delz * delz;
|
MD_FLOAT rsq = delx * delx + dely * dely + delz * delz;
|
||||||
|
|
||||||
if(rsq < cutforcesq) {
|
if(rsq < cutforcesq) {
|
||||||
MD_FLOAT sr2 = 1.0 / rsq;
|
MD_FLOAT sr2 = 1.0 / rsq;
|
||||||
MD_FLOAT sr6 = sr2 * sr2 * sr2 * sigma6;
|
MD_FLOAT sr6 = sr2 * sr2 * sr2 * sigma6;
|
||||||
MD_FLOAT force = 48.0 * sr6 * (sr6 - 0.5) * sr2 * epsilon;
|
MD_FLOAT force = 48.0 * sr6 * (sr6 - 0.5) * sr2 * epsilon;
|
||||||
fix += delx * force;
|
fix += delx * force;
|
||||||
fiy += dely * force;
|
fiy += dely * force;
|
||||||
fiz += delz * force;
|
fiz += delz * force;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fx[i] += fix;
|
fx[i] += fix;
|
||||||
fy[i] += fiy;
|
fy[i] += fiy;
|
||||||
fz[i] += fiz;
|
fz[i] += fiz;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(profile) {
|
if(profile) {
|
||||||
|
@ -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);
|
||||||
|
|
||||||
void init(Parameter *param)
|
void init(Parameter *param)
|
||||||
{
|
{
|
||||||
@ -205,7 +205,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, 1);
|
||||||
|
|
||||||
timer[FORCE] = 0.0;
|
timer[FORCE] = 0.0;
|
||||||
timer[NEIGH] = 0.0;
|
timer[NEIGH] = 0.0;
|
||||||
@ -221,7 +221,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, 1);
|
timer[FORCE] += computeForce(¶m, &atom, &neighbor, 1, 1);
|
||||||
finalIntegrate(¶m, &atom);
|
finalIntegrate(¶m, &atom);
|
||||||
|
|
||||||
if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) {
|
if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) {
|
||||||
|
14
src/stub.c
14
src/stub.c
@ -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);
|
||||||
|
|
||||||
void init(Parameter *param) {
|
void init(Parameter *param) {
|
||||||
param->epsilon = 1.0;
|
param->epsilon = 1.0;
|
||||||
@ -103,7 +103,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
initAtom(atom);
|
initAtom(atom);
|
||||||
|
|
||||||
DEBUG("Creating atoms...\n");
|
DEBUG("Creating atoms...\n");
|
||||||
const int atoms_per_unit_cell = 16;
|
const int atoms_per_unit_cell = 8;
|
||||||
|
|
||||||
for(int i = 0; i < param.nx; ++i) {
|
for(int i = 0; i < param.nx; ++i) {
|
||||||
for(int j = 0; j < param.ny; ++j) {
|
for(int j = 0; j < param.ny; ++j) {
|
||||||
@ -158,7 +158,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const double estim_volume = (double)(atom->Nlocal * 6 * sizeof(MD_FLOAT) + (atoms_per_unit_cell - 1 + 2) * sizeof(int)) / 1000.0;
|
const double estim_volume = (double)(atom->Nlocal * 6 * sizeof(MD_FLOAT) + atom->Nlocal * (atoms_per_unit_cell - 1 + 2) * sizeof(int)) / 1000.0;
|
||||||
printf("System size (unit cells): %dx%dx%d\n", param.nx, param.ny, param.nz);
|
printf("System size (unit cells): %dx%dx%d\n", param.nx, param.ny, param.nz);
|
||||||
printf("Atoms per unit cell: %d\n", atoms_per_unit_cell);
|
printf("Atoms per unit cell: %d\n", atoms_per_unit_cell);
|
||||||
printf("Total number of atoms: %d\n", atom->Nlocal);
|
printf("Total number of atoms: %d\n", atom->Nlocal);
|
||||||
@ -171,13 +171,9 @@ 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, 0);
|
computeForce(¶m, atom, &neighbor, 0, 1);
|
||||||
|
|
||||||
double T_accum = 0.0;
|
|
||||||
for(int i = 0; i < param.ntimes; i++) {
|
|
||||||
T_accum += computeForce(¶m, atom, &neighbor, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
double T_accum = computeForce(¶m, atom, &neighbor, 1, param.ntimes);
|
||||||
printf("Total time: %.4f, Time/force: %.4f\n", T_accum, T_accum / param.ntimes);
|
printf("Total time: %.4f, Time/force: %.4f\n", T_accum, T_accum / param.ntimes);
|
||||||
LIKWID_MARKER_CLOSE;
|
LIKWID_MARKER_CLOSE;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user