From 3f7edb5dbf9b29c7ffd2fab1da2829a30ff8d7c0 Mon Sep 17 00:00:00 2001 From: Rafael Ravedutti Date: Sat, 20 Mar 2021 18:32:50 +0100 Subject: [PATCH 1/7] Add support for AoS data layout Signed-off-by: Rafael Ravedutti --- Makefile | 3 +- src/atom.c | 10 +++-- src/includes/atom.h | 19 +++++++++ src/main.c | 21 +++++----- src/neighbor.c | 20 ++++------ src/pbc.c | 97 ++++++++++++++++++++++----------------------- 6 files changed, 93 insertions(+), 77 deletions(-) diff --git a/Makefile b/Makefile index 5370032..7727bfe 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ TARGET = MDBench-$(TAG) BUILD_DIR = ./$(TAG) SRC_DIR = ./src MAKE_DIR = ./ +FLAGS = #-DAOS Q ?= @ #DO NOT EDIT BELOW @@ -14,7 +15,7 @@ INCLUDES += -I./src/includes VPATH = $(SRC_DIR) ASM = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.s,$(wildcard $(SRC_DIR)/*.c)) OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o,$(wildcard $(SRC_DIR)/*.c)) -CPPFLAGS := $(CPPFLAGS) $(DEFINES) $(INCLUDES) +CPPFLAGS := $(CPPFLAGS) $(DEFINES) $(INCLUDES) ${FLAGS} ${TARGET}: $(BUILD_DIR) $(OBJ) diff --git a/src/atom.c b/src/atom.c index 313ffdc..f70bc35 100644 --- a/src/atom.c +++ b/src/atom.c @@ -111,9 +111,9 @@ void createAtom(Atom *atom, Parameter *param) growAtom(atom); } - atom->x[atom->Nlocal] = xtmp; - atom->y[atom->Nlocal] = ytmp; - atom->z[atom->Nlocal] = ztmp; + set_atom_x(atom, atom->Nlocal, xtmp); + set_atom_y(atom, atom->Nlocal, ytmp); + set_atom_z(atom, atom->Nlocal, ztmp); atom->vx[atom->Nlocal] = vxtmp; atom->vy[atom->Nlocal] = vytmp; atom->vz[atom->Nlocal] = vztmp; @@ -136,9 +136,13 @@ void growAtom(Atom *atom) int nold = atom->Nmax; atom->Nmax += DELTA; + #ifdef AOS + atom->x = (MD_FLOAT*) reallocate(atom->x, ALIGNMENT, atom->Nmax * sizeof(MD_FLOAT) * 3, nold * sizeof(MD_FLOAT) * 3); + #else atom->x = (MD_FLOAT*) reallocate(atom->x, ALIGNMENT, atom->Nmax * sizeof(MD_FLOAT), nold * sizeof(MD_FLOAT)); atom->y = (MD_FLOAT*) reallocate(atom->y, ALIGNMENT, atom->Nmax * sizeof(MD_FLOAT), nold * sizeof(MD_FLOAT)); atom->z = (MD_FLOAT*) reallocate(atom->z, ALIGNMENT, atom->Nmax * sizeof(MD_FLOAT), nold * sizeof(MD_FLOAT)); + #endif atom->vx = (MD_FLOAT*) reallocate(atom->vx, ALIGNMENT, atom->Nmax * sizeof(MD_FLOAT), nold * sizeof(MD_FLOAT)); atom->vy = (MD_FLOAT*) reallocate(atom->vy, ALIGNMENT, atom->Nmax * sizeof(MD_FLOAT), nold * sizeof(MD_FLOAT)); atom->vz = (MD_FLOAT*) reallocate(atom->vz, ALIGNMENT, atom->Nmax * sizeof(MD_FLOAT), nold * sizeof(MD_FLOAT)); diff --git a/src/includes/atom.h b/src/includes/atom.h index 97e0429..016896f 100644 --- a/src/includes/atom.h +++ b/src/includes/atom.h @@ -35,4 +35,23 @@ typedef struct { extern void initAtom(Atom*); extern void createAtom(Atom*, Parameter*); extern void growAtom(Atom*); + +#ifdef AOS +inline const char *posDataLayout() { return "AoS"; } +inline void set_atom_x(Atom *atom, int i, MD_FLOAT x) { atom->x[i * 3 + 0] = x; } +inline void set_atom_y(Atom *atom, int i, MD_FLOAT y) { atom->x[i * 3 + 1] = y; } +inline void set_atom_z(Atom *atom, int i, MD_FLOAT z) { atom->x[i * 3 + 2] = z; } +inline MD_FLOAT get_atom_x(Atom *atom, int i) { return atom->x[i * 3 + 0]; } +inline MD_FLOAT get_atom_y(Atom *atom, int i) { return atom->x[i * 3 + 1]; } +inline MD_FLOAT get_atom_z(Atom *atom, int i) { return atom->x[i * 3 + 2]; } +#else +inline const char *posDataLayout() { return "SoA"; } +inline void set_atom_x(Atom *atom, int i, MD_FLOAT x) { atom->x[i] = x; } +inline void set_atom_y(Atom *atom, int i, MD_FLOAT y) { atom->y[i] = y; } +inline void set_atom_z(Atom *atom, int i, MD_FLOAT z) { atom->z[i] = z; } +inline MD_FLOAT get_atom_x(Atom *atom, int i) { return atom->x[i]; } +inline MD_FLOAT get_atom_y(Atom *atom, int i) { return atom->y[i]; } +inline MD_FLOAT get_atom_z(Atom *atom, int i) { return atom->z[i]; } +#endif + #endif diff --git a/src/main.c b/src/main.c index 7fb68d1..8e507b7 100644 --- a/src/main.c +++ b/src/main.c @@ -116,7 +116,6 @@ double reneighbour( void initialIntegrate(Parameter *param, Atom *atom) { - MD_FLOAT* x = atom->x; MD_FLOAT* y = atom->y; MD_FLOAT* z = atom->z; MD_FLOAT* fx = atom->fx; MD_FLOAT* fy = atom->fy; MD_FLOAT* fz = atom->fz; MD_FLOAT* vx = atom->vx; MD_FLOAT* vy = atom->vy; MD_FLOAT* vz = atom->vz; @@ -124,9 +123,9 @@ void initialIntegrate(Parameter *param, Atom *atom) vx[i] += param->dtforce * fx[i]; vy[i] += param->dtforce * fy[i]; vz[i] += param->dtforce * fz[i]; - x[i] += param->dt * vx[i]; - y[i] += param->dt * vy[i]; - z[i] += param->dt * vz[i]; + set_atom_x(atom, i, get_atom_x(atom, i) + param->dt * vx[i]); + set_atom_y(atom, i, get_atom_y(atom, i) + param->dt * vy[i]); + set_atom_z(atom, i, get_atom_z(atom, i) + param->dt * vz[i]); } } @@ -149,7 +148,6 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor) MD_FLOAT cutforcesq = param->cutforce * param->cutforce; MD_FLOAT sigma6 = param->sigma6; MD_FLOAT epsilon = param->epsilon; - MD_FLOAT* x = atom->x; MD_FLOAT* y = atom->y; MD_FLOAT* z = atom->z; MD_FLOAT* fx = atom->fx; MD_FLOAT* fy = atom->fy; MD_FLOAT* fz = atom->fz; MD_FLOAT S, E; @@ -166,9 +164,9 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor) for(int i = 0; i < Nlocal; i++) { neighs = &neighbor->neighbors[i * neighbor->maxneighs]; int numneighs = neighbor->numneigh[i]; - MD_FLOAT xtmp = x[i]; - MD_FLOAT ytmp = y[i]; - MD_FLOAT ztmp = z[i]; + MD_FLOAT xtmp = get_atom_x(atom, i); + MD_FLOAT ytmp = get_atom_y(atom, i); + MD_FLOAT ztmp = get_atom_z(atom, i); MD_FLOAT fix = 0; MD_FLOAT fiy = 0; @@ -176,9 +174,9 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor) for(int k = 0; k < numneighs; k++) { int j = neighs[k]; - MD_FLOAT delx = xtmp - x[j]; - MD_FLOAT dely = ytmp - y[j]; - MD_FLOAT delz = ztmp - z[j]; + MD_FLOAT delx = xtmp - get_atom_x(atom, j); + MD_FLOAT dely = ytmp - get_atom_y(atom, j); + MD_FLOAT delz = ztmp - get_atom_z(atom, j); MD_FLOAT rsq = delx * delx + dely * dely + delz * delz; if(rsq < cutforcesq) { @@ -293,6 +291,7 @@ int main (int argc, char** argv) computeThermo(-1, ¶m, &atom); printf(HLINE); + printf("Data layout for positions: %s\n", posDataLayout()); #if PRECISION == 1 printf("Using single precision floating point.\n"); #else diff --git a/src/neighbor.c b/src/neighbor.c index 7460efb..fc80909 100644 --- a/src/neighbor.c +++ b/src/neighbor.c @@ -184,9 +184,6 @@ void buildNeighbor(Atom *atom, Neighbor *neighbor) /* bin local & ghost atoms */ binatoms(atom); int resize = 1; - MD_FLOAT* x = atom->x; - MD_FLOAT* y = atom->y; - MD_FLOAT* z = atom->z; /* loop over each atom, storing neighbors */ while(resize) { @@ -196,9 +193,9 @@ void buildNeighbor(Atom *atom, Neighbor *neighbor) for(int i = 0; i < atom->Nlocal; i++) { int* neighptr = &(neighbor->neighbors[i * neighbor->maxneighs]); int n = 0; - MD_FLOAT xtmp = x[i]; - MD_FLOAT ytmp = y[i]; - MD_FLOAT ztmp = z[i]; + MD_FLOAT xtmp = get_atom_x(atom, i); + MD_FLOAT ytmp = get_atom_y(atom, i); + MD_FLOAT ztmp = get_atom_z(atom, i); int ibin = coord2bin(xtmp, ytmp, ztmp); for(int k = 0; k < nstencil; k++) { @@ -212,9 +209,9 @@ void buildNeighbor(Atom *atom, Neighbor *neighbor) continue; } - MD_FLOAT delx = xtmp - x[j]; - MD_FLOAT dely = ytmp - y[j]; - MD_FLOAT delz = ztmp - z[j]; + MD_FLOAT delx = xtmp - get_atom_x(atom, j); + MD_FLOAT dely = ytmp - get_atom_y(atom, j); + MD_FLOAT delz = ztmp - get_atom_z(atom, j); MD_FLOAT rsq = delx * delx + dely * dely + delz * delz; if( rsq <= cutneighsq ) { @@ -309,9 +306,6 @@ int coord2bin(MD_FLOAT xin, MD_FLOAT yin, MD_FLOAT zin) void binatoms(Atom *atom) { int nall = atom->Nlocal + atom->Nghost; - MD_FLOAT* x = atom->x; - MD_FLOAT* y = atom->y; - MD_FLOAT* z = atom->z; int resize = 1; while(resize > 0) { @@ -322,7 +316,7 @@ void binatoms(Atom *atom) } for(int i = 0; i < nall; i++) { - int ibin = coord2bin(x[i], y[i], z[i]); + int ibin = coord2bin(get_atom_x(atom, i), get_atom_y(atom, i), get_atom_z(atom, i)); if(bincount[ibin] < atoms_per_bin) { int ac = bincount[ibin]++; diff --git a/src/pbc.c b/src/pbc.c index 54ef7f8..7631e16 100644 --- a/src/pbc.c +++ b/src/pbc.c @@ -48,17 +48,14 @@ void initPbc() void updatePbc(Atom *atom, Parameter *param) { int nlocal = atom->Nlocal; - MD_FLOAT* x = atom->x; - MD_FLOAT* y = atom->y; - MD_FLOAT* z = atom->z; MD_FLOAT xprd = param->xprd; MD_FLOAT yprd = param->yprd; MD_FLOAT zprd = param->zprd; for(int i = 0; i < atom->Nghost; i++) { - x[nlocal + i] = x[BorderMap[i]] + PBCx[i] * xprd; - y[nlocal + i] = y[BorderMap[i]] + PBCy[i] * yprd; - z[nlocal + i] = z[BorderMap[i]] + PBCz[i] * zprd; + set_atom_x(atom, nlocal + i, get_atom_x(atom, BorderMap[i]) + PBCx[i] * xprd); + set_atom_y(atom, nlocal + i, get_atom_y(atom, BorderMap[i]) + PBCy[i] * yprd); + set_atom_z(atom, nlocal + i, get_atom_z(atom, BorderMap[i]) + PBCz[i] * zprd); } } @@ -66,31 +63,31 @@ void updatePbc(Atom *atom, Parameter *param) * to periodic boundary conditions */ void updateAtomsPbc(Atom *atom, Parameter *param) { - MD_FLOAT* x = atom->x; - MD_FLOAT* y = atom->y; - MD_FLOAT* z = atom->z; MD_FLOAT xprd = param->xprd; MD_FLOAT yprd = param->yprd; MD_FLOAT zprd = param->zprd; for(int i = 0; i < atom->Nlocal; i++) { + MD_FLOAT x = get_atom_x(atom, i); + MD_FLOAT y = get_atom_y(atom, i); + MD_FLOAT z = get_atom_z(atom, i); - if(x[i] < 0.0) { - x[i] += xprd; - } else if(x[i] >= xprd) { - x[i] -= xprd; + if(x < 0.0) { + set_atom_x(atom, i, x + xprd); + } else if(x >= xprd) { + set_atom_x(atom, i, x - xprd); } - if(y[i] < 0.0) { - y[i] += yprd; - } else if(y[i] >= yprd) { - y[i] -= yprd; + if(y < 0.0) { + set_atom_y(atom, i, y + yprd); + } else if(y >= yprd) { + set_atom_y(atom, i, y - yprd); } - if(z[i] < 0.0) { - z[i] += zprd; - } else if(z[i] >= zprd) { - z[i] -= zprd; + if(z < 0.0) { + set_atom_z(atom, i, z + zprd); + } else if(z >= zprd) { + set_atom_z(atom, i, z - zprd); } } } @@ -102,7 +99,6 @@ void updateAtomsPbc(Atom *atom, Parameter *param) #define ADDGHOST(dx,dy,dz) Nghost++; BorderMap[Nghost] = i; PBCx[Nghost] = dx; PBCy[Nghost] = dy; PBCz[Nghost] = dz; void setupPbc(Atom *atom, Parameter *param) { - MD_FLOAT* x = atom->x; MD_FLOAT* y = atom->y; MD_FLOAT* z = atom->z; MD_FLOAT xprd = param->xprd; MD_FLOAT yprd = param->yprd; MD_FLOAT zprd = param->zprd; @@ -113,42 +109,45 @@ void setupPbc(Atom *atom, Parameter *param) if (atom->Nlocal + Nghost + 7 >= atom->Nmax) { growAtom(atom); - x = atom->x; y = atom->y; z = atom->z; } if (Nghost + 7 >= NmaxGhost) { growPbc(); } + MD_FLOAT x = get_atom_x(atom, i); + MD_FLOAT y = get_atom_y(atom, i); + MD_FLOAT z = get_atom_z(atom, i); + /* Setup ghost atoms */ /* 6 planes */ - if (x[i] < Cutneigh) { ADDGHOST(+1,0,0); } - if (x[i] >= (xprd-Cutneigh)) { ADDGHOST(-1,0,0); } - if (y[i] < Cutneigh) { ADDGHOST(0,+1,0); } - if (y[i] >= (yprd-Cutneigh)) { ADDGHOST(0,-1,0); } - if (z[i] < Cutneigh) { ADDGHOST(0,0,+1); } - if (z[i] >= (zprd-Cutneigh)) { ADDGHOST(0,0,-1); } + if (x < Cutneigh) { ADDGHOST(+1,0,0); } + if (x >= (xprd-Cutneigh)) { ADDGHOST(-1,0,0); } + if (y < Cutneigh) { ADDGHOST(0,+1,0); } + if (y >= (yprd-Cutneigh)) { ADDGHOST(0,-1,0); } + if (z < Cutneigh) { ADDGHOST(0,0,+1); } + if (z >= (zprd-Cutneigh)) { ADDGHOST(0,0,-1); } /* 8 corners */ - if (x[i] < Cutneigh && y[i] < Cutneigh && z[i] < Cutneigh) { ADDGHOST(+1,+1,+1); } - if (x[i] < Cutneigh && y[i] >= (yprd-Cutneigh) && z[i] < Cutneigh) { ADDGHOST(+1,-1,+1); } - if (x[i] < Cutneigh && y[i] >= Cutneigh && z[i] >= (zprd-Cutneigh)) { ADDGHOST(+1,+1,-1); } - if (x[i] < Cutneigh && y[i] >= (yprd-Cutneigh) && z[i] >= (zprd-Cutneigh)) { ADDGHOST(+1,-1,-1); } - if (x[i] >= (xprd-Cutneigh) && y[i] < Cutneigh && z[i] < Cutneigh) { ADDGHOST(-1,+1,+1); } - if (x[i] >= (xprd-Cutneigh) && y[i] >= (yprd-Cutneigh) && z[i] < Cutneigh) { ADDGHOST(-1,-1,+1); } - if (x[i] >= (xprd-Cutneigh) && y[i] < Cutneigh && z[i] >= (zprd-Cutneigh)) { ADDGHOST(-1,+1,-1); } - if (x[i] >= (xprd-Cutneigh) && y[i] >= (yprd-Cutneigh) && z[i] >= (zprd-Cutneigh)) { ADDGHOST(-1,-1,-1); } + if (x < Cutneigh && y < Cutneigh && z < Cutneigh) { ADDGHOST(+1,+1,+1); } + if (x < Cutneigh && y >= (yprd-Cutneigh) && z < Cutneigh) { ADDGHOST(+1,-1,+1); } + if (x < Cutneigh && y >= Cutneigh && z >= (zprd-Cutneigh)) { ADDGHOST(+1,+1,-1); } + if (x < Cutneigh && y >= (yprd-Cutneigh) && z >= (zprd-Cutneigh)) { ADDGHOST(+1,-1,-1); } + if (x >= (xprd-Cutneigh) && y < Cutneigh && z < Cutneigh) { ADDGHOST(-1,+1,+1); } + if (x >= (xprd-Cutneigh) && y >= (yprd-Cutneigh) && z < Cutneigh) { ADDGHOST(-1,-1,+1); } + if (x >= (xprd-Cutneigh) && y < Cutneigh && z >= (zprd-Cutneigh)) { ADDGHOST(-1,+1,-1); } + if (x >= (xprd-Cutneigh) && y >= (yprd-Cutneigh) && z >= (zprd-Cutneigh)) { ADDGHOST(-1,-1,-1); } /* 12 edges */ - if (x[i] < Cutneigh && z[i] < Cutneigh) { ADDGHOST(+1,0,+1); } - if (x[i] < Cutneigh && z[i] >= (zprd-Cutneigh)) { ADDGHOST(+1,0,-1); } - if (x[i] >= (xprd-Cutneigh) && z[i] < Cutneigh) { ADDGHOST(-1,0,+1); } - if (x[i] >= (xprd-Cutneigh) && z[i] >= (zprd-Cutneigh)) { ADDGHOST(-1,0,-1); } - if (y[i] < Cutneigh && z[i] < Cutneigh) { ADDGHOST(0,+1,+1); } - if (y[i] < Cutneigh && z[i] >= (zprd-Cutneigh)) { ADDGHOST(0,+1,-1); } - if (y[i] >= (yprd-Cutneigh) && z[i] < Cutneigh) { ADDGHOST(0,-1,+1); } - if (y[i] >= (yprd-Cutneigh) && z[i] >= (zprd-Cutneigh)) { ADDGHOST(0,-1,-1); } - if (y[i] < Cutneigh && x[i] < Cutneigh) { ADDGHOST(+1,+1,0); } - if (y[i] < Cutneigh && x[i] >= (xprd-Cutneigh)) { ADDGHOST(-1,+1,0); } - if (y[i] >= (yprd-Cutneigh) && x[i] < Cutneigh) { ADDGHOST(+1,-1,0); } - if (y[i] >= (yprd-Cutneigh) && x[i] >= (xprd-Cutneigh)) { ADDGHOST(-1,-1,0); } + if (x < Cutneigh && z < Cutneigh) { ADDGHOST(+1,0,+1); } + if (x < Cutneigh && z >= (zprd-Cutneigh)) { ADDGHOST(+1,0,-1); } + if (x >= (xprd-Cutneigh) && z < Cutneigh) { ADDGHOST(-1,0,+1); } + if (x >= (xprd-Cutneigh) && z >= (zprd-Cutneigh)) { ADDGHOST(-1,0,-1); } + if (y < Cutneigh && z < Cutneigh) { ADDGHOST(0,+1,+1); } + if (y < Cutneigh && z >= (zprd-Cutneigh)) { ADDGHOST(0,+1,-1); } + if (y >= (yprd-Cutneigh) && z < Cutneigh) { ADDGHOST(0,-1,+1); } + if (y >= (yprd-Cutneigh) && z >= (zprd-Cutneigh)) { ADDGHOST(0,-1,-1); } + if (y < Cutneigh && x < Cutneigh) { ADDGHOST(+1,+1,0); } + if (y < Cutneigh && x >= (xprd-Cutneigh)) { ADDGHOST(-1,+1,0); } + if (y >= (yprd-Cutneigh) && x < Cutneigh) { ADDGHOST(+1,-1,0); } + if (y >= (yprd-Cutneigh) && x >= (xprd-Cutneigh)) { ADDGHOST(-1,-1,0); } } // increase by one to make it the ghost atom count atom->Nghost = Nghost + 1; From cb0ae2b0bb8810fd8cfadabf4b321b5889b366de Mon Sep 17 00:00:00 2001 From: Rafael Ravedutti Date: Mon, 22 Mar 2021 21:51:47 +0100 Subject: [PATCH 2/7] Replace inline calls by macros Signed-off-by: Rafael Ravedutti --- src/includes/atom.h | 27 ++++++++++++++++----------- src/main.c | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/includes/atom.h b/src/includes/atom.h index 016896f..72fce88 100644 --- a/src/includes/atom.h +++ b/src/includes/atom.h @@ -37,21 +37,26 @@ extern void createAtom(Atom*, Parameter*); extern void growAtom(Atom*); #ifdef AOS -inline const char *posDataLayout() { return "AoS"; } +#define POS_DATA_LAYOUT "AoS" +/* FIXME: these macros are resulting in segfault +#define set_atom_x(atom, i, v) (atom->x[i * 3 + 0] = v) +#define set_atom_y(atom, i, v) (atom->x[i * 3 + 1] = v) +#define set_atom_z(atom, i, v) (atom->x[i * 3 + 2] = v) +*/ inline void set_atom_x(Atom *atom, int i, MD_FLOAT x) { atom->x[i * 3 + 0] = x; } inline void set_atom_y(Atom *atom, int i, MD_FLOAT y) { atom->x[i * 3 + 1] = y; } inline void set_atom_z(Atom *atom, int i, MD_FLOAT z) { atom->x[i * 3 + 2] = z; } -inline MD_FLOAT get_atom_x(Atom *atom, int i) { return atom->x[i * 3 + 0]; } -inline MD_FLOAT get_atom_y(Atom *atom, int i) { return atom->x[i * 3 + 1]; } -inline MD_FLOAT get_atom_z(Atom *atom, int i) { return atom->x[i * 3 + 2]; } +#define get_atom_x(atom, i) (atom->x[i * 3 + 0]) +#define get_atom_y(atom, i) (atom->x[i * 3 + 1]) +#define get_atom_z(atom, i) (atom->x[i * 3 + 2]) #else -inline const char *posDataLayout() { return "SoA"; } -inline void set_atom_x(Atom *atom, int i, MD_FLOAT x) { atom->x[i] = x; } -inline void set_atom_y(Atom *atom, int i, MD_FLOAT y) { atom->y[i] = y; } -inline void set_atom_z(Atom *atom, int i, MD_FLOAT z) { atom->z[i] = z; } -inline MD_FLOAT get_atom_x(Atom *atom, int i) { return atom->x[i]; } -inline MD_FLOAT get_atom_y(Atom *atom, int i) { return atom->y[i]; } -inline MD_FLOAT get_atom_z(Atom *atom, int i) { return atom->z[i]; } +#define POS_DATA_LAYOUT "SoA" +#define set_atom_x(atom, i, v) (atom->x[i] = v) +#define set_atom_y(atom, i, v) (atom->y[i] = v) +#define set_atom_z(atom, i, v) (atom->z[i] = v) +#define get_atom_x(atom, i) (atom->x[i]) +#define get_atom_y(atom, i) (atom->y[i]) +#define get_atom_z(atom, i) (atom->z[i]) #endif #endif diff --git a/src/main.c b/src/main.c index 8e507b7..27a3f4f 100644 --- a/src/main.c +++ b/src/main.c @@ -291,7 +291,7 @@ int main (int argc, char** argv) computeThermo(-1, ¶m, &atom); printf(HLINE); - printf("Data layout for positions: %s\n", posDataLayout()); + printf("Data layout for positions: %s\n", POS_DATA_LAYOUT); #if PRECISION == 1 printf("Using single precision floating point.\n"); #else From 6679b6c8aa1e8cc3bc917bf0e794aa1eaba9634b Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Tue, 23 Mar 2021 09:26:41 +0100 Subject: [PATCH 3/7] Simplify macros for data structure access. Still segvaults for AoS. --- Makefile | 2 +- include_CLANG.mk | 6 +++--- src/atom.c | 12 +++++++----- src/includes/atom.h | 25 +++++++------------------ src/main.c | 18 +++++++++--------- src/neighbor.c | 16 ++++++++-------- src/pbc.c | 30 +++++++++++++++--------------- 7 files changed, 50 insertions(+), 59 deletions(-) diff --git a/Makefile b/Makefile index 7727bfe..4275bf1 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ TARGET = MDBench-$(TAG) BUILD_DIR = ./$(TAG) SRC_DIR = ./src MAKE_DIR = ./ -FLAGS = #-DAOS +FLAGS = -DAOS Q ?= @ #DO NOT EDIT BELOW diff --git a/include_CLANG.mk b/include_CLANG.mk index 68e0076..93c499c 100644 --- a/include_CLANG.mk +++ b/include_CLANG.mk @@ -1,5 +1,5 @@ CC = cc -CXX = cc +CXX = gcc LINKER = $(CC) ANSI_CFLAGS = -ansi @@ -7,11 +7,11 @@ ANSI_CFLAGS += -std=c99 ANSI_CFLAGS += -pedantic ANSI_CFLAGS += -Wextra -CFLAGS = -Ofast $(ANSI_CFLAGS) -Xpreprocessor -fopenmp #-g +CFLAGS = -Ofast $(ANSI_CFLAGS) -g #-Xpreprocessor -fopenmp -g ASFLAGS = -masm=intel CXXFLAGS = $(CFLAGS) FCFLAGS = LFLAGS = DEFINES = -D_GNU_SOURCE -DALIGNMENT=64 -DPRECISION=2 INCLUDES = -LIBS = -lomp +LIBS = #-lomp diff --git a/src/atom.c b/src/atom.c index f70bc35..687de55 100644 --- a/src/atom.c +++ b/src/atom.c @@ -1,8 +1,10 @@ /* * ======================================================================================= * - * Author: Jan Eitzinger (je), jan.eitzinger@fau.de - * Copyright (c) 2020 RRZE, University Erlangen-Nuremberg + * Authors: Jan Eitzinger (je), jan.eitzinger@fau.de + * Rafael Ravedutti (rr), rafaelravedutti@gmail.com + * + * Copyright (c) 2021 RRZE, University Erlangen-Nuremberg * * This file is part of MD-Bench. * @@ -111,9 +113,9 @@ void createAtom(Atom *atom, Parameter *param) growAtom(atom); } - set_atom_x(atom, atom->Nlocal, xtmp); - set_atom_y(atom, atom->Nlocal, ytmp); - set_atom_z(atom, atom->Nlocal, ztmp); + atom_x(atom->Nlocal) = xtmp; + atom_y(atom->Nlocal) = ytmp; + atom_z(atom->Nlocal) = ztmp; atom->vx[atom->Nlocal] = vxtmp; atom->vy[atom->Nlocal] = vytmp; atom->vz[atom->Nlocal] = vztmp; diff --git a/src/includes/atom.h b/src/includes/atom.h index 72fce88..abc425e 100644 --- a/src/includes/atom.h +++ b/src/includes/atom.h @@ -2,7 +2,7 @@ * ======================================================================================= * * Author: Jan Eitzinger (je), jan.eitzinger@fau.de - * Copyright (c) 2020 RRZE, University Erlangen-Nuremberg + * Copyright (c) 2021 RRZE, University Erlangen-Nuremberg * * This file is part of MD-Bench. * @@ -38,25 +38,14 @@ extern void growAtom(Atom*); #ifdef AOS #define POS_DATA_LAYOUT "AoS" -/* FIXME: these macros are resulting in segfault -#define set_atom_x(atom, i, v) (atom->x[i * 3 + 0] = v) -#define set_atom_y(atom, i, v) (atom->x[i * 3 + 1] = v) -#define set_atom_z(atom, i, v) (atom->x[i * 3 + 2] = v) -*/ -inline void set_atom_x(Atom *atom, int i, MD_FLOAT x) { atom->x[i * 3 + 0] = x; } -inline void set_atom_y(Atom *atom, int i, MD_FLOAT y) { atom->x[i * 3 + 1] = y; } -inline void set_atom_z(Atom *atom, int i, MD_FLOAT z) { atom->x[i * 3 + 2] = z; } -#define get_atom_x(atom, i) (atom->x[i * 3 + 0]) -#define get_atom_y(atom, i) (atom->x[i * 3 + 1]) -#define get_atom_z(atom, i) (atom->x[i * 3 + 2]) +#define atom_x(i) atom->x[i * 3 + 0] +#define atom_y(i) atom->x[i * 3 + 1] +#define atom_z(i) atom->x[i * 3 + 2] #else #define POS_DATA_LAYOUT "SoA" -#define set_atom_x(atom, i, v) (atom->x[i] = v) -#define set_atom_y(atom, i, v) (atom->y[i] = v) -#define set_atom_z(atom, i, v) (atom->z[i] = v) -#define get_atom_x(atom, i) (atom->x[i]) -#define get_atom_y(atom, i) (atom->y[i]) -#define get_atom_z(atom, i) (atom->z[i]) +#define atom_x(i) atom->x[i] +#define atom_y(i) atom->y[i] +#define atom_z(i) atom->z[i] #endif #endif diff --git a/src/main.c b/src/main.c index 27a3f4f..c064815 100644 --- a/src/main.c +++ b/src/main.c @@ -123,9 +123,9 @@ void initialIntegrate(Parameter *param, Atom *atom) vx[i] += param->dtforce * fx[i]; vy[i] += param->dtforce * fy[i]; vz[i] += param->dtforce * fz[i]; - set_atom_x(atom, i, get_atom_x(atom, i) + param->dt * vx[i]); - set_atom_y(atom, i, get_atom_y(atom, i) + param->dt * vy[i]); - set_atom_z(atom, i, get_atom_z(atom, i) + param->dt * vz[i]); + atom_x(i) = atom_x(i) + param->dt * vx[i]; + atom_y(i) = atom_y(i) + param->dt * vy[i]; + atom_z(i) = atom_z(i) + param->dt * vz[i]; } } @@ -164,9 +164,9 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor) for(int i = 0; i < Nlocal; i++) { neighs = &neighbor->neighbors[i * neighbor->maxneighs]; int numneighs = neighbor->numneigh[i]; - MD_FLOAT xtmp = get_atom_x(atom, i); - MD_FLOAT ytmp = get_atom_y(atom, i); - MD_FLOAT ztmp = get_atom_z(atom, i); + MD_FLOAT xtmp = atom_x(i); + MD_FLOAT ytmp = atom_y(i); + MD_FLOAT ztmp = atom_z(i); MD_FLOAT fix = 0; MD_FLOAT fiy = 0; @@ -174,9 +174,9 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor) for(int k = 0; k < numneighs; k++) { int j = neighs[k]; - MD_FLOAT delx = xtmp - get_atom_x(atom, j); - MD_FLOAT dely = ytmp - get_atom_y(atom, j); - MD_FLOAT delz = ztmp - get_atom_z(atom, j); + MD_FLOAT delx = xtmp - atom_x(j); + MD_FLOAT dely = ytmp - atom_y(j); + MD_FLOAT delz = ztmp - atom_z(j); MD_FLOAT rsq = delx * delx + dely * dely + delz * delz; if(rsq < cutforcesq) { diff --git a/src/neighbor.c b/src/neighbor.c index fc80909..05591ed 100644 --- a/src/neighbor.c +++ b/src/neighbor.c @@ -2,7 +2,7 @@ * ======================================================================================= * * Author: Jan Eitzinger (je), jan.eitzinger@fau.de - * Copyright (c) 2020 RRZE, University Erlangen-Nuremberg + * Copyright (c) 2021 RRZE, University Erlangen-Nuremberg * * This file is part of MD-Bench. * @@ -193,9 +193,9 @@ void buildNeighbor(Atom *atom, Neighbor *neighbor) for(int i = 0; i < atom->Nlocal; i++) { int* neighptr = &(neighbor->neighbors[i * neighbor->maxneighs]); int n = 0; - MD_FLOAT xtmp = get_atom_x(atom, i); - MD_FLOAT ytmp = get_atom_y(atom, i); - MD_FLOAT ztmp = get_atom_z(atom, i); + MD_FLOAT xtmp = atom_x(i); + MD_FLOAT ytmp = atom_y(i); + MD_FLOAT ztmp = atom_z(i); int ibin = coord2bin(xtmp, ytmp, ztmp); for(int k = 0; k < nstencil; k++) { @@ -209,9 +209,9 @@ void buildNeighbor(Atom *atom, Neighbor *neighbor) continue; } - MD_FLOAT delx = xtmp - get_atom_x(atom, j); - MD_FLOAT dely = ytmp - get_atom_y(atom, j); - MD_FLOAT delz = ztmp - get_atom_z(atom, j); + MD_FLOAT delx = xtmp - atom_x(j); + MD_FLOAT dely = ytmp - atom_y(j); + MD_FLOAT delz = ztmp - atom_z(j); MD_FLOAT rsq = delx * delx + dely * dely + delz * delz; if( rsq <= cutneighsq ) { @@ -316,7 +316,7 @@ void binatoms(Atom *atom) } for(int i = 0; i < nall; i++) { - int ibin = coord2bin(get_atom_x(atom, i), get_atom_y(atom, i), get_atom_z(atom, i)); + int ibin = coord2bin(atom_x(i), atom_y(i), atom_z(i)); if(bincount[ibin] < atoms_per_bin) { int ac = bincount[ibin]++; diff --git a/src/pbc.c b/src/pbc.c index 7631e16..a32faf8 100644 --- a/src/pbc.c +++ b/src/pbc.c @@ -53,9 +53,9 @@ void updatePbc(Atom *atom, Parameter *param) MD_FLOAT zprd = param->zprd; for(int i = 0; i < atom->Nghost; i++) { - set_atom_x(atom, nlocal + i, get_atom_x(atom, BorderMap[i]) + PBCx[i] * xprd); - set_atom_y(atom, nlocal + i, get_atom_y(atom, BorderMap[i]) + PBCy[i] * yprd); - set_atom_z(atom, nlocal + i, get_atom_z(atom, BorderMap[i]) + PBCz[i] * zprd); + atom_x(nlocal + i) = atom_x(BorderMap[i]) + PBCx[i] * xprd; + atom_y(nlocal + i) = atom_y(BorderMap[i]) + PBCy[i] * yprd; + atom_z(nlocal + i) = atom_z(BorderMap[i]) + PBCz[i] * zprd; } } @@ -68,26 +68,26 @@ void updateAtomsPbc(Atom *atom, Parameter *param) MD_FLOAT zprd = param->zprd; for(int i = 0; i < atom->Nlocal; i++) { - MD_FLOAT x = get_atom_x(atom, i); - MD_FLOAT y = get_atom_y(atom, i); - MD_FLOAT z = get_atom_z(atom, i); + MD_FLOAT x = atom_x(i); + MD_FLOAT y = atom_y(i); + MD_FLOAT z = atom_z(i); if(x < 0.0) { - set_atom_x(atom, i, x + xprd); + atom_x(i) = x + xprd; } else if(x >= xprd) { - set_atom_x(atom, i, x - xprd); + atom_x(i) = x - xprd; } if(y < 0.0) { - set_atom_y(atom, i, y + yprd); + atom_y(i) = y + yprd; } else if(y >= yprd) { - set_atom_y(atom, i, y - yprd); + atom_y(i) = y - yprd; } if(z < 0.0) { - set_atom_z(atom, i, z + zprd); + atom_z(i) = z + zprd; } else if(z >= zprd) { - set_atom_z(atom, i, z - zprd); + atom_z(i) = z - zprd; } } } @@ -114,9 +114,9 @@ void setupPbc(Atom *atom, Parameter *param) growPbc(); } - MD_FLOAT x = get_atom_x(atom, i); - MD_FLOAT y = get_atom_y(atom, i); - MD_FLOAT z = get_atom_z(atom, i); + MD_FLOAT x = atom_x(i); + MD_FLOAT y = atom_y(i); + MD_FLOAT z = atom_z(i); /* Setup ghost atoms */ /* 6 planes */ From fc1fc9fd4522eac192905db29ee221a49166d4b9 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Tue, 23 Mar 2021 10:03:55 +0100 Subject: [PATCH 4/7] Port pbc to new macros. Enable debugging flags. --- Makefile | 2 +- include_GCC.mk | 8 +++----- src/pbc.c | 34 ++++++++++++++++++---------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 4275bf1..a3c7d85 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -TAG = CLANG +TAG = GCC #CONFIGURE BUILD SYSTEM TARGET = MDBench-$(TAG) diff --git a/include_GCC.mk b/include_GCC.mk index 83b5c5b..0054f40 100644 --- a/include_GCC.mk +++ b/include_GCC.mk @@ -8,14 +8,12 @@ ANSI_CFLAGS += -std=c99 ANSI_CFLAGS += -pedantic ANSI_CFLAGS += -Wextra -# CFLAGS = -O0 -g -std=c99 -fargument-noalias -CFLAGS = -O3 -march=znver1 -ffast-math -funroll-loops -fopenmp +CFLAGS = -O0 -g -std=c99 -fargument-noalias +# CFLAGS = -O3 -march=znver1 -ffast-math -funroll-loops -fopenmp CXXFLAGS = $(CFLAGS) ASFLAGS = -masm=intel FCFLAGS = LFLAGS = -DEFINES = -D_GNU_SOURCE +DEFINES = -D_GNU_SOURCE -DALIGNMENT=64 -DPRECISION=2 INCLUDES = LIBS = - - diff --git a/src/pbc.c b/src/pbc.c index a32faf8..6428669 100644 --- a/src/pbc.c +++ b/src/pbc.c @@ -68,26 +68,23 @@ void updateAtomsPbc(Atom *atom, Parameter *param) MD_FLOAT zprd = param->zprd; for(int i = 0; i < atom->Nlocal; i++) { - MD_FLOAT x = atom_x(i); - MD_FLOAT y = atom_y(i); - MD_FLOAT z = atom_z(i); - if(x < 0.0) { - atom_x(i) = x + xprd; - } else if(x >= xprd) { - atom_x(i) = x - xprd; + if(atom_x(i) < 0.0) { + atom_x(i) += xprd; + } else if(atom_x(i) >= xprd) { + atom_x(i) -= xprd; } - if(y < 0.0) { - atom_y(i) = y + yprd; - } else if(y >= yprd) { - atom_y(i) = y - yprd; + if(atom_y(i) < 0.0) { + atom_y(i) += yprd; + } else if(atom_y(i) >= yprd) { + atom_y(i) -= yprd; } - if(z < 0.0) { - atom_z(i) = z + zprd; - } else if(z >= zprd) { - atom_z(i) = z - zprd; + if(atom_z(i) < 0.0) { + atom_z(i) += zprd; + } else if(atom_z(i) >= zprd) { + atom_z(i) -= zprd; } } } @@ -96,7 +93,12 @@ void updateAtomsPbc(Atom *atom, Parameter *param) * defining ghost atoms around domain * only creates mapping and coordinate corrections * that are then enforced in updatePbc */ -#define ADDGHOST(dx,dy,dz) Nghost++; BorderMap[Nghost] = i; PBCx[Nghost] = dx; PBCy[Nghost] = dy; PBCz[Nghost] = dz; +#define ADDGHOST(dx,dy,dz) \ + Nghost++; \ + BorderMap[Nghost] = i; \ + PBCx[Nghost] = dx; \ + PBCy[Nghost] = dy; \ + PBCz[Nghost] = dz; void setupPbc(Atom *atom, Parameter *param) { MD_FLOAT xprd = param->xprd; From 4b481bb407a681360de5ff064035e659f4c9a6ec Mon Sep 17 00:00:00 2001 From: Rafael Ravedutti Date: Tue, 23 Mar 2021 16:21:08 +0100 Subject: [PATCH 5/7] Fix macros for AoS Signed-off-by: Rafael Ravedutti --- src/includes/atom.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/includes/atom.h b/src/includes/atom.h index abc425e..e090936 100644 --- a/src/includes/atom.h +++ b/src/includes/atom.h @@ -37,15 +37,15 @@ extern void createAtom(Atom*, Parameter*); extern void growAtom(Atom*); #ifdef AOS -#define POS_DATA_LAYOUT "AoS" -#define atom_x(i) atom->x[i * 3 + 0] -#define atom_y(i) atom->x[i * 3 + 1] -#define atom_z(i) atom->x[i * 3 + 2] +#define POS_DATA_LAYOUT "AoS" +#define atom_x(i) atom->x[(i) * 3 + 0] +#define atom_y(i) atom->x[(i) * 3 + 1] +#define atom_z(i) atom->x[(i) * 3 + 2] #else -#define POS_DATA_LAYOUT "SoA" -#define atom_x(i) atom->x[i] -#define atom_y(i) atom->y[i] -#define atom_z(i) atom->z[i] +#define POS_DATA_LAYOUT "SoA" +#define atom_x(i) atom->x[i] +#define atom_y(i) atom->y[i] +#define atom_z(i) atom->z[i] #endif #endif From d0260284397431526ea0d04f06ae064ac564621d Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Wed, 24 Mar 2021 08:43:44 +0100 Subject: [PATCH 6/7] Streamline build system --- Makefile | 16 +++++++++++----- README.md | 7 ++++--- config.mk | 7 +++++++ include_CLANG.mk | 7 ++----- include_GCC.mk | 10 +++------- include_ICC.mk | 7 ++----- src/includes/parameter.h | 3 --- 7 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 config.mk diff --git a/Makefile b/Makefile index a3c7d85..90e3ce1 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,28 @@ -TAG = GCC - #CONFIGURE BUILD SYSTEM TARGET = MDBench-$(TAG) BUILD_DIR = ./$(TAG) SRC_DIR = ./src MAKE_DIR = ./ -FLAGS = -DAOS Q ?= @ #DO NOT EDIT BELOW +include $(MAKE_DIR)/config.mk include $(MAKE_DIR)/include_$(TAG).mk INCLUDES += -I./src/includes +ifeq ($(strip $(DATA_LAYOUT)),AOS) +DEFINES += -DAOS +endif +ifeq ($(strip $(DATA_TYPE)),SP) +DEFINES += -DPRECISION=1 +else +DEFINES += -DPRECISION=2 +endif + VPATH = $(SRC_DIR) ASM = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.s,$(wildcard $(SRC_DIR)/*.c)) OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o,$(wildcard $(SRC_DIR)/*.c)) -CPPFLAGS := $(CPPFLAGS) $(DEFINES) $(INCLUDES) ${FLAGS} - +CPPFLAGS := $(CPPFLAGS) $(DEFINES) $(OPTIONS) $(INCLUDES) ${TARGET}: $(BUILD_DIR) $(OBJ) @echo "===> LINKING $(TARGET)" diff --git a/README.md b/README.md index ba47bcb..94e2875 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,10 @@ A simple, sequential C implementation of the [Mantevo miniMD](https://github.co ## Build -1. Open the `Makefile` and edit the `TAG` value according to the tool chain used. Currently supported is GCC, CLANG (LLVM), and ICC (Intel). -2. Open and adapt the compiler flags in `.mk`, e.g. in `include_ICC.mk` for the Intel tool chain. -3. Build the binary calling `make`. +1. Open `config.mk` and edit the `TAG` value according to the tool chain used. Currently supported is GCC, CLANG (LLVM), and ICC (Intel). +2. Change `DATA_LAYOUT` and `DATA_TYPE` if desired in config.mk. +3. Open and adapt the compiler flags in `.mk`, e.g. in `include_ICC.mk` for the Intel tool chain. +4. Build the binary calling `make`. You can clean intermediate build results with `make clean`, and all build results with `make distclean`. You have to call `make clean` before `make` if you changed the build settings. diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..30c95c7 --- /dev/null +++ b/config.mk @@ -0,0 +1,7 @@ +# Supported: GCC, CLANG, ICC +TAG ?= GCC +DATA_TYPE ?= SP#SP or DP +DATA_LAYOUT ?= AOS#AOS or SOA + +#Feature options +OPTIONS += -DALIGNMENT=64 diff --git a/include_CLANG.mk b/include_CLANG.mk index 93c499c..59fa579 100644 --- a/include_CLANG.mk +++ b/include_CLANG.mk @@ -1,5 +1,4 @@ CC = cc -CXX = gcc LINKER = $(CC) ANSI_CFLAGS = -ansi @@ -9,9 +8,7 @@ ANSI_CFLAGS += -Wextra CFLAGS = -Ofast $(ANSI_CFLAGS) -g #-Xpreprocessor -fopenmp -g ASFLAGS = -masm=intel -CXXFLAGS = $(CFLAGS) -FCFLAGS = LFLAGS = -DEFINES = -D_GNU_SOURCE -DALIGNMENT=64 -DPRECISION=2 +DEFINES = -D_GNU_SOURCE INCLUDES = -LIBS = #-lomp +LIBS = -lm #-lomp diff --git a/include_GCC.mk b/include_GCC.mk index 0054f40..9dd536a 100644 --- a/include_GCC.mk +++ b/include_GCC.mk @@ -1,7 +1,5 @@ CC = gcc -CXX = g++ -FC = gfortran -LINKER = $(CXX) +LINKER = $(CC) ANSI_CFLAGS = -ansi ANSI_CFLAGS += -std=c99 @@ -10,10 +8,8 @@ ANSI_CFLAGS += -Wextra CFLAGS = -O0 -g -std=c99 -fargument-noalias # CFLAGS = -O3 -march=znver1 -ffast-math -funroll-loops -fopenmp -CXXFLAGS = $(CFLAGS) ASFLAGS = -masm=intel -FCFLAGS = LFLAGS = -DEFINES = -D_GNU_SOURCE -DALIGNMENT=64 -DPRECISION=2 +DEFINES = -D_GNU_SOURCE INCLUDES = -LIBS = +LIBS = -lm diff --git a/include_ICC.mk b/include_ICC.mk index 25207af..ddb61ac 100644 --- a/include_ICC.mk +++ b/include_ICC.mk @@ -1,5 +1,4 @@ CC = icc -CXX = icpc LINKER = $(CC) OPENMP = #-qopenmp @@ -11,10 +10,8 @@ PROFILE = #-profile-functions -g -pg #OPTS = -fast -no-vec $(PROFILE) OPTS = -fast -xHost $(PROFILE) CFLAGS = $(PROFILE) -restrict $(OPENMP) $(OPTS) -CXXFLAGS = $(CFLAGS) ASFLAGS = -masm=intel -FCFLAGS = LFLAGS = $(PROFILE) $(OPTS) $(OPENMP) -DEFINES = -D_GNU_SOURCE -DALIGNMENT=64 # -DLIKWID_PERFMON -DPRECISION=1 +DEFINES = -D_GNU_SOURCE # -DALIGNMENT=64 -DLIKWID_PERFMON -DPRECISION=1 INCLUDES = #$(LIKWID_INC) -LIBS = #$(LIKWID_LIB) -llikwid +LIBS = -lm #$(LIKWID_LIB) -llikwid diff --git a/src/includes/parameter.h b/src/includes/parameter.h index 87da5f8..4f6f914 100644 --- a/src/includes/parameter.h +++ b/src/includes/parameter.h @@ -23,9 +23,6 @@ #ifndef __PARAMETER_H_ #define __PARAMETER_H_ -#ifndef PRECISION -#define PRECISION 2 -#endif #if PRECISION == 1 #define MD_FLOAT float #else From 32b23a2ebd48003d1986180cb6da9f20aab7387f Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Wed, 24 Mar 2021 08:48:27 +0100 Subject: [PATCH 7/7] Set defaults for GCC --- config.mk | 2 +- include_GCC.mk | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.mk b/config.mk index 30c95c7..9cf51d0 100644 --- a/config.mk +++ b/config.mk @@ -1,7 +1,7 @@ # Supported: GCC, CLANG, ICC TAG ?= GCC DATA_TYPE ?= SP#SP or DP -DATA_LAYOUT ?= AOS#AOS or SOA +DATA_LAYOUT ?= SoA#AOS or SOA #Feature options OPTIONS += -DALIGNMENT=64 diff --git a/include_GCC.mk b/include_GCC.mk index 9dd536a..d29cca9 100644 --- a/include_GCC.mk +++ b/include_GCC.mk @@ -6,8 +6,8 @@ ANSI_CFLAGS += -std=c99 ANSI_CFLAGS += -pedantic ANSI_CFLAGS += -Wextra -CFLAGS = -O0 -g -std=c99 -fargument-noalias -# CFLAGS = -O3 -march=znver1 -ffast-math -funroll-loops -fopenmp +# CFLAGS = -O0 -g -std=c99 -fargument-noalias +CFLAGS = -O3 -march=znver1 -ffast-math -funroll-loops # -fopenmp ASFLAGS = -masm=intel LFLAGS = DEFINES = -D_GNU_SOURCE