1// RUN: %libomptarget-compile-generic && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-generic 2>&1 | %fcheck-generic -allow-empty -check-prefix=DEBUG
2// REQUIRES: libomptarget-debug
3
4/*
5 Test for looptripcount being popped from runtime stack.
6*/
7#include <omp.h>
8#include <stdio.h>
9int main() {
10 int N = 128;
11 int NN = 1024;
12 int num_teams[NN];
13 int num_threads[NN];
14
15 printf(format: "#pragma omp target teams distribute parallel for thread_limit(4)\n");
16#pragma omp target teams distribute parallel for thread_limit(4)
17 for (int j = 0; j < N; j++) {
18 num_threads[j] = omp_get_num_threads();
19 num_teams[j] = omp_get_num_teams();
20 }
21 printf(format: "num_threads %d num_teams %d\n", num_threads[0], num_teams[0]);
22 // DEBUG: loop trip count is 128
23 printf(format: "#pragma omp target teams distribute parallel for\n");
24#pragma omp target teams distribute parallel for
25 for (int j = 0; j < N; j++) {
26 num_threads[j] = omp_get_num_threads();
27 num_teams[j] = omp_get_num_teams();
28 }
29 printf(format: "num_threads %d num_teams %d\n", num_threads[0], num_teams[0]);
30 // DEBUG: loop trip count is 128
31 return 0;
32}
33

source code of offload/test/offloading/looptripcnt.c