Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Variable died for no reason

GVasi4
Beginner
1,054 Views

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?

0 Kudos
6 Replies
GVasi4
Beginner
1,054 Views

It seems that site doesn't work correctly so I have to continue here:

Hi!

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
cout<<var<<endl;
var2 = 0;
cout<<"var is dead"<<endl;
cout<<var<<endl;//program dies

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?

0 Kudos
Vladimir_P_1234567890
1,054 Views

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?

0 Kudos
GVasi4
Beginner
1,054 Views

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.

0 Kudos
RahulV_intel
Moderator
1,054 Views

Hi,

Since your problem is solved, can we close this thread?

0 Kudos
GVasi4
Beginner
1,054 Views

Hi!

Yes.

0 Kudos
RahulV_intel
Moderator
1,054 Views

Thanks for the confirmation.

0 Kudos
Reply