nor's blog

By nor, 6 weeks ago, In English

MikeMirzayanov added a new compiler in response to the bug mentioned here. However, it does not come without a catch.

Namely, any pragma that is of the form #pragma GCC target(...) would NOT work with this new compiler. The issue is well-known by people who use up-to-date compilers but there has not been much progress towards a fix.

One of the ways to fix it is to add the target pragma AFTER the STL includes. This should make your code compile, but a lot of code would simply not be optimized, so use it at your own risk.

The other way is to use g++-12, but risk a TLE due to the linked blog (it's easy to write hacks for most problems). Fortunately, there is a fix for this hack, but, echoing the words of the blog author, use that at your own risk.

For completeness, the first two of these don't compile on g++-13 but the last one does.

#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <vector>
int main() { std::vector<int> a; }
#pragma GCC target("avx")
#include <vector>
int main() { std::vector<int> a; }
#pragma GCC optimize("O3")
#include <vector>
#pragma GCC target("avx")
int main() { std::vector<int> a; }
  • Vote: I like it
  • +34
  • Vote: I do not like it

»
6 weeks ago, # |
  Vote: I like it +83 Vote: I do not like it

A c++ user trying to squeeze their solution nowadays:

meme
»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

good to know

»
6 weeks ago, # |
  Vote: I like it +26 Vote: I do not like it

Just code the SIMD sections in assembly. Shouldn't be that hard >_>