Merge branch 'master' of github.com:RRZE-HPC/MD-Bench
This commit is contained in:
75
src/main.c
75
src/main.c
@@ -39,14 +39,18 @@
|
||||
#include <thermo.h>
|
||||
#include <pbc.h>
|
||||
#include <timers.h>
|
||||
#include <eam.h>
|
||||
|
||||
#define HLINE "----------------------------------------------------------------------------\n"
|
||||
|
||||
extern double computeForce(Parameter*, Atom*, Neighbor*);
|
||||
extern double computeForceTracing(Parameter*, Atom*, Neighbor*, Stats*, int, int);
|
||||
extern double computeForceEam(Eam* eam, Atom *atom, Neighbor *neighbor, Stats *stats, int first_exec, int timestep);
|
||||
|
||||
void init(Parameter *param)
|
||||
{
|
||||
param->input_file = NULL;
|
||||
param->force_field = FF_LJ;
|
||||
param->epsilon = 1.0;
|
||||
param->sigma6 = 1.0;
|
||||
param->rho = 0.8442;
|
||||
@@ -68,6 +72,7 @@ void init(Parameter *param)
|
||||
|
||||
double setup(
|
||||
Parameter *param,
|
||||
Eam *eam,
|
||||
Atom *atom,
|
||||
Neighbor *neighbor,
|
||||
Stats *stats)
|
||||
@@ -79,6 +84,7 @@ double setup(
|
||||
param->zprd = param->nz * param->lattice;
|
||||
|
||||
S = getTimeStamp();
|
||||
if(param->force_field == FF_EAM) { initEam(eam, param->input_file, param->ntypes); }
|
||||
initAtom(atom);
|
||||
initNeighbor(neighbor, param);
|
||||
initPbc();
|
||||
@@ -147,16 +153,31 @@ void printAtomState(Atom *atom)
|
||||
printf("Atom counts: Natoms=%d Nlocal=%d Nghost=%d Nmax=%d\n",
|
||||
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++) { */
|
||||
/* printf("%d %f %f %f\n", i, atom->x[i], atom->y[i], atom->z[i]); */
|
||||
/* } */
|
||||
/* for (int i=0; i<nall; i++) { */
|
||||
/* printf("%d %f %f %f\n", i, atom->x[i], atom->y[i], atom->z[i]); */
|
||||
/* } */
|
||||
}
|
||||
|
||||
int main (int argc, char** argv)
|
||||
int str2ff(const char *string)
|
||||
{
|
||||
if(strncmp(string, "lj", 2) == 0) return FF_LJ;
|
||||
if(strncmp(string, "eam", 3) == 0) return FF_EAM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* ff2str(int ff)
|
||||
{
|
||||
if(ff == FF_LJ) { return "lj"; }
|
||||
if(ff == FF_EAM) { return "eam"; }
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
double timer[NUMTIMER];
|
||||
Eam eam;
|
||||
Atom atom;
|
||||
Neighbor neighbor;
|
||||
Stats stats;
|
||||
@@ -173,6 +194,19 @@ int main (int argc, char** argv)
|
||||
|
||||
for(int i = 0; i < argc; i++)
|
||||
{
|
||||
if((strcmp(argv[i], "-f") == 0))
|
||||
{
|
||||
if((param.force_field = str2ff(argv[++i])) < 0) {
|
||||
fprintf(stderr, "Invalid force field!\n");
|
||||
exit(-1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if((strcmp(argv[i], "-i") == 0))
|
||||
{
|
||||
param.input_file = strdup(argv[++i]);
|
||||
continue;
|
||||
}
|
||||
if((strcmp(argv[i], "-n") == 0) || (strcmp(argv[i], "--nsteps") == 0))
|
||||
{
|
||||
param.ntimes = atoi(argv[++i]);
|
||||
@@ -193,7 +227,7 @@ int main (int argc, char** argv)
|
||||
param.nz = atoi(argv[++i]);
|
||||
continue;
|
||||
}
|
||||
if((strcmp(argv[i], "-f") == 0))
|
||||
if((strcmp(argv[i], "--freq") == 0))
|
||||
{
|
||||
param.proc_freq = atof(argv[++i]);
|
||||
continue;
|
||||
@@ -202,21 +236,27 @@ int main (int argc, char** argv)
|
||||
{
|
||||
printf("MD Bench: A minimalistic re-implementation of miniMD\n");
|
||||
printf(HLINE);
|
||||
printf("-f <string>: force field (lj or eam), default lj\n");
|
||||
printf("-i <string>: input file for EAM\n");
|
||||
printf("-n / --nsteps <int>: set number of timesteps for simulation\n");
|
||||
printf("-nx/-ny/-nz <int>: set linear dimension of systembox in x/y/z direction\n");
|
||||
printf("-f <real>: processor frequency (GHz)\n");
|
||||
printf("--freq <real>: processor frequency (GHz)\n");
|
||||
printf(HLINE);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
setup(¶m, &atom, &neighbor, &stats);
|
||||
setup(¶m, &eam, &atom, &neighbor, &stats);
|
||||
computeThermo(0, ¶m, &atom);
|
||||
#if defined(MEM_TRACER) || defined(INDEX_TRACER) || defined(PRINT_STATS)
|
||||
computeForceTracing(¶m, &atom, &neighbor, &stats, 1, 0);
|
||||
if(param.force_field == FF_EAM) {
|
||||
computeForceEam(&eam, &atom, &neighbor, &stats, 1, 0);
|
||||
} else {
|
||||
#if defined(MEM_TRACER) || defined(INDEX_TRACER) || defined(COMPUTE_STATS)
|
||||
computeForceTracing(¶m, &atom, &neighbor, &stats, 1, 0);
|
||||
#else
|
||||
computeForce(¶m, &atom, &neighbor);
|
||||
computeForce(¶m, &atom, &neighbor);
|
||||
#endif
|
||||
}
|
||||
|
||||
timer[FORCE] = 0.0;
|
||||
timer[NEIGH] = 0.0;
|
||||
@@ -231,11 +271,15 @@ int main (int argc, char** argv)
|
||||
timer[NEIGH] += reneighbour(¶m, &atom, &neighbor);
|
||||
}
|
||||
|
||||
#if defined(MEM_TRACER) || defined(INDEX_TRACER) || defined(PRINT_STATS)
|
||||
timer[FORCE] += computeForceTracing(¶m, &atom, &neighbor, &stats, 0, n + 1);
|
||||
if(param.force_field == FF_EAM) {
|
||||
timer[FORCE] += computeForceEam(&eam, &atom, &neighbor, &stats, 0, n + 1);
|
||||
} else {
|
||||
#if defined(MEM_TRACER) || defined(INDEX_TRACER) || defined(COMPUTE_STATS)
|
||||
timer[FORCE] += computeForceTracing(¶m, &atom, &neighbor, &stats, 0, n + 1);
|
||||
#else
|
||||
timer[FORCE] += computeForce(¶m, &atom, &neighbor);
|
||||
timer[FORCE] += computeForce(¶m, &atom, &neighbor);
|
||||
#endif
|
||||
}
|
||||
finalIntegrate(¶m, &atom);
|
||||
|
||||
if(!((n + 1) % param.nstat) && (n+1) < param.ntimes) {
|
||||
@@ -247,6 +291,7 @@ int main (int argc, char** argv)
|
||||
computeThermo(-1, ¶m, &atom);
|
||||
|
||||
printf(HLINE);
|
||||
printf("Force field: %s\n", ff2str(param.force_field));
|
||||
printf("Data layout for positions: %s\n", POS_DATA_LAYOUT);
|
||||
#if PRECISION == 1
|
||||
printf("Using single precision floating point.\n");
|
||||
@@ -260,7 +305,7 @@ int main (int argc, char** argv)
|
||||
printf(HLINE);
|
||||
printf("Performance: %.2f million atom updates per second\n",
|
||||
1e-6 * (double) atom.Natoms * param.ntimes / timer[TOTAL]);
|
||||
#ifdef PRINT_STATS
|
||||
#ifdef COMPUTE_STATS
|
||||
displayStatistics(&atom, ¶m, &stats, timer);
|
||||
#endif
|
||||
LIKWID_MARKER_CLOSE;
|
||||
|
Reference in New Issue
Block a user