コード例 #1
0
ファイル: layout_hyper_sl32.c プロジェクト: andypea/MILC
/*--------------------------------------------------------------------*/
static void setup_qmp_grid(){
  int ndim = 4;
  int len[4];
  int ndim2, i;
  const int *nsquares2;

  len[0] = nx; len[1] = ny; len[2] = nz; len[3] = nt;

  if(mynode()==0){
    printf("qmp_grid,");
    printf("\n");
  }

  ndim2 = QMP_get_allocated_number_of_dimensions();
  nsquares2 = QMP_get_allocated_dimensions();

  /* If the dimensions are not already allocated, use the
     node_geometry request.  Otherwise a hardware or command line
     specification trumps the parameter input. */
#ifdef FIX_NODE_GEOM
  if(ndim2 == 0){
    ndim2 = 4;
    nsquares2 = node_geometry;
  }
  else{
    node0_printf("setup_qmp_grid: Preallocated machine geometry overrides request\n");
  }
#endif

  if(mynode()==0){
    printf("Using machine geometry: ");
    for(i=0; i<ndim; i++){
      printf("%d ",nsquares2[i]);
      if(i < ndim-1)printf("X ");
    }
    printf("\n");
  }

  /* In principle, we could now rotate coordinate axes */
  /* Save this for a future upgrade */

  set_qmp_layout_grid(nsquares2, ndim2);

  ndim2 = QMP_get_logical_number_of_dimensions();
  nsquares2 = QMP_get_logical_dimensions();

  for(i=0; i<ndim; i++) {
    if(i<ndim2) nsquares[i] = nsquares2[i];
    else nsquares[i] = 1;
  }

  for(i=0; i<ndim; i++) {
    if(len[i]%nsquares[i] != 0) {
      node0_printf("LATTICE SIZE DOESN'T FIT GRID\n");
      QMP_abort(0);
    }
    squaresize[i] = len[i]/nsquares[i];
  }
}
コード例 #2
0
ファイル: qlayout.c プロジェクト: usqcd-software/qlua
static void
eo_setup(QDP_Lattice *lat, void *args)
{
    mLattice *S = args;
    QDP_allocate_lattice_params(lat, sizeof (params));
    params *p = QDP_get_lattice_params(lat);

    p->S = S;

    if (QMP_get_msg_passing_type() != QMP_SWITCH) {
        int nd2 = QMP_get_allocated_number_of_dimensions();
        const int *nsquares2 = QMP_get_allocated_dimensions();
        int i;

        for (i = 0; i < S->rank; i++) {
            S->net[i] = (i < nd2) ? nsquares2[i] : 1;
        }
    } else { /* not QMP_GRID */
        int squaresize[QLUA_MAX_LATTICE_RANK];
        int extrafactors[QLUA_MAX_LATTICE_RANK];
        int i;
        for (i = 0; i < S->rank; i++) {
            squaresize[i] = S->dim[i];
            extrafactors[i] = 1;
            S->net[i] = 1;
        }

        /* Figure out dimensions of rectangle */
        int n = QMP_get_number_of_nodes();   /* nodes to factor */
        int k = MAXPRIMES-1;
        while (n > 1) {
            /* figure out which prime to divide by starting with largest */
            /* if no factor found, assume n is prime */
            while ((k >= 0) && (n % prime[k] != 0)) --k;
            int pfac = (k>=0) ? prime[k] : n;

            /* figure out which direction to divide */
            /* find largest divisible dimension of h-cubes */
            /* if one direction with largest dimension has already been
               divided, divide it again.  Otherwise divide first direction
               with largest dimension. */
            int j = -1;
            int i;
            for (i = 0; i < S->rank; i++) {
                if (squaresize[i] % pfac == 0) {
                    if ((j<0) ||
                        (extrafactors[j] * squaresize[i] > 
                         extrafactors[i] * squaresize[j])) {
                        j = i;
                    } else if (extrafactors[j] * squaresize[i] == 
                               extrafactors[i] * squaresize[j]) {
                        if ((S->net[j] == 1) || (S->net[i] != 1))
                            j = i;
                    }
                }
            }

            /* This can fail if we run out of prime factors in the dimensions */
            /* then just choose largest dimension */
            if (j < 0) {
                int i;
                for (i = 0; i < S->rank; i++) {
                    if ((j<0) ||
                        (extrafactors[j] * squaresize[i] >
                         extrafactors[i] * squaresize[j]) ) {
                        j = i;
                    } else if (extrafactors[j] * squaresize[i] ==
                               extrafactors[i] * squaresize[j]) {
                        if((S->net[j] == 1) || (S->net[i] != 1))
                            j = i;
                    }
                }
                n /= pfac;
                extrafactors[j] *= pfac;
                S->net[j] *= pfac;
            } else {
                n /= pfac;
                squaresize[j] /= pfac;
                S->net[j] *= pfac;
            }
        }
    } /* not QMP_GRID */

    int mc[QLUA_MAX_LATTICE_RANK];
    int i;

    S->node = QDP_this_node;
    node2coord(mc, QDP_this_node, S);

    for (i = 0; i < S->rank; i++) {
        int x = mc[i];

        mc[i] = x + 1;
        if (mc[i] == S->net[i])
            mc[i] = 0;
        S->neighbor_up[i] = coord2node(mc, S);

        mc[i] = x - 1;
        if (mc[i] < 0)
            mc[i] = S->net[i] - 1;
        S->neighbor_down[i] = coord2node(mc, S);

        mc[i] = x;
    }
}
コード例 #3
0
ファイル: sysfunc.C プロジェクト: DeanHowarth/QUDA-CPS
void init_qmp(int * argc, char ***argv) {

#if 0
  printf("init_qmp(%d %p)\n",*argc,*argv);
  for(int i = 0; i<*argc;i++){
    printf("argv[%d](before)=%s\n",i,(*argv)[i]); 
  }
#endif

#if 0
   spi_init();
#endif
  
    QMP_thread_level_t prv;
#ifndef UNIFORM_SEED_NO_COMMS
    QMP_status_t init_status = QMP_init_msg_passing(argc, argv, QMP_THREAD_SINGLE, &prv);
    if (init_status) printf("QMP_init_msg_passing returned %d\n",init_status);
    peRank = QMP_get_node_number();
    peNum = QMP_get_number_of_nodes();
    if(!peRank)printf("QMP_init_msg_passing returned %d\n",init_status);

    if (init_status != QMP_SUCCESS) {
      QMP_error("%s\n",QMP_error_string(init_status));
    }

    // check QMP thread level
    // Added by Hantao
    if(peRank == 0) {
        switch(prv) {
        case QMP_THREAD_SINGLE:
            printf("QMP thread level = QMP_THREAD_SINGLE\n");
            break;
        case QMP_THREAD_FUNNELED:
            printf("QMP thread level = QMP_THREAD_FUNNELED\n");
            break;
        case QMP_THREAD_SERIALIZED:
            printf("QMP thread level = QMP_THREAD_SERIALIZED\n");
            break;
        case QMP_THREAD_MULTIPLE:
            printf("QMP thread level = QMP_THREAD_MULTIPLE\n");
            break;
        default:
            printf("QMP thread level = no idea what this is, boom!\n");
        }
    }

    //Check to make sure that this machine is a GRID machine
    //Exit if not GRID machine
    QMP_ictype qmp_type = QMP_get_msg_passing_type();

    //Get information about the allocated machine
    peNum = QMP_get_number_of_nodes();
    NDIM = QMP_get_allocated_number_of_dimensions();
    peGrid = QMP_get_allocated_dimensions();
    pePos = QMP_get_allocated_coordinates();

    if(peRank==0){
      for(int i = 0; i<*argc;i++){
        printf("argv[%d])(after)=%s\n",i,(*argv)[i]); 
      }
    }
#else
    QMP_status_t init_status = QMP_SUCCESS;
    peRank=0;
    peNum=1;
    NDIM=4;
#endif

//#if (TARGET == BGL) || (TARGET == BGP)
  if (NDIM>5){
    peNum = 1;
    for(int i = 0;i<5;i++)
	peNum *= peGrid[i];
    peRank = peRank % peNum;
  }
  int if_print=1;
  for(int i = 0;i<NDIM;i++)
  if (pePos[i]>=2) if_print=0;

  if (if_print){
      printf("Rank=%d Num=%d NDIM=%d\n",peRank,peNum,NDIM);
      printf("dim:");
      for(int i = 0;i<NDIM;i++)
        printf(" %d",peGrid[i]);
      printf("\n");
      printf("pos:");
      for(int i = 0;i<NDIM;i++)
        printf(" %d",pePos[i]);
      printf("\n");

#if 0
    int rc;
    BGLPersonality pers;
    rts_get_personality(&pers, sizeof(pers));
    printf("from personality: %d %d %d %d\n",pers.xCoord,pers.yCoord,pers.zCoord,rts_get_processor_id());
#endif
  }


//     printf("from personality:\n");

#if 0
    if ( (qmp_type!= QMP_GRID) && (qmp_type !=QMP_MESH)  ) {
      QMP_error("CPS on QMP only implemented for GRID or MESH, not (%d) machines\n",qmp_type);
    }
#endif

//     printf("QMP_declare_logical_topology(peGrid, NDIM)\n");
#ifndef UNIFORM_SEED_NO_COMMS
    //Declare the logical topology (Redundant for GRID machines)
    if (QMP_declare_logical_topology(peGrid, NDIM) != QMP_SUCCESS) {
      QMP_error("Node %d: Failed to declare logical topology\n",peRank);
      exit(-4);
    }
#endif
    initialized = true;
  printf("Rank=%d init_qmp() done\n",peRank);
    
  }