diff --git a/src/base.hpp b/src/base.hpp index 281bd9bcff9909fd89b9a03159a63941873e4cd2..a29635091644b4dc81dfa0b66bdd93c353f676ed 100644 --- a/src/base.hpp +++ b/src/base.hpp @@ -28,7 +28,6 @@ #define BASE static const int message_buffer_length = 1024; -static char debug_message_buffer[message_buffer_length]; extern int myrank, nprocs; inline int MOD(int a, int n) @@ -38,6 +37,8 @@ inline int MOD(int a, int n) #ifndef NDEBUG +static char debug_message_buffer[message_buffer_length]; + inline void DEBUG_MSG(const char * format, ...) { va_list argptr; diff --git a/src/slab_field_particles.cpp b/src/slab_field_particles.cpp index 2b7aa23c54387f2f35ca737d39044e3321b5a59c..e21d8fb6687db50de84ed3efffe987df9e290575 100644 --- a/src/slab_field_particles.cpp +++ b/src/slab_field_particles.cpp @@ -129,6 +129,34 @@ int slab_field_particles<rnumber>::get_rank(double z) return tmp; } +template <class rnumber> +void slab_field_particles<rnumber>::synchronize_single_particle(int p) +{ + MPI_Status *s = new MPI_Status; + if (this->watching[p]) for (int r=0; r<this->fs->rd->nprocs; r++) + if (r != this->computing[p]) + { + if (this->fs->rd->myrank == this->computing[p]) + MPI_Send( + this->state + p*this->ncomponents, + this->ncomponents, + MPI_REAL8, + r, + p*this->computing[p], + this->fs->rd->comm); + if (this->fs->rd->myrank == r) + MPI_Recv( + this->state + p*this->ncomponents, + this->ncomponents, + MPI_REAL8, + this->computing[p], + p*this->computing[p], + this->fs->rd->comm, + s); + } + delete s; +} + template <class rnumber> void slab_field_particles<rnumber>::synchronize() { @@ -226,9 +254,9 @@ void slab_field_particles<rnumber>::get_grid_coordinates(double *x, int *xg, dou template <class rnumber> void slab_field_particles<rnumber>::linear_interpolation(float *field, int *xg, double *xx, double *dest) { - ptrdiff_t tindex, tmp; - tindex = ((ptrdiff_t(xg[2] )*this->fs->rd->subsizes[1]+xg[1] )*this->fs->rd->subsizes[2]+xg[0] )*3; - tmp = ptrdiff_t(xg[2]); + //ptrdiff_t tindex, tmp; + //tindex = ((ptrdiff_t(xg[2] )*this->fs->rd->subsizes[1]+xg[1] )*this->fs->rd->subsizes[2]+xg[0] )*3; + //tmp = ptrdiff_t(xg[2]); //DEBUG_MSG( // "linear interpolation xx is %lg %lg %lg xg is %d %d %d," // " corner index is ((%ld*%d+%d)*%d+%d)*3 = %ld\n", diff --git a/src/slab_field_particles.hpp b/src/slab_field_particles.hpp index 4f8c094b4fda8962a74b07c0641268e719107ae8..e7abde5b923a667ee808ce79c3fd78a6b7755745 100644 --- a/src/slab_field_particles.hpp +++ b/src/slab_field_particles.hpp @@ -42,6 +42,9 @@ class slab_field_particles /* watching is an array of shape [nparticles], with * watching[p] being true if particle p is in the domain of myrank * or in the buffer regions. + * watching is not really being used right now, since I don't do partial + * synchronizations of particles. + * we may do this at some point in the future, if it seems needed... * */ bool *watching; /* computing is an array of shape [nparticles], with @@ -97,6 +100,7 @@ class slab_field_particles /* generic methods, should work for all children of this class */ int get_rank(double z); // get rank for given value of z void synchronize(); + void synchronize_single_particle(int p); void get_grid_coordinates(double *x, int *xg, double *xx); void linear_interpolation(float *field, int *xg, double *xx, double *dest); void rFFTW_to_buffered(rnumber *src, rnumber *dst);