I've been watching Mike Acton's talk on Data-oriented design in C++ in CppCon 2014, and he gives this example:
int Foo::Bar(int count)
{
int value = 0;
for (int i = 0; i < count; i++) {
if (m_someDataMemberOfFoo) value++
}
return value;
}
And explains how some compilers keep re-reading m_someDataMemberOfFoo
in every iteration, perhaps because its value might change due to concurrent access. Regardless of whether it's appropriate for the compiler to do so - can one tell the compiler to specifically ignore any possibility of concurrent access to anything during the execution of some method, so that it may optimize better?
In other words, can I tell it the compiler that this
is __restrict__
ed?