Skip to content

Commit

Permalink
bh_fuse_cache now uses unique view id's based on the seqset class for…
Browse files Browse the repository at this point in the history
… calculation hash'es.

This means that the caches fusion result can be reuses for the same problem (code) run with different problem sizes.
More reuse of cache is good :)
  • Loading branch information
tblum committed Jun 9, 2015
1 parent 6fe27ec commit a8520fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
23 changes: 4 additions & 19 deletions core/bh_fuse_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,14 @@ namespace bohrium {
const bh_view& view = instr.operand[oidx];
if (bh_is_constant(&view)) // Ignore constants
continue;

uint64_t base_id; // Hash the base array pointer
map<const bh_base*, uint64_t>::iterator it = batch.base2id.find(view.base);
if(it != batch.base2id.end()) {
base_id = it->second;
} else {
base_id = batch.base_id_count++;
batch.base2id.insert(make_pair(view.base, base_id));
}
this->append((char*)&base_id, sizeof(base_id));

// Hash ndim and start
this->append((char*)&view.ndim, sizeof(view.ndim));
this->append((char*)&view.start, sizeof(view.start));

// Hash shape and stride
this->append((char*)view.shape, sizeof(bh_index)*view.ndim);
this->append((char*)view.stride, sizeof(bh_index)*view.ndim);
std::pair<size_t,bool> vid = batch.views.insert(view);
size_t id = vid.first;
this->append((char*)&id, sizeof(id));
}
}

//Constructor of the BatchHash class
BatchHash::BatchHash(const vector<bh_instruction> &instr_list):base_id_count(0)
BatchHash::BatchHash(const vector<bh_instruction> &instr_list)
{
string data;
BOOST_FOREACH(const bh_instruction &instr, instr_list)
Expand Down
5 changes: 3 additions & 2 deletions include/bh_fuse_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ struct InstrHash: public std::string
* (aka instruction list) */
struct BatchHash
{
uint64_t base_id_count;
std::map<const bh_base*, uint64_t> base2id;
// Sequence set of views used in this batch
seqset<bh_view> views;

uint64_t _hash;

/* Construct a BatchHash instant based on the instruction list */
Expand Down

0 comments on commit a8520fe

Please sign in to comment.