Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

OpenMP realloc lhs failure

Ulrich_M_
New Contributor I
1,136 Views

The following code, built with 19.1.2.254 in debug mode with "/standard-semantics" fails execution with "Critical error detected c0000374":

program mfort
	implicit none
	real, allocatable	:: x(:)
	integer		:: i,j
	
	x=[1,2,3] 
!$omp parallel do private(x)	
	do i=1,10
		x=[(j,j=1,12)]
		print *,sum(x)
	enddo
end program

 

0 Kudos
1 Solution
Ron_Green
Moderator
1,113 Views

Should be legal per spec Section 2.19.3

I'll open a bug report.

View solution in original post

0 Kudos
6 Replies
jimdempseyatthecove
Honored Contributor III
1,125 Views

Try firstprivate(x)

so as to copy in the initial contents of the unallocated array descriptor.

Jim Dempsey

0 Kudos
Ulrich_M_
New Contributor I
1,121 Views

Thank you for your suggestion.

In my real code, I had a function return a matrix of variable size. I tried a number of things there, including firstprivate, make the allocatable variables threadprivate with copyin, etc, but they all failed. In the end, I found a workaround by replacing the function by a subroutine that explicitly allocates the (initially deallocated) variable, and by deallocating the variable at the end of each loop iteration.

My conclusion is that the combination of OpenMP and automatic lhs reallocation is currently poorly implemented. The code above is merely a trivial reproducer.

0 Kudos
Ron_Green
Moderator
1,114 Views

Should be legal per spec Section 2.19.3

I'll open a bug report.

0 Kudos
Ron_Green
Moderator
1,108 Views

you are correct - the seg fault is on deallocation after the loop exit.  the prints never get out of the stdout buffer before the seg fault hits.

0 Kudos
Ulrich_M_
New Contributor I
1,102 Views

Thank you for taking a look!

UM

0 Kudos
Ron_Green
Moderator
1,095 Views

Bug ID is CMPLRLLVM-23023


0 Kudos
Reply