[OpenMP][offload] Fix single-thread SPMD cross-team reductions (#231843)

If a kernel gets SPMDized by OpenMPOpt but does not have a parallel
region, it actually is only executed by a single thread.
forceSingleThreadPerWorkgroupHelper() is responsible for that and had
been introduced by https://reviews.llvm.org/D133120. The cross-team
reduction trusted that SPMD mode means that we can re-use the threads of
the parallel region. Now, OpenMPOpt explicitly limits affected kernels
to a single thread per team via the kernel environment, so that we
actually know how many threads we have available. This also changes
omp_get_thread_limit().

Claude assisted with this patch.

GitOrigin-RevId: 2c1650555b1005a6bbe7cf3cb0648bea0fa7416d
1 file changed