I have coded a quite long code and I use boost for multithreading (3 threads, two of them depend on each other) I am obtaining very weird results, namely:
ISSUE 1 ) If I define one more variable in one class my code compiles correctly but it will not produce the same results. I do not know why, but results are worse if I define one random variable more.. Right now there are like 60 variables defined in that class.
ISSUE 2 ) The other day, I removed one variable that I was not using and then the code performed worse... this is magic also.
ISSUE 3 )Another day, I had to remove this variable I was not using, if would not have removed it, it would have worked worse. This is just the opposite that happened to me in ISSUE 2.
ISSUE 4 ) Similar to previous errors. I had a library that I was not using, so I removed the include file and it compiled well but the performance was worse (?)... after a few ours were I changed a couple of lines (which were not related to this library) I could remove this include file without decreasing the performance of the code... Really weird..
Is any of you familiar with this issues?
I know that all this errors come from the fact that I am not an expert in C++ , but I would like to learn to avoid them.... many thanks for your time.
Edit: By 'it performs worse' I do not exactly mean that. It just does not perform in any way. It is like the code does not enter in the boost threads or something like that, but I do not obtain any input.
Sounds like your build is doing funky things. At least that is my guess. Try doing a clean build by removing object files and recompiling everything. Also, it would be nice to know what compiler are you using? How much worse does the code perform? How are you measuring performance? What extra compiler flags are you using? Are any of these extra flags meant for optimization?
I did a clean build but the same weird things happens...
I think I use gcc compiler.
By 'it performs worse' I do not exactly mean that. It just does not perform in any way. It is like the code does not enter in the boost threads or something like that, but I do not obtain any input.
Yes I use optimization flags:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")