PLUTO  4.0
 All Data Structures Files Functions Variables Enumerations Macros Pages
Functions
al_decompose.c File Reference

ArrayLib functions to decompose the domain among the MPI processes. More...

#include "al_hidden.h"

Functions

int AL_Find_decomp_ (int sz_ptr, int mode, int *procs)
 
int AL_Global_to_local_ (int sz_ptr)
 
int AL_Decomp1d_ (int gdim, int lproc, int lloc, int *start, int *end)
 
int AL_Decompose (int sz_ptr, int *procs, int mode)
 

Detailed Description

ArrayLib functions to decompose the domain among the MPI processes.

Authors
A. Malagoli (University of Chicago)
G. Muscianisi (g.mus.nosp@m.cian.nosp@m.isi@c.nosp@m.inec.nosp@m.a.it)
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Aug 24, 2012

Function Documentation

int AL_Decomp1d_ ( int  gdim,
int  lproc,
int  lloc,
int *  start,
int *  end 
)

Decompose a 1D array, given the number of processors along the direction

Parameters
[in]gdiminteger size of the global dimension
[in]lprocinteger size of the number of processors along the dimension
[in]llocinteger location of this node along the dimension
[out]startinteger pointer to start address for the array (C-convention)
[out]endinteger pointer to end address for the array (C-convention)
int AL_Decompose ( int  sz_ptr,
int *  procs,
int  mode 
)

Create a distributed array descriptor and compile it

Parameters
[in]sz_ptrinteger pointer to the distributed array descriptor
[in,out]procsarray with the processor decomposition
[in]modeavailable value:
AL_AUTO_DECOMP (internal decomposition) [Only for powers of two dimensions];
AL_MPI_DECOMP (MPI decomposition);
AL_USER_DECOMP (user defined)

Bug fixed on Aug 26, 2012: When the global view of the file for a staggered variable is computed, the gdims[nd] has to be computed and then passed to the function AL_Type_create_subarray.

Since gdims[nd]=s->arrdim[nd], and in s->arrdim[nd] is taking into account that the variable is staggered, we comment the line "gdims[istag]++;" because it is no more needed.

Bug fixed on Aug 26, 2012: The following "if" has been modified:

OLD version: if (s->beg[istag] == s->bg[istag]) { ldims[istag]++; }else{ starts[istag]++; }

NEW version: if (s->beg[istag] == s->bg[istag]) { }else{ starts[istag]++; ldims[istag]–; }

  • "ldims[istag]++;" has been cancelled from the firt part of the if for the same motivation explaned before;
  • "ldims[istag]–;" has been added in the second part of the if because in PLUTO the index of the staggered variables start from -1, while in the ArrayLib they start from 0.

Bugs fixed on Aug 26, 2012: The following if has been modified:

OLD version: if (s->beg[istag] == s->bg[istag]) { ldims[istag]++; starts[istag]–; }

NEW version: if (s->beg[istag] == s->bg[istag]) { }else{ ldims[istag]–; starts[istag]++; }

  • "ldims[istag]++;" has been cancelled from the firt part of the if because when the local subarray for the MPI_Set_write_all for a staggered variable is computed, the ldims[nd] has to be computed and then passed to the function AL_Type_create_subarray. Since ldims[nd]=s->larrdim[nd], and in s->larrdim[nd] is taking into account that the variable is staggered, we remouved the line "ldims[istag]++;" because it is no more needed;
  • "starts[istag]–;" has been cancelled from the first part of the if because in PLUTO the indexes for the staggered variables start locally from -1, while in ArrayLib they start from 0;
  • the "else" has been added to take into account the motivation explaned in the point before.
int AL_Find_decomp_ ( int  sz_ptr,
int  mode,
int *  procs 
)

Find the decomposition for a distributed array given its global size and the number of nodes

Parameters
[in]sz_ptrinteger pointer to the SZ structure
[in]modemode parameter: AL_AUTO_DECOMP, AL_MPI_DECOMP, AL_USER_DECOMP
[in,out]procsarray of processor decomposition
int AL_Global_to_local_ ( int  sz_ptr)

Compute addresses of local portions of array from global dimensions and processor decomposition

Parameters
[in]sz_ptrinteger pointer to SZ structure

Bug fixed on Dec 7, 2011: The lines:

if( s->isstaggered[i] == AL_TRUE ){ s->lend[i] = (end-start+1+s->lbeg[i]);}

if( s->isstaggered[i] == AL_TRUE ){ s->larrdim_gp[i] = (end-start+1+s->bg[i]+s->eg[i]+1);}

if( s->isstaggered[i] == AL_TRUE ){ s->larrdim[i] = (end-start+1+1);}

have been added to manage in the right way the correspondence among global and local indeces for staggered variables.