<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63136>63136</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Questions about preventing OpenMP OpenMP parallel regions.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Ehu1
</td>
</tr>
</table>
<pre>
I don't understand why the OpenMP parallel regions are not being merged during OpenMP optimization in the following code.
```
program main
implicit none
integer :: a
call f(a)
!$omp parallel
a = a + 1
!$omp end parallel
!$omp parallel
a = a + 1
!$omp end parallel
end program main
```
I found the reasons for preventing the merging of parallel regions in OpenMPopt.cpp.
```
if (IsBeforeMergableRegion) {
Function *CalledFunction = CI->getCalledFunction();
if (!CalledFunction)
return false;
// Return false (unmergable) if the call before the parallel
// region calls an explicit affinity (proc_bind) or number of
// threads (num_threads) compiler-generated function. Those settings
// may be incompatible with following parallel regions.
// TODO: ICV tracking to detect compatibility.
for (const auto &RFI : UnmergableCallsInfo) {
if (CalledFunction == RFI.Declaration)
return false;
}
}
```
However, I cannot understand the logic behind this part. In what situations would merging parallel regions after calling an explicit affinity (proc_bind) or number of threads (num_threads) compiler-generated function lead to errors?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU9z46gT_TT40hWVhBzZOuiQxOP66TCV36Zm9zqFoJHYRaDiT7zeT7-FLCdxHB92KJdtmu4H3e81MO9VbxAbcv9I7ncrFsNgXfNtiMWqs-LYtCCsIXQTIBqBzgdmBByGI4QB4XlC8_3_MDHHtEYNDntljQfmEIwN0KEyPYzoehQgokuzJcZOQY3qHxaUNaDMDCet1vaQnLgVmJF8R_IHUuXLZ55OzvaOjQAjU-ZkAjVOWnEVwFiDiw2UCdijA1I-kPIB2NnOmdYgCd0yQuuzkdCC0LUdp7dczisMSLlL3_QRimt3NOIq5DbYL8DNluucP1WlBWmjEXMVHTKfSJDW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