RestingRajarshi's blog

By RestingRajarshi, 2 years ago, In English

Just a heads up if someone else gets this bug:

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

I usually add these two lines of pragmas in my code. But on submitting it to the POI judge, it gives runtime error 4, and when excluded, it doesn't.

Would also be nice if someone could elaborate on why Runtime error 4 is returned on passing the pragmas.

 
 
 
 
  • Vote: I like it
  • +6
  • Vote: I do not like it

»
2 years ago, # |
  Vote: I like it +16 Vote: I do not like it

With second pragma you allow compiler to use some assembly instructions which are not supported on some machines, and if some judge system uses different machines for compilation and execution, you may encounter such a problem. I'm not sure about POI, but with Yandex system it is exactly such case.

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    That's the case. Using pragmas is just asking for a problem in most cases imho.

    • »
      »
      »
      2 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Well, Ofast and sse should work everywhere. But of course, using these pragmas makes sense only if you know and understand why you need them in specific solution.