Exemplo n.º 1
0
// data access
void referenceData(long long int address){
	long long int setNumber = getBits(address, nIndexBits, nBlockBits);
	long long int tag = getBits(address, 64 - nIndexBits - nBlockBits, nIndexBits + nBlockBits);

	LINE *foundPos = posIn(tag, sets[setNumber]); //foundPos is position of corresponding line in cache
	// if address in in the cache
	if (foundPos != NULL){  //hit
		
		hit++;
		long long int tempTag = foundPos->tag;
		removeLine(foundPos, sets[setNumber]);
		append(tempTag, sets[setNumber]);
	}
	else {  // miss
		miss++;
		// if the cache is full then we need eviction by remove found line and append new address
		if (sets[setNumber]->numLines == nLines) {    // eviction
			eviction++;
			removeLine(sets[setNumber]->firstLine, sets[setNumber]);
			append(tag, sets[setNumber]);
		} else {
		    sets[setNumber]->numLines++;
			append(tag, sets[setNumber]);
		}
	}
}
Exemplo n.º 2
0
  void HDFWalkerIOEngine::read(hid_t grp, const char* name) 
  {
    const int RANK = 3;
    hsize_t count[RANK], offset[]={0,0,0};

    hid_t dataset = H5Dopen(grp,name);
    hid_t dataspace = H5Dget_space(dataset);
    int rank = H5Sget_simple_extent_ndims(dataspace);
    int status_n = H5Sget_simple_extent_dims(dataspace, count, NULL);

    vector<MCWalkerConfiguration::PosType> posIn(count[0]*count[1]);

    hid_t memspace = H5Screate_simple(RANK, count, NULL);
    herr_t status = H5Sselect_hyperslab(dataspace,H5S_SELECT_SET, offset,NULL,count,NULL);
    status = H5Dread(dataset, H5T_NATIVE_DOUBLE, memspace, dataspace, H5P_DEFAULT, &(posIn[0][0]));

    H5Sclose(dataspace);
    H5Sclose(memspace);
    H5Dclose(dataset);

    int curWalker = W.getActiveWalkers();
    if(curWalker) {
      W.createWalkers(count[0]);
    } else {
      W.resize(count[0],count[1]);
    }

    MCWalkerConfiguration::iterator it = W.begin()+curWalker; 
    int ii=0;
    for(int iw=0; iw<count[0]; iw++) {
      //std::copy(Post_temp[iw],Post_temp[iw+1], (*it)->R.begin());
      for(int iat=0; iat < count[1]; iat++,ii++){
        (*it)->R(iat) = posIn[ii];
      }
      ++it;
    }
  }
Exemplo n.º 3
0
  void HDFWalkerIOEngine::readAll(hid_t grp, const char* name, Communicate* comm) 
  {
    int mynode=comm->rank();
    int nprocs=comm->size();
    vector<int> woffset(nprocs+1,0);

    const int RANK = 3;
    hsize_t offset[]={1,1,1};
    hsize_t gcount[RANK],count[RANK];
    hsize_t stride[]={1,1,1};

    hid_t dataset = H5Dopen(grp,name);
    hid_t dataspace = H5Dget_space(dataset);
    int rank_n = H5Sget_simple_extent_ndims(dataspace);
    int status_n = H5Sget_simple_extent_dims(dataspace, gcount, NULL);

    //assign offsets and size
    FairDivideLow(gcount[0],nprocs,woffset);
    offset[0]=woffset[mynode]; offset[1] = 0; offset[2] = 0;
    count[0]=woffset[mynode+1]-woffset[mynode];
    count[1]=gcount[1];
    count[2]=gcount[2];

    app_log() << "   Initial walker distribution: ";
    std::copy(woffset.begin(),woffset.end(),ostream_iterator<int>(app_log()," "));
    app_log() << endl;

    vector<MCWalkerConfiguration::PosType> posIn(count[0]*count[1]);

    hid_t memspace = H5Screate_simple(RANK, count, NULL);
    herr_t status = H5Sselect_hyperslab(dataspace,H5S_SELECT_SET, offset,NULL,count,NULL);

#if defined(H5_HAVE_PARALLEL)
    xfer_plist = H5Pcreate(H5P_DATASET_XFER);
    H5Pset_dxpl_mpio(xfer_plist,H5FD_MPIO_COLLECTIVE);
#else
    xfer_plist =  H5P_DEFAULT;
#endif
    hid_t type_id=get_h5_datatype(posIn[0][0]);
    status = H5Dread(dataset, type_id, memspace, dataspace, xfer_plist, &(posIn[0][0]));

    H5Sclose(dataspace);
    H5Sclose(memspace);
    H5Dclose(dataset);

#if defined(H5_HAVE_PARALLEL)
    H5Pclose(xfer_plist);
#endif

    int curWalker = W.getActiveWalkers();
    if(curWalker) {
      W.createWalkers(count[0]);
    } else {
      W.resize(count[0],count[1]);
    }

    MCWalkerConfiguration::iterator it = W.begin()+curWalker; 
    int ii=0;
    for(int iw=0; iw<count[0]; iw++) {
      //std::copy(Post_temp[iw],Post_temp[iw+1], (*it)->R.begin());
      for(int iat=0; iat < count[1]; iat++,ii++){
        (*it)->R(iat) = posIn[ii];
      }
      ++it;
    }
  }