brintos

brintos / llvm-project-archived public Read only

0
0
Text · 822 B · 2308098 Raw
37 lines · c
1// RUN: %libomp-compile2// RUN: env KMP_HOT_TEAMS_MODE=0 KMP_HOT_TEAMS_MAX_LEVEL=1 %libomp-run3//4// Force the defaults of:5// KMP_HOT_TEAMS_MODE=0 means free extra threads after parallel6//   involving non-hot team7// KMP_HOT_TEAMS_MAX_LEVEL=1 means only the initial outer team8//   is a hot team.9 10#include <stdio.h>11#include <stdlib.h>12#include <omp.h>13 14int main() {15  int a;16  omp_set_max_active_levels(2);17// This nested parallel creates extra threads on the thread pool18#pragma omp parallel num_threads(2)19  {20#pragma omp parallel num_threads(2)21    {22#pragma omp atomic23      a++;24    }25  }26 27// Causes assert if hidden helper thread tries to allocate from thread pool28// instead of creating new OS threads29#pragma omp parallel num_threads(1)30  {31#pragma omp target nowait32    { a++; }33  }34 35  return EXIT_SUCCESS;36}37