Files
clang-p2996/offload/test/offloading/high_trip_count_block_limit.cpp
Tim Gymnich 597d2f7662 [OpenMP] Add Environment Variable to disable Reuse of Blocks for High Loop Trip Counts (#89239)
Sometimes it might be beneficial to spawn more thread blocks instead of
reusing existing for multiple loop iterations.

**Alternatives considered:**

Make `DefaultNumBlocks` settable via an environment variable.

---------

Co-authored-by: Joseph Huber <huberjn@outlook.com>
2024-06-14 07:35:23 -07:00

36 lines
1.0 KiB
C++

// clang-format off
// RUN: %libomptarget-compilexx-generic && env LIBOMPTARGET_REUSE_BLOCKS_FOR_HIGH_TRIP_COUNT=False %libomptarget-run-generic 2>&1 | %fcheck-generic
// RUN: %libomptarget-compilexx-generic && %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=DEFAULT
// UNSUPPORTED: aarch64-unknown-linux-gnu
// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
// UNSUPPORTED: x86_64-pc-linux-gnu
// UNSUPPORTED: x86_64-pc-linux-gnu-LTO
// UNSUPPORTED: s390x-ibm-linux-gnu
// UNSUPPORTED: s390x-ibm-linux-gnu-LTO
// clang-format on
/*
Check if there is a thread for each loop iteration
*/
#include <omp.h>
#include <stdio.h>
int main() {
int N = 819200;
int num_threads[N];
#pragma omp target teams distribute parallel for
for (int j = 0; j < N; j++) {
num_threads[j] = omp_get_num_threads() * omp_get_num_teams();
}
if (num_threads[0] == N)
// CHECK: PASS
printf("PASS\n");
else
// DEFAULT: FAIL
printf("FAIL: num_threads: %d\n != N: %d", num_threads[0], N);
return 0;
}