From 56ad09156bd8f350871289b0c0ca51798f6733aa Mon Sep 17 00:00:00 2001 From: Rafael Ravedutti Date: Thu, 20 May 2021 00:08:10 +0200 Subject: [PATCH] Fix explicit types for stubbed version Signed-off-by: Rafael Ravedutti --- Makefile | 4 ++++ src/main-stub.c | 14 ++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index e15e330..23b00ce 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,10 @@ ifneq ($(INTERNAL_LOOP_NTIMES),) DEFINES += -DINTERNAL_LOOP_NTIMES=$(INTERNAL_LOOP_NTIMES) endif +ifneq ($(EXPLICIT_TYPES),) + DEFINES += -DEXPLICIT_TYPES +endif + VPATH = $(SRC_DIR) ASM = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.s,$(wildcard $(SRC_DIR)/*.c)) OBJ = $(filter-out $(BUILD_DIR)/main%,$(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o,$(wildcard $(SRC_DIR)/*.c))) diff --git a/src/main-stub.c b/src/main-stub.c index a0973f1..e7493b8 100644 --- a/src/main-stub.c +++ b/src/main-stub.c @@ -50,7 +50,6 @@ void init(Parameter *param) { atom->vx[atom->Nlocal] = vy; \ atom->vy[atom->Nlocal] = vy; \ atom->vz[atom->Nlocal] = vz; \ - atom->type[atom->Nlocal] = rand() % atom->ntypes; \ atom->Nlocal++ int main(int argc, const char *argv[]) { @@ -126,16 +125,16 @@ int main(int argc, const char *argv[]) { initAtom(atom); #ifdef EXPLICIT_TYPES - atom->ntypes = param->ntypes; + atom->ntypes = param.ntypes; atom->epsilon = allocate(ALIGNMENT, atom->ntypes * atom->ntypes * sizeof(MD_FLOAT)); atom->sigma6 = allocate(ALIGNMENT, atom->ntypes * atom->ntypes * sizeof(MD_FLOAT)); atom->cutforcesq = allocate(ALIGNMENT, atom->ntypes * atom->ntypes * sizeof(MD_FLOAT)); atom->cutneighsq = allocate(ALIGNMENT, atom->ntypes * atom->ntypes * sizeof(MD_FLOAT)); for(int i = 0; i < atom->ntypes * atom->ntypes; i++) { - atom->epsilon[i] = param->epsilon; - atom->sigma6[i] = param->sigma6; - atom->cutneighsq[i] = param->cutneigh * param->cutneigh; - atom->cutforcesq[i] = param->cutforce * param->cutforce; + atom->epsilon[i] = param.epsilon; + atom->sigma6[i] = param.sigma6; + atom->cutneighsq[i] = param.cutneigh * param.cutneigh; + atom->cutforcesq[i] = param.cutforce * param.cutforce; } #endif @@ -173,6 +172,9 @@ int main(int argc, const char *argv[]) { for(int jj = 0; jj < fac_y; ++jj) { for(int kk = 0; kk < fac_z; ++kk) { if(added_atoms < atoms_per_unit_cell) { + #ifdef EXPLICIT_TYPES + atom->type[atom->Nlocal] = rand() % atom->ntypes; + #endif ADD_ATOM(ii * offset_x, jj * offset_y, kk * offset_z, vx, vy, vz); added_atoms++; }