mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 21:55:42 +00:00
memory prefetching (#4224)
This commit is contained in:
+12
-2
@@ -140,8 +140,13 @@ void ActionPointDistances::PopulateOne(
|
||||
const Coords& currentCoords = indexToCoords[currentIndex];
|
||||
visited[currentIndex] = true;
|
||||
|
||||
for (const std::array<int, 6>& neighbors = adjacencyTable[currentIndex];
|
||||
int adjacentIndex : neighbors) {
|
||||
// Prefetch terrain data for all neighbors to reduce memory stalls
|
||||
const std::array<int, 6>& neighbors = adjacencyTable[currentIndex];
|
||||
for (int i = 0; i < 6 && neighbors[i] != -1; i++) {
|
||||
__builtin_prefetch(hexMap->terrain()->Get(neighbors[i]), 0, 3);
|
||||
}
|
||||
|
||||
for (int adjacentIndex : neighbors) {
|
||||
if (adjacentIndex == -1) break; // End of valid neighbors
|
||||
if (visited[adjacentIndex]) continue;
|
||||
|
||||
@@ -168,6 +173,11 @@ void ActionPointDistances::PopulateOne(
|
||||
return from.from == currentCoords;
|
||||
});
|
||||
if (entry != braveWaterPossibleCoords->details.end()) {
|
||||
// Prefetch terrain data for water braving targets
|
||||
for (const auto braveIndex : entry->to.indexIterator()) {
|
||||
__builtin_prefetch(hexMap->terrain()->Get(braveIndex), 0, 3);
|
||||
}
|
||||
|
||||
for (const auto braveIndex : entry->to.indexIterator()) {
|
||||
if (visited[braveIndex]) continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user