ホーム » VC OpenMP » OpenMP Fatal User Error 1002

2023年4月
 1
2345678
9101112131415
16171819202122
23242526272829
30  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,265 アクセス



OpenMP Fatal User Error 1002

OpenMP が有効な時でも動作する様にテストしていると…
Fatal User Error 1002: A ‘#pragma omp critical’ is illegally nested in one of the same name
Fatal User Error 1002: A '#pragma omp critical' is illegally nested in one of the same name
元々あった次のコードに #pragma omp critical としたことによるもの.

tstring	Get_Self_Original	(void)
{
	static	bool	Yet = true ;
	static	tstring	Self_original ;
	if (Yet) {
		tstring	self_name = ::Get_module_name() ;
		Self_original = Get_OriginalFilename(self_name.c_str()) ;
		if (Self_original.empty()) {
			Self_original = ::Path_GetName(self_name) ;
			}
		Yet = false ;
		}
	return	Self_original ;
	}

次の様に並列処理可能にすることで動作する様にはなるが …

tstring	Get_Self_Original	(void)
{
	#ifdef	_OPENMP
	//	#pragma	omp	critical	(_Get_Self_Original_)
	#endif
	{
	#ifdef	_OPENMP
			bool	Yet = true ;
			tstring	Self_original ;
	#else
		static	bool	Yet = true ;
		static	tstring	Self_original ;
	#endif
		if (Yet) {
			tstring	self_name = ::Get_module_name() ;
			Self_original = Get_OriginalFilename(self_name.c_str()) ;
			if (Self_original.empty()) {
				Self_original = ::Path_GetName(self_name) ;
				}
			Yet = false ;
			}
		return	Self_original ;
		}
	}

以前にも同じようなことをやっていた.
https://dev.mish.work/wordpress/2010/03/31/openmp-error-1002/


2023/04/27
この関数は exe の起動直後などに一度呼ばれることを意図しているので,critical をもっと局所的に.

tstring	Get_Self_Original	(void)
{
	static	bool	Yet = true ;
	static	tstring	Self_original ;
	if (Yet) {
		#ifdef	_OPENMP
			#pragma	omp	critical	(_Get_Self_Original_)
		#endif
		{
			tstring	self_name = ::Get_module_name() ;
			Self_original = Get_OriginalFilename(self_name.c_str()) ;
			if (Self_original.empty()) {
				Self_original = ::Path_GetName(self_name) ;
				}
			Yet = false ;
			}
		}
	return	Self_original ;
	}

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.
%d人のブロガーが「いいね」をつけました。