ChtotoSlabovato's blog

By ChtotoSlabovato, history, 4 years ago, In English

On the last contest I have send identical code on compilers for all 3 versions and while I got time limit on ++17 and ++14, on ++20 it took slightly more than a second(twice as fast). Is C++20 that effective or how else that can be explained?

  • Vote: I like it
  • -19
  • Vote: I do not like it

»
4 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What was the code?

»
4 years ago, hide # |
Rev. 3  
Vote: I like it +16 Vote: I do not like it

There should be a tangible performance difference between 64-bit and 32-bit compiled code, specially if your program uses 64-bit numeric data processing extensively and the compiled code is running on a 64-bit microprocessor.

  • »
    »
    4 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Thank you. Am i right to understand that code on c++14 and c++17 is always 32 bits or i can change that somehow

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

      With pleause.

      RE: Your question

      This depends on the compilation flags passed to the g++ compiler.

      Check the following old blog about that issue.

      About the programming languages

      The Codeforces technical administration team should be able to confirm that the GNU c++14 and c++17 compilers generate 32-bit executable code by default, as I expect.

      Note that the among the g++ compilation flags is the -m switch, which allows changing the default target architectural model used to generate the object code. Using -m32 should generate 32-bit executable code, and using -m64 should generate 64-bit executable code.

      On the other hand, I checked your code, and found that it uses 64-bit integers extensively, as I expected. You may check the following update to your code, which was accepted using c++14.

      167158251