Skip to content

Commit

Permalink
Lab Swmem Prefetch 1: Increased lookahead
Browse files Browse the repository at this point in the history
  • Loading branch information
simveit committed Dec 20, 2024
1 parent 5d6beae commit 16632d7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions labs/memory_bound/swmem_prefetch_1/solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ static int getSumOfDigits(int n) {

int solution(const hash_map_t *hash_map, const std::vector<int> &lookups) {
int result = 0;

int lookahead = 32;
for (int i = 0; i < lookups.size(); i++) {
int val = lookups[i];
if (i < lookups.size() - 1) {
int future_val = lookups[i + 1];
if (i < lookups.size() - lookahead) {
int future_val = lookups[i + lookahead];
int future_bucket = future_val % hash_map->getNBuckets();
__builtin_prefetch(&((hash_map->getVector())[future_bucket]));
}
Expand Down

0 comments on commit 16632d7

Please sign in to comment.