コード例 #1
0
ファイル: globalregt.cpp プロジェクト: syc0n/nanox
void global_reg_t::fillDimensionData( nanos_region_dimension_internal_t *region) const {
   RegionNode *n = key->getRegionNode( id );
   std::vector< std::size_t > const &sizes = key->getDimensionSizes();
   for ( int dimIdx = key->getNumDimensions() - 1; dimIdx >= 0; dimIdx -= 1 ) {
      std::size_t accessedLength = n->getValue();
      n = n->getParent();
      std::size_t lowerBound = n->getValue();
      n = n->getParent();
      region[ dimIdx ].accessed_length = accessedLength;
      region[ dimIdx ].lower_bound = lowerBound;
      region[ dimIdx ].size = sizes[ dimIdx ];
   }
}
コード例 #2
0
ファイル: globalregt.cpp プロジェクト: syc0n/nanox
std::size_t global_reg_t::getDataSize() const {
   RegionNode *n = key->getRegionNode( id );
   std::size_t dataSize = 1;

   for ( int dimIdx = key->getNumDimensions() - 1; dimIdx >= 0; dimIdx -= 1 ) {
      std::size_t accessedLength = n->getValue();
      n = n->getParent();
      n = n->getParent();
      dataSize *= accessedLength;
   }
   return dataSize; 
}
コード例 #3
0
ファイル: globalregt.cpp プロジェクト: syc0n/nanox
std::size_t global_reg_t::getBreadth() const {
   RegionNode *n = key->getRegionNode( id );
   std::size_t offset = 0;
   std::size_t lastOffset = 0;
   std::vector< std::size_t > const &sizes = key->getDimensionSizes();
   uint64_t acumSizes = 1;

   for ( unsigned int dimIdx = 0; dimIdx < key->getNumDimensions() - 1; dimIdx += 1 ) {
      acumSizes *= sizes[ dimIdx ];
   }
   
   for ( int dimIdx = key->getNumDimensions() - 1; dimIdx >= 0; dimIdx -= 1 ) {
      std::size_t accessedLength = n->getValue();
      n = n->getParent();
      std::size_t lowerBound = n->getValue();
      n = n->getParent();
      offset += acumSizes * lowerBound;
      lastOffset += acumSizes * ( lowerBound + accessedLength - 1 );
      if ( dimIdx >= 1 ) acumSizes = acumSizes / sizes[ dimIdx - 1 ];
   }
   return ( lastOffset - offset ) + 1;
}
コード例 #4
0
ファイル: globalregt.cpp プロジェクト: syc0n/nanox
reg_t global_reg_t::getFitRegionId() const {
   RegionNode *n = key->getRegionNode( id );
   bool keep_fitting = true;
   nanos_region_dimension_internal_t fitDimensions[ key->getNumDimensions() ];
   std::vector< std::size_t > const &sizes = key->getDimensionSizes();

   for ( int idx = key->getNumDimensions() - 1; idx >= 0; idx -= 1 ) {
      std::size_t accessedLength = n->getValue();
      n = n->getParent();
      std::size_t lowerBound = n->getValue();
      n = n->getParent();
      fitDimensions[ idx ].size = sizes[ idx ];
      if ( keep_fitting ) {
         fitDimensions[ idx ].accessed_length = accessedLength;
         fitDimensions[ idx ].lower_bound = lowerBound;
         if ( accessedLength != 1 )
            keep_fitting = false;
      } else {
         fitDimensions[ idx ].lower_bound = 0;
         fitDimensions[ idx ].accessed_length = sizes[ idx ];
      }
   }
   return key->obtainRegionId( fitDimensions );
}
コード例 #5
0
ファイル: globalregt.cpp プロジェクト: syc0n/nanox
reg_t global_reg_t::getSlabRegionId( std::size_t slabSize ) const {
   RegionNode *n = key->getRegionNode( id );
   std::vector< std::size_t > const &sizes = key->getDimensionSizes();
   std::size_t acc_size = 1;
   nanos_region_dimension_internal_t fitDimensions[ key->getNumDimensions() ];
   if ( slabSize < this->getBreadth() ) {
      fatal("Can not allocate slab for this region. Not supported yet. slabSize "<< slabSize << " breadth " << this->getBreadth());
   } else if ( this->getBreadth() < slabSize && id == 1 ) {
      return id;
   } else {

      unsigned int lower_bounds[key->getNumDimensions()];
      for ( int idx = key->getNumDimensions() - 1; idx >= 0; idx -= 1 ) {
         //std::size_t accessedLength = n->getValue();
         n = n->getParent();
         std::size_t lowerBound = n->getValue();
         n = n->getParent();
         lower_bounds[idx] = lowerBound;
      }

      bool keep_expanding = true;
      for ( unsigned int idx = 0; idx < key->getNumDimensions(); idx += 1 ) {
         fitDimensions[ idx ].size = sizes[ idx ];
         //std::cerr << "This dimension size " << sizes[ idx ] << std::endl;
         if ( keep_expanding ) {
            acc_size *= sizes[ idx ];
         //std::cerr << "This dimension acc_size " << acc_size << " slab size " << slabSize << std::endl;
            if ( slabSize == acc_size || ( slabSize > acc_size && ( ( slabSize % acc_size ) == 0 ) ) ) {
               fitDimensions[ idx ].lower_bound = 0;
               fitDimensions[ idx ].accessed_length = sizes[ idx ];
            } else if ( slabSize < acc_size && ( acc_size % slabSize ) == 0 ) {
               std::size_t slab_elems = slabSize / ( acc_size / sizes[ idx ] );
               //std::cerr << "slab_elems is " << slab_elems << " lb: " <<  lower_bounds[idx] << std::endl;
               fitDimensions[ idx ].accessed_length = slab_elems;
               fitDimensions[ idx ].lower_bound = ( lower_bounds[idx] / slab_elems ) * slab_elems;
               keep_expanding = false;
            } else {
               fatal("invalid slabSize: " << slabSize << " reg size is " << this->getBreadth() );
            }
         } else {
            fitDimensions[ idx ].accessed_length = 1;
            fitDimensions[ idx ].lower_bound = 1;
         }
      }
      (void ) fitDimensions;
   }
   return key->obtainRegionId( fitDimensions );
}
コード例 #6
0
ファイル: globalregt.cpp プロジェクト: syc0n/nanox
uint64_t global_reg_t::getFirstAddress( uint64_t baseAddress ) const {
   RegionNode *n = key->getRegionNode( id );
   uint64_t offset = 0;
   std::vector< std::size_t > const &sizes = key->getDimensionSizes();
   uint64_t acumSizes = 1;

   for ( unsigned int dimIdx = 0; dimIdx < key->getNumDimensions() - 1; dimIdx += 1 ) {
      acumSizes *= sizes[ dimIdx ];
   }
   
   for ( int dimIdx = key->getNumDimensions() - 1; dimIdx >= 0; dimIdx -= 1 ) {
      //std::size_t accessedLength = n->getValue();
      n = n->getParent();
      std::size_t lowerBound = n->getValue();
      n = n->getParent();
      offset += acumSizes * lowerBound;
      if ( dimIdx >= 1 ) acumSizes = acumSizes / sizes[ dimIdx - 1 ];
   }
   return baseAddress + offset; 
}