GithubHelp home page GithubHelp logo

cache-simulator's People

Stargazers

 avatar

Watchers

 avatar

cache-simulator's Issues

메모리 구조 개선

현재 시뮬레이터의 메모리 구조는 단순한 연결리스트 구조로 구현해 두었음.

제일 처음에 구현했던 cachesim.c에서는 trace 파일의 인스트럭션 수가 적고 메모리의 데이터까지 유지해야 했기 때문에 위와 같은 방식으로 구현했었지만, cachesim-onelevel.c 이후 구현에서는 trace 파일에서 STORE 인스트럭션의 경우에도 기록할 데이터의 값이 명시되어 있지 않고, trace 파일 자체가 매우 크므로 데이터 추가에 O(N)이 걸리는 연결리스트 형태로 메모리 구조를 구현해 두는 것은 비효율적임

따라서, 메모리 구조 역시 해시 테이블 형태로 변경하거나, 아예 제거하는 등의 개선이 필요

FIFO Replacement Policy 구현 개선

현재 FIFO 구현은 LRU 코드를 일부 수정한 방식으로, 전역으로 선언한 timecnt가 계속 증가하며, write miss 발생 시 block 을 메모리로부터 fetch 해 올 때 해당 block의 fetched_time 멤버 변수에 그 시점의 timecnt를 저장해 둔 후, victim block을 찾을 때는 SET 안의 block을 모두 순회하며 fetched_time이 가장 작은 블럭을 선택하여 FIFO를 구현함.

// iterate BLOCK in SET to get proper block address
for (blockidx = 0, victimidx = 0; blockidx < set_size; blockidx++) {
    // block++ until it finds empty block
    if (cache[addr.index].block[blockidx].valid == 0) {
        isemptyblock = TRUE;
        break;
    }
    // check brought-in time(block->fetched_time) and update victimidx so that we can get the index of First-In block
    else if (cache[addr.index].block[blockidx].fetched_time < cache[addr.index].block[victimidx].fetched_time) {
        victimidx = blockidx;
    }
}

하지만 위 코드를 보면, SET안의 모든 block이 비어 있는 초기 상태에서 데이터를 기록할 때, 0번째 인덱스부터 마지막 인덱스까지 순회하며 제일 먼저 검색되는 empty block의 인덱스에 데이터를 기록하는 것을 알 수 있다.

따라서, 0 -> 1 -> 2 -> ... -> set_size-1 의 순서로 데이터가 기록될 것이고, FIFO 알고리즘을 적용한다면 victim block 역시 해당 순서와 같이 변화할 것이다.

결과적으로, victim_idx = (victim_idx++) % set_size (victim_idx 초기값=0) 과 같은 형태로 구현할 수 있고, 이를 struct SET에 저장해 두고 활용하면 전역변수 timecnt 없이도 FIFO를 쉽게 구현할 수 있을 것으로 예상된다.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.