Example #1
0
void MQMigrator::Translate( uint64_t address, uint64_t *row, uint64_t *col, uint64_t *bank,
                          uint64_t *rank, uint64_t *channel, uint64_t *subarray )
{
    /* Use the default -- We will only change the channel if needed. */
    AddressTranslator::Translate( address, row, col, bank, rank, channel, subarray );
	/**
    std::cout << "\nMQMigrator::Translate address " << std::hex << address << " To:\n" \
                                       "old channel " << *channel << "\n" \
                                       "rank " << *channel << "\n" \
                                       "bank " << *channel << "\n" \
                                       "row " << *channel << "\n" \
                                       "col " << *channel << "\n" \
                                       "subarray " << *channel << "\n" \
                                                   << std::endl; 
   	*/ 

	/* This should be a unique key for this address. */
    NVMAddress keyAddress;
    keyAddress.SetTranslatedAddress( *row, *col, *bank, *rank, *channel, *subarray );
    keyAddress.SetPhysicalAddress( address );
    uint64_t key = GetAddressKey( keyAddress );
	ncounter_t r_channel = *channel;
	if( access_times.count( r_channel)==0)
	{
		access_times[ r_channel]= 1;
	}   
	else
		access_times[r_channel]++;

    /* Check if the page was migrated and migration is complete. */
    if( migrationMap.count( key ) != 0 )
    {
        if( migrationState[key] == MQ_MIGRATION_DONE )
        {
            *channel = migrationMap[key];
  			
//			std::cout << "\n------new channel " << std::hex << *channel <<std::endl;

            migratedAccesses++;
        }
    }
	ncounter_t m_channel = *channel;
	if( migrate_access_times.count( m_channel)==0)
	{
		migrate_access_times[ m_channel]= 1;
	}   
	else
		migrate_access_times[m_channel]++;
}
void Migrator::Translate( uint64_t address, uint64_t *row, uint64_t *col, uint64_t *bank,
                          uint64_t *rank, uint64_t *channel, uint64_t *subarray )
{
    /* Use the default -- We will only change the channel if needed. */
    AddressTranslator::Translate( address, row, col, bank, rank, channel, subarray );

    
    /* This should be a unique key for this address. */
    NVMAddress keyAddress;
    keyAddress.SetTranslatedAddress( *row, *col, *bank, *rank, *channel, *subarray );
    keyAddress.SetPhysicalAddress( address );
    uint64_t key = GetAddressKey( keyAddress );

    /* Check if the page was migrated and migration is complete. */
    if( migrationMap.count( key ) != 0 )
    {
        if( migrationState[key] == MIGRATION_DONE )
        {
            *channel = migrationMap[key];

            migratedAccesses++;
        }
    }
}
Example #3
0
void CommonMigrator::ChooseVictim( Migrator *at, NVMAddress& /*promotee*/, NVMAddress& victim )
{
    /*
     *  Since this is no method called after every module in the system is 
     *  initialized, we check here to see if we have queried the memory system
     *  about the information we need.
     */
    if( !queriedMemory )
    {
        /*
         *  Our naive replacement policy will simply circle through all the pages
         *  in the fast memory. In order to count the pages we need to count the
         *  number of rows in the fast memory channel. We do this by creating a
         *  dummy request which would route to the fast memory channel. From this
         *  we can grab it's config pointer and calculate the page count.
         */
        NVMainRequest queryRequest;
		//set query request's channel to promotionChannel
        queryRequest.address.SetTranslatedAddress( 0, 0, 0, 0, promotionChannel, 0 );
        queryRequest.address.SetPhysicalAddress( 0 );
        queryRequest.type = READ;
        queryRequest.owner = this;

        NVMObject *curObject = NULL;
		//search all children of parent , only if find the child node that can cast to SubArray safely , 
		//and assign it to curObject(find Subarray Object ) 
        FindModuleChildType( &queryRequest, SubArray, curObject, parent->GetTrampoline( ) );

        SubArray *promotionChannelSubarray = NULL;
        promotionChannelSubarray = dynamic_cast<SubArray *>( curObject );

        assert( promotionChannelSubarray != NULL );
        Params *p = promotionChannelSubarray->GetParams( );
        promotionChannelParams = p;

        totalPromotionPages = p->RANKS * p->BANKS * p->ROWS;
        currentPromotionPage = totalPromotionPages;

        if( p->COLS != numCols )
        {
            std::cout << "Warning: Page size of fast and slow memory differs." << std::endl;
        }

        queriedMemory = true;
    }
    /*
     *  From the current promotion page, simply craft some translated address together
     *  as the victim address.
     */
    uint64_t victimRank, victimBank, victimRow, victimSubarray, subarrayCount;
    ncounter_t promoPage = currentPromotionPage;

    victimRank = promoPage % promotionChannelParams->RANKS;
    promoPage >>= NVM::mlog2( promotionChannelParams->RANKS );

    victimBank = promoPage % promotionChannelParams->BANKS;
    promoPage >>= NVM::mlog2( promotionChannelParams->BANKS );

    subarrayCount = promotionChannelParams->ROWS / promotionChannelParams->MATHeight;
    victimSubarray = promoPage % subarrayCount;
    promoPage >>= NVM::mlog2( subarrayCount );

    victimRow = promoPage;

    victim.SetTranslatedAddress( victimRow, 0, victimBank, victimRank, promotionChannel, victimSubarray );
    uint64_t victimAddress = at->ReverseTranslate( victimRow, 0, victimBank, victimRank, promotionChannel, victimSubarray );
    victim.SetPhysicalAddress( victimAddress );
	if( currentPromotionPage>0)
	    currentPromotionPage = (currentPromotionPage - 1) % totalPromotionPages;
	else
		currentPromotionPage = ( currentPromotionPage + totalPromotionPages)% totalPromotionPages;
}