Exemple #1
0
int main(int argc, char* argv[])
{
  int rank;
  int namelen;
  char procname[MPI_MAX_PROCESSOR_NAME];

  MPI_Init(&argc, &argv);

  MPI_Comm_rank(MPI_COMM_WORLD, &rank);

  MPI_Get_processor_name( procname, &namelen );

  MPIX_Hardware_t hw;
  MPIX_Hardware(&hw);

  printf("%d: processor name = %s, Size = {%2d,%2d,%2d,%2d,%1d}, Coords = {%2d,%2d,%2d,%2d,%1d}, isTorus = {%1d,%1d,%1d,%1d,%1d} \n",
         rank, procname,
         hw.Size[0], hw.Size[1], hw.Size[2], hw.Size[3], hw.Size[4],
         hw.Coords[0], hw.Coords[1], hw.Coords[2], hw.Coords[3], hw.Coords[4],
         hw.isTorus[0], hw.isTorus[1], hw.isTorus[2], hw.isTorus[3], hw.isTorus[4]);

  fflush(stdout);

  MPI_Finalize();

  return 0;
}
Exemple #2
0
void z_mpi_get_cart_topology(int *ndims, int *dims, int *torus, int *pos) /* z_proto, z_func z_mpi_get_cart_topology */
{
  int _ndims, _dims[MAX_CART_NDIMS], _torus[MAX_CART_NDIMS], _pos[MAX_CART_NDIMS];

#if defined(HAVE__BGP_PERSONALITY_T)

  /* BlueGene/P */

  _BGP_Personality_t personality;


  _ndims = 4;

  if (dims == NULL || torus == NULL || pos == NULL) goto exit_ndims_only;

  Kernel_GetPersonality(&personality, sizeof(personality));

  _dims[0] = personality.Network_Config.Xnodes;
  _dims[1] = personality.Network_Config.Ynodes;
  _dims[2] = personality.Network_Config.Znodes;

  _torus[0] = BGP_Personality_isTorusX(&personality);
  _torus[1] = BGP_Personality_isTorusY(&personality);
  _torus[2] = BGP_Personality_isTorusZ(&personality);

  _pos[0] = personality.Network_Config.Xcoord;
  _pos[1] = personality.Network_Config.Ycoord;
  _pos[2] = personality.Network_Config.Zcoord;

  switch (personality.Kernel_Config.ProcessConfig)
  {
    case _BGP_PERS_PROCESSCONFIG_SMP:
      _dims[3] = 1;
      break;
    case _BGP_PERS_PROCESSCONFIG_VNM:
      _dims[3] = 4;
      break;
    case _BGP_PERS_PROCESSCONFIG_2x2:
      _dims[3] = 2;
      break;
    default:
      _dims[3] = 1;
      break;
  }

  _torus[3] = (_torus[0] || _torus[1] || _torus[2]);

  _pos[3] = Kernel_PhysicalProcessorID();

#elif defined(HAVE_MPIX_HARDWARE_T)

  /* BlueGene/Q */

  int i;
  MPIX_Hardware_t hw;


  _ndims = MPIX_TORUS_MAX_DIMS + 1;

  if (dims == NULL || torus == NULL || pos == NULL) goto exit_ndims_only;

  MPIX_Hardware(&hw);

  _torus[MPIX_TORUS_MAX_DIMS] = 0;

  for (i = 0; i < MPIX_TORUS_MAX_DIMS; ++i)
  {
    _dims[i] = hw.Size[i];
    _torus[i] = hw.isTorus[i]?1:0;
    _pos[0] = hw.Coords[i];

    if (_torus[i]) _torus[MPIX_TORUS_MAX_DIMS] = 1;
  }

  _dims[MPIX_TORUS_MAX_DIMS] = hw.ppn;

  _pos[MPIX_TORUS_MAX_DIMS] = hw.coreID;

#else

  /* MPI */

  MPI_Comm comm;
  int size, rank;


  _ndims = 3;

  if (dims == NULL || torus == NULL || pos == NULL) goto exit_ndims_only;

  comm = MPI_COMM_WORLD;
  MPI_Comm_size(comm, &size);
  MPI_Comm_rank(comm, &rank);

  _dims[0] = 0;
  _dims[1] = 0;
  _dims[2] = 0;

  MPI_Dims_create(size, 3, _dims);

  _pos[2] = (rank / (1))                       % _dims[2];
  _pos[1] = (rank / (1 * _dims[2]))            % _dims[1];
  _pos[0] = (rank / (1 * _dims[2] * _dims[1])) % _dims[0];

  _torus[0] = 0;
  _torus[1] = 0;
  _torus[2] = 0;
#endif

  if (*ndims <= 0) *ndims = _ndims;

  z_mpi_remap_cart_topology(_ndims, _dims, _torus, _pos, *ndims, dims, torus, pos);

exit_ndims_only:

  *ndims = _ndims;
}