Fix explicit types for stubbed version

Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
This commit is contained in:
Rafael Ravedutti 2021-05-20 00:08:10 +02:00
parent 4496e91125
commit 56ad09156b
2 changed files with 12 additions and 6 deletions

View File

@ -23,6 +23,10 @@ ifneq ($(INTERNAL_LOOP_NTIMES),)
DEFINES += -DINTERNAL_LOOP_NTIMES=$(INTERNAL_LOOP_NTIMES) DEFINES += -DINTERNAL_LOOP_NTIMES=$(INTERNAL_LOOP_NTIMES)
endif endif
ifneq ($(EXPLICIT_TYPES),)
DEFINES += -DEXPLICIT_TYPES
endif
VPATH = $(SRC_DIR) VPATH = $(SRC_DIR)
ASM = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.s,$(wildcard $(SRC_DIR)/*.c)) 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))) OBJ = $(filter-out $(BUILD_DIR)/main%,$(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o,$(wildcard $(SRC_DIR)/*.c)))

View File

@ -50,7 +50,6 @@ void init(Parameter *param) {
atom->vx[atom->Nlocal] = vy; \ atom->vx[atom->Nlocal] = vy; \
atom->vy[atom->Nlocal] = vy; \ atom->vy[atom->Nlocal] = vy; \
atom->vz[atom->Nlocal] = vz; \ atom->vz[atom->Nlocal] = vz; \
atom->type[atom->Nlocal] = rand() % atom->ntypes; \
atom->Nlocal++ atom->Nlocal++
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
@ -126,16 +125,16 @@ int main(int argc, const char *argv[]) {
initAtom(atom); initAtom(atom);
#ifdef EXPLICIT_TYPES #ifdef EXPLICIT_TYPES
atom->ntypes = param->ntypes; atom->ntypes = param.ntypes;
atom->epsilon = allocate(ALIGNMENT, atom->ntypes * atom->ntypes * sizeof(MD_FLOAT)); atom->epsilon = allocate(ALIGNMENT, atom->ntypes * atom->ntypes * sizeof(MD_FLOAT));
atom->sigma6 = 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->cutforcesq = allocate(ALIGNMENT, atom->ntypes * atom->ntypes * sizeof(MD_FLOAT));
atom->cutneighsq = 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++) { for(int i = 0; i < atom->ntypes * atom->ntypes; i++) {
atom->epsilon[i] = param->epsilon; atom->epsilon[i] = param.epsilon;
atom->sigma6[i] = param->sigma6; atom->sigma6[i] = param.sigma6;
atom->cutneighsq[i] = param->cutneigh * param->cutneigh; atom->cutneighsq[i] = param.cutneigh * param.cutneigh;
atom->cutforcesq[i] = param->cutforce * param->cutforce; atom->cutforcesq[i] = param.cutforce * param.cutforce;
} }
#endif #endif
@ -173,6 +172,9 @@ int main(int argc, const char *argv[]) {
for(int jj = 0; jj < fac_y; ++jj) { for(int jj = 0; jj < fac_y; ++jj) {
for(int kk = 0; kk < fac_z; ++kk) { for(int kk = 0; kk < fac_z; ++kk) {
if(added_atoms < atoms_per_unit_cell) { 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); ADD_ATOM(ii * offset_x, jj * offset_y, kk * offset_z, vx, vy, vz);
added_atoms++; added_atoms++;
} }