Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.

Unsynchronized For Loop

cybernike
Beginner
470 Views

My C++ code is similar to below:

list a;
#pragma omp parallel for
for(int i=0;i {
some code here..
#pragma omp critical
{
a.push_back(some integer);
}
some code here..
}

a.clear();



The Intel thread checker complains that the statement after the for loop, a.clear() , messes with the statements for a in the for loop - a write->write data race error. But why? I thought at the end of the for loop, there is an implicit barrier to wait for all threads to reach the end point of the loop. What am I missing?

Thanks.

0 Kudos
3 Replies
TimP
Honored Contributor III
470 Views

According to what you presented, I would agree with you. It's not difficult, with C and C++, to get out on the edge of what is supported in OpenMP. I would suggest submission of a question on premier.intel.com, if you're working with the Windows thread checker. The linux thread checker seems to be in a less than satisfactory state right now, pending resumption of development of the next version.

0 Kudos
cybernike
Beginner
470 Views
Quoting - tim18

According to what you presented, I would agree with you. It's not difficult, with C and C++, to get out on the edge of what is supported in OpenMP. I would suggest submission of a question on premier.intel.com, if you're working with the Windows thread checker. The linux thread checker seems to be in a less than satisfactory state right now, pending resumption of development of the next version.

Sorry, I am new to this site. Is the premier site free for everyone? I am still doing the 30-day evaluation for the thread checker. I tried to log on at premier.intel.com using the same forum pw/id and it didn't work.

I tried my program with both windows and linux versions of the thread checker. Even though the linux shows fewer errors, both versions complain about the list errors that I mentioned above.

I did check the content of my list before and after clear() and the list looked absolutely fine and this makes me wonder if the thread checker is not accurate about the errors.

0 Kudos
TimP
Honored Contributor III
470 Views
Quoting - cybernike

Sorry, I am new to this site. Is the premier site free for everyone? I am still doing the 30-day evaluation for the thread checker. I tried to log on at premier.intel.com using the same forum pw/id and it didn't work.

I tried my program with both windows and linux versions of the thread checker. Even though the linux shows fewer errors, both versions complain about the list errors that I mentioned above.

I did check the content of my list before and after clear() and the list looked absolutely fine and this makes me wonder if the thread checker is not accurate about the errors.

You should be able to opensupport accounts by registering your trial serial numbers at https://registrationcenter.intel.com. Your question may get lower priority, but it won't hurt to ask if your evaluation period could be extended until it is possible to answer your question.

0 Kudos
Reply