Commit 129baa7d authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

replaces init method with "set_to_zero" function

parent 267ff8fb
......@@ -675,9 +675,9 @@ public:
// allocate rhs buffer
descriptor.results.reset(new real_number[NbParticlesToReceive*size_particle_rhs]);
// clean up rhs buffer
std::fill_n(descriptor.results.get(), NbParticlesToReceive*size_particle_rhs, 0);
// precompute rhs buffer (?)
computer_thread.template init_result_array<size_particle_rhs>(descriptor.results.get(), NbParticlesToReceive);
set_particle_data_to_zero<partsize_t, real_number, size_particle_rhs>(
descriptor.results.get(),
NbParticlesToReceive);
// Compute
partsize_t idxPart = 0;
......
......@@ -413,11 +413,19 @@ public:
const partsize_t NbParticlesToReceive = descriptor.nbParticlesToRecv;
assert(descriptor.toCompute != nullptr);
// allocate buffer
descriptor.results.reset(new real_number[NbParticlesToReceive*size_particle_rhs]);
in_computer.template init_result_array<size_particle_rhs>(descriptor.results.get(), NbParticlesToReceive);
// clean up buffer
set_particle_data_to_zero<partsize_t, real_number, size_particle_rhs>(
descriptor.results.get(),
NbParticlesToReceive);
if(more_than_one_thread == false){
in_computer.template apply_computation<field_class, size_particle_positions, size_particle_rhs>(in_field, descriptor.toCompute.get(), descriptor.results.get(), NbParticlesToReceive);
in_computer.template apply_computation<field_class, size_particle_positions, size_particle_rhs>(
in_field,
descriptor.toCompute.get(),
descriptor.results.get(),
NbParticlesToReceive);
}
else{
TIMEZONE_OMP_INIT_PRETASK(timeZoneTaskKey)
......
......@@ -398,4 +398,19 @@ std::vector<real_number> BuildLimitsAllProcesses(
return spatial_limit_per_proc;
}
#endif
template <typename partsize_t, typename rnumber, int size_of_particle>
int set_particle_data_to_zero(
rnumber __restrict__ *data,
const partsize_t numberParticles)
{
// TODO: ensure simd.
// don't use openmp here, as this function may be called from within openmp parallel regions
std::fill_n(
data,
numberParticles*size_of_particle,
0);
return EXIT_SUCCESS;
}
#endif//PARTICLES_UTILS_HPP
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment