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

C++ code using OpenMP crashes at runtime when compiled with Intel Compiler 2022, not native Clang

AndrewC
New Contributor III
796 Views

The code below crashes at runtime when compiled with Intel Compiler 2022, but not native Clang 13.0 , or Intel 19.2 or GCC 10

Visual Studio 2019, One API 2022, c++17 language. Remove the '&' after the const auto works around the issue.

#include <iostream>
#include <tuple>
#include <vector>
#include <omp.h>

std::vector<std::pair<int, std::vector<int>>> data;


void DoTask(int a, int b)
{
	{
#pragma omp critical
		std::cout << "Thread " << omp_get_thread_num() << ' ' << a << ',' << b << std::endl;
	}
}

void test2()
{
#	pragma omp parallel
	{
#	pragma omp single
		{
			for (auto iter = data.begin(); iter != data.end(); ++iter)
			{
				const auto &a = iter->first;
				const auto &b = iter->second;
				for (const auto &aa : b)
				{
					if (aa != a)
					{
#	pragma omp task
						DoTask(a, aa);
					}
				}
			}
		}
	}
}




int main()
{
	std::vector<int> tmp({ 1,2,3,4,5,6,7,8,9 });
	for (int i = 0; i < 10; i++)
	{
		data.push_back({ i,tmp });
	}
	std::cout << "Starting test using iter " << std::endl;
	test2();
}

 

0 Kudos
4 Replies
SantoshY_Intel
Moderator
775 Views

Hi,

 

Thank you for posting in Intel Communities.

 

Could you please confirm whether you are facing the same issue as shown in the attached screenshots below?

 

If not, then could you please provide us with a screenshot of your issue?

 

Thanks & Regards.

Santosh

 

0 Kudos
AndrewC
New Contributor III
763 Views

Yes, I get an access violation as per your screen shot.

0 Kudos
SantoshY_Intel
Moderator
747 Views

Hi,


Thank you for the confirmation.


We were able to reproduce your issue from our end using visual studio 2019 and Intel compiler 2022 on a windows machine. we are working on your issue internally and will get back to you soon.


Thanks & Regards,

Santosh


0 Kudos
Viet_H_Intel
Moderator
432 Views

We have released onaAPI 2022.3 which addressed this issue. Please upgrade to this version.

I am going to close this thread.

Thanks,

 

0 Kudos
Reply