LAB/GEM5

GEM5, NVMain FRFCFS MemCon에 WR,RD buffer hit,miss 추가

RyoTTa 2021. 6. 11. 15:49
반응형

NVMain에서 FRFCFS-WQF에는 Write, Read Request에 해당하는 Queue 가 두개로 나뉘어 처음부터 Write, Read row buffer hit, miss를 지원한다.

하지만 FRFCFS에서는 Queue가 하나라서 기본적인 Row buffer hit,miss만 지원한다. 이를 Write에 대한 hit,miss 와 Read에 대한 hit, miss 둘다 출력하게 수정한다.

$ vim ./nvmain/MemControl/FRFCFS/FRFCFS.h
  private:
    NVMTransactionQueue *memQueue;

    /* Cached Configuration Variables*/
    uint64_t queueSize;

    /* Stats */
    uint64_t measuredLatencies, measuredQueueLatencies, measuredTotalLatencies;
    double averageLatency, averageQueueLatency, averageTotalLatency;
    uint64_t mem_reads, mem_writes;
    uint64_t rb_hits;
    uint64_t rb_miss;
    uint64_t starvation_precharges;
    uint64_t write_pauses;

위에 해당하는 부분을 아래와 같이 수정한다.

  private:
    NVMTransactionQueue *memQueue;

    /* Cached Configuration Variables*/
    uint64_t queueSize;

    /* Stats */
    uint64_t measuredLatencies, measuredQueueLatencies, measuredTotalLatencies;
    double averageLatency, averageQueueLatency, averageTotalLatency;
    uint64_t mem_reads, mem_writes;
    uint64_t rb_hits;
    uint64_t rb_miss;
    uint64_t starvation_precharges;
    uint64_t write_pauses;

    uint64_t wr_rb_hits;
    uint64_t wr_rb_miss;
    uint64_t rd_rb_hits;
    uint64_t rd_rb_miss;

 

$ vim ./nvmain/MemControl/FRFCFS/FRFCFS.cpp
FRFCFS::FRFCFS( )
{
    std::cout << "Created a First Ready First Come First Serve memory controller!"
        << std::endl;

    queueSize = 32;
    starvationThreshold = 4;

    averageLatency = 0.0f;
    averageQueueLatency = 0.0f;
    averageTotalLatency = 0.0f;

    measuredLatencies = 0;
    measuredQueueLatencies = 0;
    measuredTotalLatencies = 0;

    mem_reads = 0;
    mem_writes = 0;

    rb_hits = 0;
    rb_miss = 0;

    write_pauses = 0;

    starvation_precharges = 0;

    psInterval = 0;

    InitQueues( 1 );

    memQueue = &(transactionQueues[0]);
}

위에 해당하는 부분을 아래와 같이 수정한다.

FRFCFS::FRFCFS( )
{
    std::cout << "Created a First Ready First Come First Serve memory controller!"
        << std::endl;

    queueSize = 32;
    starvationThreshold = 4;

    averageLatency = 0.0f;
    averageQueueLatency = 0.0f;
    averageTotalLatency = 0.0f;

    measuredLatencies = 0;
    measuredQueueLatencies = 0;
    measuredTotalLatencies = 0;

    mem_reads = 0;
    mem_writes = 0;

    rb_hits = 0;
    rb_miss = 0;
    wr_rb_hits = 0;
    wr_rb_miss = 0;
    rd_rb_hits = 0;
    rd_rb_miss = 0;

    write_pauses = 0;

    starvation_precharges = 0;

    psInterval = 0;

    InitQueues( 1 );

    memQueue = &(transactionQueues[0]);
}
void FRFCFS::Cycle( ncycle_t steps )
{
    NVMainRequest *nextRequest = NULL;

    /* Check for starved requests BEFORE row buffer hits. */
    if( FindStarvedRequest( *memQueue, &nextRequest ) )
    {
        rb_miss++;
        starvation_precharges++;
    }
    /* Check for row buffer hits. */
    else if( FindRowBufferHit( *memQueue, &nextRequest) )
    {
        rb_hits++;
    }
    /* Check if the address is accessible through any other means. */
    else if( FindCachedAddress( *memQueue, &nextRequest ) )
    {
    }
    else if( FindWriteStalledRead( *memQueue, &nextRequest ) )
    {
        if( nextRequest != NULL )
            write_pauses++;
    }
    /* Find the oldest request that can be issued. */
    else if( FindOldestReadyRequest( *memQueue, &nextRequest ) )
    {
        rb_miss++;
    }
    /* Find requests to a bank that is closed. */
    else if( FindClosedBankRequest( *memQueue, &nextRequest ) )
    {
        rb_miss++;
    }
    else
    {
        nextRequest = NULL;
    }

    /* Issue the commands for this transaction. */
    if( nextRequest != NULL )
    {
        IssueMemoryCommands( nextRequest );
    }

    /* Issue any commands in the command queues. */
    CycleCommandQueues( );

    MemoryController::Cycle( steps );
}

위에 해당하는 부분을 아래와 같이 수정한다.

void FRFCFS::Cycle( ncycle_t steps )
{
    NVMainRequest *nextRequest = NULL;

    /* Check for starved requests BEFORE row buffer hits. */
    if( FindStarvedRequest( *memQueue, &nextRequest ) )
    {
        rb_miss++;
        starvation_precharges++;
        
        if(nextRequest->type == WRITE){
            wr_rb_miss++;
        }   
        else if(nextRequest->type == READ){
            rd_rb_miss++;
        }
    }
    /* Check for row buffer hits. */
    else if( FindRowBufferHit( *memQueue, &nextRequest) )
    {
        rb_hits++;

        if(nextRequest->type == WRITE){
            wr_rb_hits++;
        }   
        else if(nextRequest->type == READ){
            rd_rb_hits++;
        }
    }
    /* Check if the address is accessible through any other means. */
    else if( FindCachedAddress( *memQueue, &nextRequest ) )
    {
    }
    else if( FindWriteStalledRead( *memQueue, &nextRequest ) )
    {
        if( nextRequest != NULL )
            write_pauses++;
    }
    /* Find the oldest request that can be issued. */
    else if( FindOldestReadyRequest( *memQueue, &nextRequest ) )
    {
        rb_miss++;
        if(nextRequest->type == WRITE){
            wr_rb_miss++;
        }   
        else if(nextRequest->type == READ){
            rd_rb_miss++;
        }
    }
    /* Find requests to a bank that is closed. */
    else if( FindClosedBankRequest( *memQueue, &nextRequest ) )
    {
        rb_miss++;
        if(nextRequest->type == WRITE){
            wr_rb_miss++;
        }   
        else if(nextRequest->type == READ){
            rd_rb_miss++;
        }
    }
    else
    {
        nextRequest = NULL;
    }

    /* Issue the commands for this transaction. */
    if( nextRequest != NULL )
    {
        IssueMemoryCommands( nextRequest );
    }

    /* Issue any commands in the command queues. */
    CycleCommandQueues( );

    MemoryController::Cycle( steps );
}
void FRFCFS::RegisterStats( )
{
    AddStat(mem_reads);
    AddStat(mem_writes);
    AddStat(rb_hits);
    AddStat(rb_miss);
    AddStat(starvation_precharges);
    AddStat(averageLatency);
    AddStat(averageQueueLatency);
    AddStat(averageTotalLatency);
    AddStat(measuredLatencies);
    AddStat(measuredQueueLatencies);
    AddStat(measuredTotalLatencies);
    AddStat(write_pauses);

    MemoryController::RegisterStats( );
}

위에 해당하는 부분을 아래와 같이 수정한다.

void FRFCFS::RegisterStats( )
{
    AddStat(mem_reads);
    AddStat(mem_writes);
    AddStat(rb_hits);
    AddStat(rb_miss);
    AddStat(wr_rb_hits);
    AddStat(wr_rb_miss);
    AddStat(rd_rb_hits);
    AddStat(rd_rb_miss);
    AddStat(starvation_precharges);
    AddStat(averageLatency);
    AddStat(averageQueueLatency);
    AddStat(averageTotalLatency);
    AddStat(measuredLatencies);
    AddStat(measuredQueueLatencies);
    AddStat(measuredTotalLatencies);
    AddStat(write_pauses);

    MemoryController::RegisterStats( );
}
반응형

'LAB > GEM5' 카테고리의 다른 글

GEM5, NVMain V.20.0.3에 맞게 수정  (3) 2021.08.27
GEM5, DRAMSim2에 Buffer Hit, Miss 추가  (0) 2021.06.21
GEM5, NVMain 설치 (2)  (0) 2021.03.17
GEM5, NVMain에 L3 Cache 추가  (0) 2021.03.17
GEM5, NVMain 설치  (0) 2021.03.16