diff --git a/TurTLE/_code.py b/TurTLE/_code.py index e9bac67edcec905ef1bacc58ab7a5defbb9a1703..00339f955ae67ff72df5743ec2a0cd1be75e6be1 100644 --- a/TurTLE/_code.py +++ b/TurTLE/_code.py @@ -407,6 +407,8 @@ class _code(_base): command_atoms = [self.host_info['executable_launcher']] if self.host_info['executable_launcher'] == 'srun': command_atoms += ['-p', 'interactive'] + if 'executable_parameters' in self.host_info.keys(): + command_atoms += self.host_info['executable_parameters'] else: command_atoms = ['mpirun'] command_atoms += ['-n', diff --git a/cpp/kspace.cpp b/cpp/kspace.cpp index c2d941bd590025e0b64ee78d936a293fca7938e0..64daa3c48d7cb7e4d59b2d269a598a4286c27394 100644 --- a/cpp/kspace.cpp +++ b/cpp/kspace.cpp @@ -147,9 +147,29 @@ kspace<be, dt>::kspace( &this->kshell.front(), this->nshells, MPI_DOUBLE, MPI_SUM, this->layout->comm); + + // 2020-08-07 + // following loop generated some problems with intel compiler + // at highest optimization level, the intel compiler performs aggressive + // vectorization of loops, including this one. + // it also turns on speculative execution, i.e. it computes both branches + // of the if clause in parallel, and then it picks out the useful result. + // the problem is that one of the branches is a division by 0, hence a + // floating point exception is raised. + // there are several possible solutions: + // * instead of dividing by `this->nshell[n]`, create a double `nnshell` + // that takes the maximum value between 1.0 and `this->nshell[n]`, and + // then divide by `nnshell` + // * use the '-fp-speculation=safe' intel compiler option + // * tell the compiler that we do not want to vectorize this particular + // loop by using `#pragma novector`. + // I chose the last option because there's no reason to optimize this + // loop. Furthermore, it seems like the solution that's most readable, + // and with the least amount of side effects. + # pragma novector for (int n=0; n<this->nshells; n++){ - volatile double nnshell = std::max(double(this->nshell[n]), 1.0); - this->kshell[n] /= nnshell; + if (this->nshell[n] > 0) + this->kshell[n] /= this->nshell[n]; } }