I searched around for this, but was unable to find a conclusive answer. What parameters do I need to pass to __builtin_prefetch
to fetch a cacheline in exclusive mode (i.e. after prefetching, the cacheline is going to be written to at some point in the future)?
For reference, this is an outline of the code I have
void foo(std::uint8_t* line) {
assert(!(line % std::hardware_constructive_interference_size));
prefetch(bytes + std::hardware_constructive_interference_size);
auto result = bar(line);
write(bytes + std::hardware_constructive_interference_size);
}
Is there even a benefit in adding a prefetch here? Or will the processor typically always prefetch data in this case?