HMLP: High-performance Machine Learning Primitives
|
Cache1D<NSET, NWAY, T> creates a layer of cache with NSET that directly maps a 1D array. The direct map is [ id % NSET ]. Each set has NWAY that are fully associated. More...
#include <Cache.hpp>
Public Member Functions | |
Cache1D (size_t unit) | |
Data< T > | Read (size_t id) |
void | Write (size_t id, Data< T > &input) |
Cache1D<NSET, NWAY, T> creates a layer of cache with NSET that directly maps a 1D array. The direct map is [ id % NSET ]. Each set has NWAY that are fully associated.
|
inline |
resize table and locks
resize frequency
resize buffer
all units
|
inline |
use direct map to find the set
use std::map::find inside the fully associated set
cache hit
increate frequency
|
inline |
use direct map to find the set
compute the offset of the whole NSET-by-NWAY cachline
early return if id has been written to the cache
column id of the buffer
insert id into table[ id % NSET ]
cache replacement
compute the minimal frequency
match the cahceline and replace