36 lines · cpp
1// clang-format off2// RUN: %libomptarget-compilexx-generic && env LIBOMPTARGET_REUSE_BLOCKS_FOR_HIGH_TRIP_COUNT=False %libomptarget-run-generic 2>&1 | %fcheck-generic3// RUN: %libomptarget-compilexx-generic && %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=DEFAULT4 5// UNSUPPORTED: aarch64-unknown-linux-gnu 6// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO 7// UNSUPPORTED: x86_64-unknown-linux-gnu 8// UNSUPPORTED: x86_64-unknown-linux-gnu-LTO 9// UNSUPPORTED: s390x-ibm-linux-gnu 10// UNSUPPORTED: s390x-ibm-linux-gnu-LTO11// clang-format on12 13/*14 Check if there is a thread for each loop iteration15*/16#include <omp.h>17#include <stdio.h>18 19int main() {20 int N = 819200;21 int num_threads[N];22 23#pragma omp target teams distribute parallel for24 for (int j = 0; j < N; j++) {25 num_threads[j] = omp_get_num_threads() * omp_get_num_teams();26 }27 28 if (num_threads[0] == N)29 // CHECK: PASS30 printf("PASS\n");31 else32 // DEFAULT: FAIL33 printf("FAIL: num_threads: %d\n != N: %d", num_threads[0], N);34 return 0;35}36