示例#1
0
/* Map node number and index to coordinates  */
void get_coords(int coords[], int node, int index){
  int mc[4];
  int ir;
  int eo;
  int k = node;

  /* Compute machine coordinates for node */
  lex_coords(mc, 4, machine_dimensions, k);

  /* Lexicographic index on node rounded to even */
  ir = 2*index;
  if(ir >= sites_on_node){
    ir -= sites_on_node;
    eo = 1;
  }
  else
    eo = 0;

  /* Convert to coordinates - result is two-fold ambiguous */
  lex_coords(coords, 4, sub_lattice_dimensions, ir);

  /* Adjust coordinate according to parity (assumes even sites_on_node) */
  if( (coords[0] + coords[1] + coords[2] + coords[3]) % 2 != eo){
    coords[0]++;
    if(coords[0] >= sub_lattice_dimensions[0]){
      coords[0] -= sub_lattice_dimensions[0];
      coords[1]++;
      if(coords[1] >= sub_lattice_dimensions[1]){
	coords[1] -= sub_lattice_dimensions[1];
	coords[2]++;
	if(coords[2] >= sub_lattice_dimensions[2]){
	  coords[2] -= sub_lattice_dimensions[2];
	  coords[3]++;
	}
      }
    }
  }

  /* Add offset for hypercube */
  coords[0] += mc[0]*sub_lattice_dimensions[0];
  coords[1] += mc[1]*sub_lattice_dimensions[1];
  coords[2] += mc[2]*sub_lattice_dimensions[2];
  coords[3] += mc[3]*sub_lattice_dimensions[3];

  /* Consistency checks for debugging */
  if((k = node_number(coords[0], coords[1], coords[2], coords[3])) 
     != node){
    printf("get_coords: coords %d %d %d %d for node %d map to wrong node %d\n",
	   coords[0], coords[1], coords[2], coords[3], node, k);
    terminate(1);
  }
  if((k = node_index(coords[0], coords[1], coords[2], coords[3]))
      != index){
    printf("get_coords: coords %d %d %d %d for index %d map to wrong index %d\n",
	   coords[0], coords[1], coords[2], coords[3], index, k);
    terminate(1);
  }
}
示例#2
0
static void ft_get_coords(int coords[], int node, int index, 
			  int dirp[], int squaresize[], int nsquares[]){
  int mc[NDIM];
  int dir;

  /* coords = the sublattice coordinate */
  lex_coords(dirp, coords, NDIM, squaresize, index);

  /* mc = the machine coordinates for node k */
  lex_coords(dirp, mc, NDIM, nsquares, node);

  /* Add offset to get full lattice coordinate */
  for(dir = 0; dir < NDIM; dir++)
    coords[dir] += mc[dir]*squaresize[dir];
}
示例#3
0
/* Map any node to its I/O node */
int io_node(const int node){
  int i,j,k; 

  /* Get the machine coordinates for the specified node */
  lex_coords(io_node_coords, 4, machine_dimensions, node);

  /* Round the node coordinates down to get the io_node coordinate */
  for(i = 0; i < 4; i++)
    io_node_coords[i] = nodes_per_ionode[i] * 
      (io_node_coords[i]/nodes_per_ionode[i]);
  
  /* Return the linearized machine coordinates of the I/O node */
  return (int)lex_rank(io_node_coords, 4, machine_dimensions);
}
示例#4
0
/* Map any node to its I/O node */
int io_node(const int node){
  int i; 
  int io_node_coords[4];

  /* If we don't have I/O partitions, each node does its own I/O */
  if(ionodegeomvals == NULL)
    return node;

  /* Get the machine coordinates for the specified node */
  lex_coords(io_node_coords, 4, dim_mach, node);

  /* Round the node coordinates down to get the io_node coordinate */
  for(i = 0; i < 4; i++)
    io_node_coords[i] = nodes_per_ionode[i] * 
      (io_node_coords[i]/nodes_per_ionode[i]);
  
  /* Return the linearized machine coordinates of the I/O node */
  return (int)lex_rank(io_node_coords, 4, dim_mach);
}
示例#5
0
/* Map node number and index to coordinates  */
void get_coords(int coords[], int node, int index){
  int mc[4];
  int ir,kr,d,eo;
  int k = node;

  /* Compute machine coordinates for node */
  lex_coords(mc, 4, nsquares, k);

  /* Lexicographic index of hypercube, rounded to even */
  ir = 2*(index % subl_sites_on_node);
  /* "32-color" index */
  kr = index/subl_sites_on_node;

  if(kr >= 16){
    kr -= 16;
    eo = 1;
  }
  else
    eo = 0;

  /* First get sublattice coordinates */
  for(d = XUP; d <= TUP; d++){
    coords[d] = ir % (squaresize[d]/2);
    ir /= (squaresize[d]/2);
  }

  /* Adjust sublattice coordinates according to its parity */
  if( (coords[XUP] + coords[YUP] + coords[ZUP] + coords[TUP]) % 2 != eo){
    coords[XUP]++;
    if(coords[XUP] >= squaresize[XUP]/2){
      coords[XUP] -= squaresize[XUP]/2; coords[YUP]++;
      if(coords[YUP] >= squaresize[YUP]/2){
	coords[YUP] -= squaresize[YUP]/2; coords[ZUP]++;
	if(coords[ZUP] >= squaresize[ZUP]/2){
	  coords[ZUP] -= squaresize[ZUP]/2; coords[TUP]++;
	}
      }
    }
  }

  /* Next convert to the site coordinate relative to the origin of the
     node hypercube */
  for(d = XUP; d <= TUP; d++){
    coords[d] = 2*coords[d] + kr % 2;
    kr /= 2;
  }

  /* Finally add offset for node hypercube origin */
  coords[XUP] += mc[XUP]*squaresize[XUP];
  coords[YUP] += mc[YUP]*squaresize[YUP];
  coords[ZUP] += mc[ZUP]*squaresize[ZUP];
  coords[TUP] += mc[TUP]*squaresize[TUP];

  /* Consistency checks for debugging */
  if((k = node_number(coords[0], coords[1], coords[2], coords[3])) 
     != node){
    printf("get_coords: coords %d %d %d %d for node %d index %d map to wrong node %d\n",
	   coords[0], coords[1], coords[2], coords[3], node, index, k);
    terminate(1);
  }
  if((k = node_index(coords[0], coords[1], coords[2], coords[3]))
      != index){
    printf("get_coords: coords %d %d %d %d for node %d index %d map to wrong index %d\n",
	   coords[0], coords[1], coords[2], coords[3], node, index, k);
    terminate(1);
  }
}
示例#6
0
void setup_layout(){
  int k = mynode();
#ifdef FIX_NODE_GEOM
  int *geom = node_geometry;
#else
  int *geom = NULL;
#endif

  if(k == 0)
    printf("LAYOUT = Hypercubes, options = ");

#ifdef HAVE_QMP
  /* QMP treatment */
  /* Is there already a grid? 
     This could be a grid architecture with a preset dimension, or
     a geometry could have been set by the -qmp-geom command line arg. 
     In either case we have a nonzero allocated number of dimensions. 
*/
  if(QMP_get_allocated_number_of_dimensions() == 0)
    /* Set the geometry if requested */
    set_qmp_layout_grid(geom, 4);

  /* Has a grid been set up now? */
  if(QMP_get_msg_passing_type() == QMP_GRID)
    setup_qmp_grid();
  else if(geom != NULL)
    setup_fixed_geom(geom, 4);
  else
    setup_hyper_prime();

#else

  /* Non QMP treatment */
  if(geom != NULL)
    setup_fixed_geom(geom, 4);
  else
    setup_hyper_prime();

#endif

#ifdef FIX_IONODE_GEOM
  /* Initialize I/O node function */
  init_io_node();
#endif
  
  /* Compute machine coordinates for this node */
  lex_coords(machine_coordinates, 4, nsquares, k);

  /* Number of sites on node */
  sites_on_node =
    squaresize[XUP]*squaresize[YUP]*squaresize[ZUP]*squaresize[TUP];

  /* Need number of sites per hypercube divisible by 32 */
  if( mynode()==0)if( sites_on_node%32 != 0){
    printf("SORRY, CAN'T LAY OUT THIS LATTICE\n");
    terminate(0);
  }
  subl_sites_on_node = sites_on_node/32;
  if( mynode()==0)
    printf("ON EACH NODE %d x %d x %d x %d\n",squaresize[XUP],squaresize[YUP],
	   squaresize[ZUP],squaresize[TUP]);

  /* Actually we have already required sites_on_node to be a multiple of 32 */
  if( mynode()==0 && sites_on_node%2 != 0)
    printf("WATCH OUT FOR EVEN/ODD SITES ON NODE BUG!!!\n");
  even_sites_on_node = odd_sites_on_node = sites_on_node/2;
}