During the C++ application execution one of the variables dies for no reason. I think that the causes of this problem are connected to memory. However, I don't have any ideas how to solve this problem. What could be the cause of this problem?
It seems that site doesn't work correctly so I have to continue here:
I discovered that some simple arithmetic OpenMP parallel programs runs faster with using icpc compiler instead of g++.
However, when I have tried to compile big OpenMP application (which works correctly with g++) with icpc, it has broken. Using manual code debugging I have discovered that the issue is that one of the variables dies for no reason. I have faced this issue earlier with this application and g++ compiler, but in different mode. It works like:
//no parallel code before this problem
cout<<"var is alive"<<endl;//all works correctly
var2 = 0;
cout<<"var is dead"<<endl;
I face this problem on a completely different devices, so I think that it doesn't matter. Are there any general causes of such phenomena? What should I do to solve this problem?
Grigorii Vasilev wrote:
I have faced this issue earlier with this application and g++ compiler, but in different mode. It works like:
You have the answer in this sentence - something is wrong in your code. it looks one thread has overwritten a stack of another thread
1. is "program dies" segfault, kill, illegal instruction or what? what is the back trace?
2. is the problem appears in serial block or in parallel section?
Problem is solved. In my particular case the cause of the problem was that absolutely another variable was changed by different threads/functions, so I have made that variable const.
So, if you have similar problem you should check all code.