Fix more bugs. Enable optimization for CLANG.
This commit is contained in:
parent
dcee5f97f2
commit
b1f2e23696
@ -7,7 +7,7 @@ ANSI_CFLAGS += -std=c99
|
|||||||
ANSI_CFLAGS += -pedantic
|
ANSI_CFLAGS += -pedantic
|
||||||
ANSI_CFLAGS += -Wextra
|
ANSI_CFLAGS += -Wextra
|
||||||
|
|
||||||
CFLAGS = -O3 $(ANSI_CFLAGS) #-g
|
CFLAGS = -Ofast $(ANSI_CFLAGS) #-g
|
||||||
ASFLAGS = -masm=intel
|
ASFLAGS = -masm=intel
|
||||||
CXXFLAGS = $(CFLAGS)
|
CXXFLAGS = $(CFLAGS)
|
||||||
FCFLAGS =
|
FCFLAGS =
|
||||||
|
23
src/main.c
23
src/main.c
@ -68,10 +68,6 @@ void init(Parameter *param)
|
|||||||
param->mass = 1.0;
|
param->mass = 1.0;
|
||||||
param->dtforce = 0.5 * param->dt;
|
param->dtforce = 0.5 * param->dt;
|
||||||
param->every = 20;
|
param->every = 20;
|
||||||
double lattice = pow((4.0 / param->rho), (1.0 / 3.0));
|
|
||||||
param->xprd = param->nx * lattice;
|
|
||||||
param->yprd = param->ny * lattice;
|
|
||||||
param->zprd = param->nz * lattice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double setup(
|
double setup(
|
||||||
@ -80,6 +76,10 @@ double setup(
|
|||||||
Neighbor *neighbor)
|
Neighbor *neighbor)
|
||||||
{
|
{
|
||||||
double S, E;
|
double S, E;
|
||||||
|
double lattice = pow((4.0 / param->rho), (1.0 / 3.0));
|
||||||
|
param->xprd = param->nx * lattice;
|
||||||
|
param->yprd = param->ny * lattice;
|
||||||
|
param->zprd = param->nz * lattice;
|
||||||
|
|
||||||
S = getTimeStamp();
|
S = getTimeStamp();
|
||||||
initAtom(atom);
|
initAtom(atom);
|
||||||
@ -145,7 +145,7 @@ void finalIntegrate(Parameter *param, Atom *atom)
|
|||||||
|
|
||||||
double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor)
|
double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor)
|
||||||
{
|
{
|
||||||
int Nlocal = atom->Natoms;
|
int Nlocal = atom->Nlocal;
|
||||||
int* neighs;
|
int* neighs;
|
||||||
double cutforcesq = param->cutforce * param->cutforce;
|
double cutforcesq = param->cutforce * param->cutforce;
|
||||||
double sigma6 = param->sigma6;
|
double sigma6 = param->sigma6;
|
||||||
@ -204,11 +204,11 @@ void printAtomState(Atom *atom)
|
|||||||
printf("Atom counts: Natoms=%d Nlocal=%d Nghost=%d Nmax=%d\n",
|
printf("Atom counts: Natoms=%d Nlocal=%d Nghost=%d Nmax=%d\n",
|
||||||
atom->Natoms, atom->Nlocal, atom->Nghost, atom->Nmax);
|
atom->Natoms, atom->Nlocal, atom->Nghost, atom->Nmax);
|
||||||
|
|
||||||
int nall = atom->Nlocal + atom->Nghost;
|
/* int nall = atom->Nlocal + atom->Nghost; */
|
||||||
|
|
||||||
for (int i=0; i<nall; i++) {
|
/* for (int i=0; i<nall; i++) { */
|
||||||
printf("%d %f %f %f\n", i, atom->x[i], atom->y[i], atom->z[i]);
|
/* printf("%d %f %f %f\n", i, atom->x[i], atom->y[i], atom->z[i]); */
|
||||||
}
|
/* } */
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
@ -283,11 +283,12 @@ int main (int argc, char** argv)
|
|||||||
computeThermo(-1, ¶m, &atom);
|
computeThermo(-1, ¶m, &atom);
|
||||||
|
|
||||||
printf(HLINE);
|
printf(HLINE);
|
||||||
printf("System: %d atoms, Steps: %d\n", atom.Natoms, param.ntimes);
|
printf("System: %d atoms %d ghost atoms, Steps: %d\n", atom.Natoms, atom.Nghost, param.ntimes);
|
||||||
printf("TOTAL %.2fs FORCE %.2fs NEIGH %.2fs REST %.2fs\n",
|
printf("TOTAL %.2fs FORCE %.2fs NEIGH %.2fs REST %.2fs\n",
|
||||||
timer[TOTAL], timer[FORCE], timer[NEIGH], timer[TOTAL]-timer[FORCE]-timer[NEIGH]);
|
timer[TOTAL], timer[FORCE], timer[NEIGH], timer[TOTAL]-timer[FORCE]-timer[NEIGH]);
|
||||||
printf(HLINE);
|
printf(HLINE);
|
||||||
printf("Performance: %.2f million atom updates per second\n", 1e-6 * (double) (atom.Natoms * param.ntimes) / timer[TOTAL]);
|
printf("Performance: %.2f million atom updates per second\n",
|
||||||
|
1e-6 * (double) atom.Natoms * param.ntimes / timer[TOTAL]);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user