[OpenMP][DeviceRTL] Use the actual block size in the SPMD no-loop distribute path (#214073)

In the SPMD no-loop path the iteration index is `BId * NumThreads +
TId`, so `NumThreads` has to
be the size of the block the threads are actually in. `DistributeFor`
uses the caller-supplied
value as-is. If that value is larger than the block size, the index
strides past the end of each
block and the iterations in between are never run.

Fixes #198621.

Reproduced on gfx90a, `num_teams(4)`, 128 iterations, varying the value
passed as `NumThreads`
against the threads the block actually has:

| NumThreads passed | threads in block | iterations not run |
|---|---|---|
| 256 | 32 | 96 of 128 |
| 256 | 64 | 64 of 128 |
| 128 | 32 | 96 of 128 |
| 64 | 64 | 0 |

Exactly as many iterations run as there are threads in the block, and
the rest are dropped. With
this patch all four cases run all 128.

AMD carries the same fix downstream as ROCm/llvm-project#3058.

### Testing

The new test calls `__kmpc_distribute_for_static_loop_4u` directly. That
is unusual, and the reason
is that no C or C++ construct reaches it: clang lowers worksharing loops
to
`__kmpc_for_static_init_4`, and only flang emits
`__kmpc_distribute_for_static_loop_*`. Verified on
device IR from both frontends. Calling the entry directly keeps the test
independent of the Fortran
runtime, which upstream does not ship for the device.

Verified the test fails without the patch (`unwritten: 96`) and passes
with it (`unwritten: 0`).

Also ran 66 Fortran offload probes covering collapse, reductions,
private and firstprivate arrays,
nested parallel, simd, allocatable, atomic and complex arithmetic, in
no-loop mode with
`exec_mode` confirmed to be 6 rather than assumed: all pass before and
after, so the clamp does not
disturb the cases where the caller's value was already correct.

---

Parts of this change were written or audited with Claude Code. I have
reviewed all of it and take
full responsibility for the contribution. See
`llvm/docs/AIToolPolicy.md`.

GitOrigin-RevId: 9c317bbbdbeaaf2b2e039ece201baba8f21f9d2a
1 file changed