I can't set -march/-mtune (to any setting) AND regular optimizations (Highest) without my code breaking everywhere. I can use one or the other but not both at the same time. If I use both then a lot of my code breaks, like, with just Highest optimization I can run my program for hours and everything works as expected, but if I add -march/-mtune it crashes near the beginning. The piece of code that crashes depends on which startup parameters I specify, but seeing how they're not related in any way I'm guessing a lot of things get broken by this.
My program is a real-time simulation so speed is crucial, that's why I'm trying to get the extra speed from architecture-specific optimizations. Is there anything I need to take into account when adding these options? Any "usual" culprits? Debugging optimized code with GDB is near impossible so debugging is out of the question. Like I said though, my code works fine both without optimizations and with -g3.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Okay so, during ONE of the many startup paths, removing this line solves the problem and allows the program to run for a few minutes before crashing elsewhere:
for (int c = 0; c < 10; c++) consonants[c] = -1; // consonants being declared as: int consonants[10];
That line isn't actually necessary. I only put it there to make sure every index of the array has the same value. It's just a standard practice I've adopted since I learned that running a program with GDB doesn't zero out any data. In this particular case, the data is set before it is used later in the function, so that line is only a courtesy. Running the code without that line shouldn't make any difference, but if I add -march/-mtune, it crashes with a sigsegv at that line. What the heck? ;-;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Never mind, I figured it out. I still don't know about the example I posted but it turned out all the other errors were logic errors. I'm using all optimizations now. :D
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can't set -march/-mtune (to any setting) AND regular optimizations (Highest) without my code breaking everywhere. I can use one or the other but not both at the same time. If I use both then a lot of my code breaks, like, with just Highest optimization I can run my program for hours and everything works as expected, but if I add -march/-mtune it crashes near the beginning. The piece of code that crashes depends on which startup parameters I specify, but seeing how they're not related in any way I'm guessing a lot of things get broken by this.
My program is a real-time simulation so speed is crucial, that's why I'm trying to get the extra speed from architecture-specific optimizations. Is there anything I need to take into account when adding these options? Any "usual" culprits? Debugging optimized code with GDB is near impossible so debugging is out of the question. Like I said though, my code works fine both without optimizations and with -g3.
Okay so, during ONE of the many startup paths, removing this line solves the problem and allows the program to run for a few minutes before crashing elsewhere:
for (int c = 0; c < 10; c++) consonants[c] = -1; // consonants being declared as: int consonants[10];
That line isn't actually necessary. I only put it there to make sure every index of the array has the same value. It's just a standard practice I've adopted since I learned that running a program with GDB doesn't zero out any data. In this particular case, the data is set before it is used later in the function, so that line is only a courtesy. Running the code without that line shouldn't make any difference, but if I add -march/-mtune, it crashes with a sigsegv at that line. What the heck? ;-;
Never mind, I figured it out. I still don't know about the example I posted but it turned out all the other errors were logic errors. I'm using all optimizations now. :D