Simplify macros for data structure access.
Still segvaults for AoS.
This commit is contained in:
parent
cb0ae2b0bb
commit
6679b6c8aa
2
Makefile
2
Makefile
@ -5,7 +5,7 @@ TARGET = MDBench-$(TAG)
|
|||||||
BUILD_DIR = ./$(TAG)
|
BUILD_DIR = ./$(TAG)
|
||||||
SRC_DIR = ./src
|
SRC_DIR = ./src
|
||||||
MAKE_DIR = ./
|
MAKE_DIR = ./
|
||||||
FLAGS = #-DAOS
|
FLAGS = -DAOS
|
||||||
Q ?= @
|
Q ?= @
|
||||||
|
|
||||||
#DO NOT EDIT BELOW
|
#DO NOT EDIT BELOW
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
CC = cc
|
CC = cc
|
||||||
CXX = cc
|
CXX = gcc
|
||||||
LINKER = $(CC)
|
LINKER = $(CC)
|
||||||
|
|
||||||
ANSI_CFLAGS = -ansi
|
ANSI_CFLAGS = -ansi
|
||||||
@ -7,11 +7,11 @@ ANSI_CFLAGS += -std=c99
|
|||||||
ANSI_CFLAGS += -pedantic
|
ANSI_CFLAGS += -pedantic
|
||||||
ANSI_CFLAGS += -Wextra
|
ANSI_CFLAGS += -Wextra
|
||||||
|
|
||||||
CFLAGS = -Ofast $(ANSI_CFLAGS) -Xpreprocessor -fopenmp #-g
|
CFLAGS = -Ofast $(ANSI_CFLAGS) -g #-Xpreprocessor -fopenmp -g
|
||||||
ASFLAGS = -masm=intel
|
ASFLAGS = -masm=intel
|
||||||
CXXFLAGS = $(CFLAGS)
|
CXXFLAGS = $(CFLAGS)
|
||||||
FCFLAGS =
|
FCFLAGS =
|
||||||
LFLAGS =
|
LFLAGS =
|
||||||
DEFINES = -D_GNU_SOURCE -DALIGNMENT=64 -DPRECISION=2
|
DEFINES = -D_GNU_SOURCE -DALIGNMENT=64 -DPRECISION=2
|
||||||
INCLUDES =
|
INCLUDES =
|
||||||
LIBS = -lomp
|
LIBS = #-lomp
|
||||||
|
12
src/atom.c
12
src/atom.c
@ -1,8 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* =======================================================================================
|
* =======================================================================================
|
||||||
*
|
*
|
||||||
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
|
* Authors: Jan Eitzinger (je), jan.eitzinger@fau.de
|
||||||
* Copyright (c) 2020 RRZE, University Erlangen-Nuremberg
|
* Rafael Ravedutti (rr), rafaelravedutti@gmail.com
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 RRZE, University Erlangen-Nuremberg
|
||||||
*
|
*
|
||||||
* This file is part of MD-Bench.
|
* This file is part of MD-Bench.
|
||||||
*
|
*
|
||||||
@ -111,9 +113,9 @@ void createAtom(Atom *atom, Parameter *param)
|
|||||||
growAtom(atom);
|
growAtom(atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_atom_x(atom, atom->Nlocal, xtmp);
|
atom_x(atom->Nlocal) = xtmp;
|
||||||
set_atom_y(atom, atom->Nlocal, ytmp);
|
atom_y(atom->Nlocal) = ytmp;
|
||||||
set_atom_z(atom, atom->Nlocal, ztmp);
|
atom_z(atom->Nlocal) = ztmp;
|
||||||
atom->vx[atom->Nlocal] = vxtmp;
|
atom->vx[atom->Nlocal] = vxtmp;
|
||||||
atom->vy[atom->Nlocal] = vytmp;
|
atom->vy[atom->Nlocal] = vytmp;
|
||||||
atom->vz[atom->Nlocal] = vztmp;
|
atom->vz[atom->Nlocal] = vztmp;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* =======================================================================================
|
* =======================================================================================
|
||||||
*
|
*
|
||||||
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
|
* 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.
|
* This file is part of MD-Bench.
|
||||||
*
|
*
|
||||||
@ -38,25 +38,14 @@ extern void growAtom(Atom*);
|
|||||||
|
|
||||||
#ifdef AOS
|
#ifdef AOS
|
||||||
#define POS_DATA_LAYOUT "AoS"
|
#define POS_DATA_LAYOUT "AoS"
|
||||||
/* FIXME: these macros are resulting in segfault
|
#define atom_x(i) atom->x[i * 3 + 0]
|
||||||
#define set_atom_x(atom, i, v) (atom->x[i * 3 + 0] = v)
|
#define atom_y(i) atom->x[i * 3 + 1]
|
||||||
#define set_atom_y(atom, i, v) (atom->x[i * 3 + 1] = v)
|
#define atom_z(i) atom->x[i * 3 + 2]
|
||||||
#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])
|
|
||||||
#else
|
#else
|
||||||
#define POS_DATA_LAYOUT "SoA"
|
#define POS_DATA_LAYOUT "SoA"
|
||||||
#define set_atom_x(atom, i, v) (atom->x[i] = v)
|
#define atom_x(i) atom->x[i]
|
||||||
#define set_atom_y(atom, i, v) (atom->y[i] = v)
|
#define atom_y(i) atom->y[i]
|
||||||
#define set_atom_z(atom, i, v) (atom->z[i] = v)
|
#define atom_z(i) atom->z[i]
|
||||||
#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
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
18
src/main.c
18
src/main.c
@ -123,9 +123,9 @@ void initialIntegrate(Parameter *param, Atom *atom)
|
|||||||
vx[i] += param->dtforce * fx[i];
|
vx[i] += param->dtforce * fx[i];
|
||||||
vy[i] += param->dtforce * fy[i];
|
vy[i] += param->dtforce * fy[i];
|
||||||
vz[i] += param->dtforce * fz[i];
|
vz[i] += param->dtforce * fz[i];
|
||||||
set_atom_x(atom, i, get_atom_x(atom, i) + param->dt * vx[i]);
|
atom_x(i) = atom_x(i) + param->dt * vx[i];
|
||||||
set_atom_y(atom, i, get_atom_y(atom, i) + param->dt * vy[i]);
|
atom_y(i) = atom_y(i) + param->dt * vy[i];
|
||||||
set_atom_z(atom, i, get_atom_z(atom, i) + param->dt * vz[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++) {
|
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 = get_atom_x(atom, i);
|
MD_FLOAT xtmp = atom_x(i);
|
||||||
MD_FLOAT ytmp = get_atom_y(atom, i);
|
MD_FLOAT ytmp = atom_y(i);
|
||||||
MD_FLOAT ztmp = get_atom_z(atom, i);
|
MD_FLOAT ztmp = atom_z(i);
|
||||||
|
|
||||||
MD_FLOAT fix = 0;
|
MD_FLOAT fix = 0;
|
||||||
MD_FLOAT fiy = 0;
|
MD_FLOAT fiy = 0;
|
||||||
@ -174,9 +174,9 @@ double computeForce(Parameter *param, Atom *atom, Neighbor *neighbor)
|
|||||||
|
|
||||||
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 - get_atom_x(atom, j);
|
MD_FLOAT delx = xtmp - atom_x(j);
|
||||||
MD_FLOAT dely = ytmp - get_atom_y(atom, j);
|
MD_FLOAT dely = ytmp - atom_y(j);
|
||||||
MD_FLOAT delz = ztmp - get_atom_z(atom, 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) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* =======================================================================================
|
* =======================================================================================
|
||||||
*
|
*
|
||||||
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
|
* 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.
|
* 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++) {
|
for(int i = 0; i < atom->Nlocal; i++) {
|
||||||
int* neighptr = &(neighbor->neighbors[i * neighbor->maxneighs]);
|
int* neighptr = &(neighbor->neighbors[i * neighbor->maxneighs]);
|
||||||
int n = 0;
|
int n = 0;
|
||||||
MD_FLOAT xtmp = get_atom_x(atom, i);
|
MD_FLOAT xtmp = atom_x(i);
|
||||||
MD_FLOAT ytmp = get_atom_y(atom, i);
|
MD_FLOAT ytmp = atom_y(i);
|
||||||
MD_FLOAT ztmp = get_atom_z(atom, i);
|
MD_FLOAT ztmp = atom_z(i);
|
||||||
int ibin = coord2bin(xtmp, ytmp, ztmp);
|
int ibin = coord2bin(xtmp, ytmp, ztmp);
|
||||||
|
|
||||||
for(int k = 0; k < nstencil; k++) {
|
for(int k = 0; k < nstencil; k++) {
|
||||||
@ -209,9 +209,9 @@ void buildNeighbor(Atom *atom, Neighbor *neighbor)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MD_FLOAT delx = xtmp - get_atom_x(atom, j);
|
MD_FLOAT delx = xtmp - atom_x(j);
|
||||||
MD_FLOAT dely = ytmp - get_atom_y(atom, j);
|
MD_FLOAT dely = ytmp - atom_y(j);
|
||||||
MD_FLOAT delz = ztmp - get_atom_z(atom, 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 <= cutneighsq ) {
|
if( rsq <= cutneighsq ) {
|
||||||
@ -316,7 +316,7 @@ void binatoms(Atom *atom)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < nall; i++) {
|
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) {
|
if(bincount[ibin] < atoms_per_bin) {
|
||||||
int ac = bincount[ibin]++;
|
int ac = bincount[ibin]++;
|
||||||
|
30
src/pbc.c
30
src/pbc.c
@ -53,9 +53,9 @@ void updatePbc(Atom *atom, Parameter *param)
|
|||||||
MD_FLOAT zprd = param->zprd;
|
MD_FLOAT zprd = param->zprd;
|
||||||
|
|
||||||
for(int i = 0; i < atom->Nghost; i++) {
|
for(int i = 0; i < atom->Nghost; i++) {
|
||||||
set_atom_x(atom, nlocal + i, get_atom_x(atom, BorderMap[i]) + PBCx[i] * xprd);
|
atom_x(nlocal + i) = atom_x(BorderMap[i]) + PBCx[i] * xprd;
|
||||||
set_atom_y(atom, nlocal + i, get_atom_y(atom, BorderMap[i]) + PBCy[i] * yprd);
|
atom_y(nlocal + i) = atom_y(BorderMap[i]) + PBCy[i] * yprd;
|
||||||
set_atom_z(atom, nlocal + i, get_atom_z(atom, BorderMap[i]) + PBCz[i] * zprd);
|
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;
|
MD_FLOAT zprd = param->zprd;
|
||||||
|
|
||||||
for(int i = 0; i < atom->Nlocal; i++) {
|
for(int i = 0; i < atom->Nlocal; i++) {
|
||||||
MD_FLOAT x = get_atom_x(atom, i);
|
MD_FLOAT x = atom_x(i);
|
||||||
MD_FLOAT y = get_atom_y(atom, i);
|
MD_FLOAT y = atom_y(i);
|
||||||
MD_FLOAT z = get_atom_z(atom, i);
|
MD_FLOAT z = atom_z(i);
|
||||||
|
|
||||||
if(x < 0.0) {
|
if(x < 0.0) {
|
||||||
set_atom_x(atom, i, x + xprd);
|
atom_x(i) = x + xprd;
|
||||||
} else if(x >= xprd) {
|
} else if(x >= xprd) {
|
||||||
set_atom_x(atom, i, x - xprd);
|
atom_x(i) = x - xprd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(y < 0.0) {
|
if(y < 0.0) {
|
||||||
set_atom_y(atom, i, y + yprd);
|
atom_y(i) = y + yprd;
|
||||||
} else if(y >= yprd) {
|
} else if(y >= yprd) {
|
||||||
set_atom_y(atom, i, y - yprd);
|
atom_y(i) = y - yprd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(z < 0.0) {
|
if(z < 0.0) {
|
||||||
set_atom_z(atom, i, z + zprd);
|
atom_z(i) = z + zprd;
|
||||||
} else if(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();
|
growPbc();
|
||||||
}
|
}
|
||||||
|
|
||||||
MD_FLOAT x = get_atom_x(atom, i);
|
MD_FLOAT x = atom_x(i);
|
||||||
MD_FLOAT y = get_atom_y(atom, i);
|
MD_FLOAT y = atom_y(i);
|
||||||
MD_FLOAT z = get_atom_z(atom, i);
|
MD_FLOAT z = atom_z(i);
|
||||||
|
|
||||||
/* Setup ghost atoms */
|
/* Setup ghost atoms */
|
||||||
/* 6 planes */
|
/* 6 planes */
|
||||||
|
Loading…
Reference in New Issue
Block a user