Skip to content

Commit 21a8c63

Browse files
authored
[offload] Remove bad assert in StaticLoopChunker::Distribute (#132705)
When building with asserts enabled, this can actually cause strange miscompilations because an incorrect llvm.assume is generated at the point of the assertion.
1 parent b82fd71 commit 21a8c63

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

offload/DeviceRTL/src/Workshare.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,6 @@ template <typename Ty> class StaticLoopChunker {
820820
Ty ThreadChunk = 0;
821821
Ty NumThreads = 1;
822822
Ty TId = 0;
823-
ASSERT(TId == mapping::getThreadIdInBlock(), "Bad thread id");
824823

825824
// All teams need to participate.
826825
Ty NumBlocks = mapping::getNumberOfBlocksInKernel();
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
! REQUIRES: flang, amdgpu
2+
3+
! RUN: %libomptarget-compile-fortran-generic
4+
! RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic
5+
program main
6+
integer :: array(10) = 0
7+
integer :: x, y, z
8+
!$omp target
9+
!$omp teams distribute private(x, y)
10+
OuterLoopOne: do x=1,1
11+
array(2) = 42
12+
OuterLoopTwo: do y=1,1
13+
!$omp parallel do private(z)
14+
InnerLoopOne: do z=1,10
15+
array(z) = 20
16+
enddo InnerLoopOne
17+
!$omp end parallel do
18+
enddo OuterLoopTwo
19+
enddo OuterLoopOne
20+
!$omp end teams distribute
21+
!$omp end target
22+
! Expected to print all 20's
23+
print *, array
24+
end program main
25+
26+
! CHECK: 20 20 20 20 20 20 20 20 20 20

0 commit comments

Comments
 (0)