Skip to content
Snippets Groups Projects
Commit 070ff0b7 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

add function to synch just one particle

not sure we'll ever use it, but you never know.
parent 58607f03
Branches
Tags
No related merge requests found
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#define BASE #define BASE
static const int message_buffer_length = 1024; static const int message_buffer_length = 1024;
static char debug_message_buffer[message_buffer_length];
extern int myrank, nprocs; extern int myrank, nprocs;
inline int MOD(int a, int n) inline int MOD(int a, int n)
...@@ -38,6 +37,8 @@ inline int MOD(int a, int n) ...@@ -38,6 +37,8 @@ inline int MOD(int a, int n)
#ifndef NDEBUG #ifndef NDEBUG
static char debug_message_buffer[message_buffer_length];
inline void DEBUG_MSG(const char * format, ...) inline void DEBUG_MSG(const char * format, ...)
{ {
va_list argptr; va_list argptr;
......
...@@ -129,6 +129,34 @@ int slab_field_particles<rnumber>::get_rank(double z) ...@@ -129,6 +129,34 @@ int slab_field_particles<rnumber>::get_rank(double z)
return tmp; 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> template <class rnumber>
void slab_field_particles<rnumber>::synchronize() void slab_field_particles<rnumber>::synchronize()
{ {
...@@ -226,9 +254,9 @@ void slab_field_particles<rnumber>::get_grid_coordinates(double *x, int *xg, dou ...@@ -226,9 +254,9 @@ void slab_field_particles<rnumber>::get_grid_coordinates(double *x, int *xg, dou
template <class rnumber> template <class rnumber>
void slab_field_particles<rnumber>::linear_interpolation(float *field, int *xg, double *xx, double *dest) void slab_field_particles<rnumber>::linear_interpolation(float *field, int *xg, double *xx, double *dest)
{ {
ptrdiff_t tindex, tmp; //ptrdiff_t tindex, tmp;
tindex = ((ptrdiff_t(xg[2] )*this->fs->rd->subsizes[1]+xg[1] )*this->fs->rd->subsizes[2]+xg[0] )*3; //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]); //tmp = ptrdiff_t(xg[2]);
//DEBUG_MSG( //DEBUG_MSG(
// "linear interpolation xx is %lg %lg %lg xg is %d %d %d," // "linear interpolation xx is %lg %lg %lg xg is %d %d %d,"
// " corner index is ((%ld*%d+%d)*%d+%d)*3 = %ld\n", // " corner index is ((%ld*%d+%d)*%d+%d)*3 = %ld\n",
......
...@@ -42,6 +42,9 @@ class slab_field_particles ...@@ -42,6 +42,9 @@ class slab_field_particles
/* watching is an array of shape [nparticles], with /* watching is an array of shape [nparticles], with
* watching[p] being true if particle p is in the domain of myrank * watching[p] being true if particle p is in the domain of myrank
* or in the buffer regions. * 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; bool *watching;
/* computing is an array of shape [nparticles], with /* computing is an array of shape [nparticles], with
...@@ -97,6 +100,7 @@ class slab_field_particles ...@@ -97,6 +100,7 @@ class slab_field_particles
/* generic methods, should work for all children of this class */ /* generic methods, should work for all children of this class */
int get_rank(double z); // get rank for given value of z int get_rank(double z); // get rank for given value of z
void synchronize(); void synchronize();
void synchronize_single_particle(int p);
void get_grid_coordinates(double *x, int *xg, double *xx); void get_grid_coordinates(double *x, int *xg, double *xx);
void linear_interpolation(float *field, int *xg, double *xx, double *dest); void linear_interpolation(float *field, int *xg, double *xx, double *dest);
void rFFTW_to_buffered(rnumber *src, rnumber *dst); void rFFTW_to_buffered(rnumber *src, rnumber *dst);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment