view libgomp/testsuite/libgomp.c-c++-common/pause-2.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
line wrap: on
line source

/* { dg-do run } */
/* { dg-require-effective-target tls_runtime } */

#include <omp.h>
#include <stdlib.h>

int t = 128;
#pragma omp threadprivate (t)

int
main ()
{
  #pragma omp parallel
  t = omp_get_thread_num () + 256;
  #pragma omp parallel
  if (t != omp_get_thread_num () + 256)
    abort ();
  omp_pause_resource (omp_pause_soft, omp_get_initial_device ());
  /* This goes beyond what is required by the standard, we actually
     check if the threads other than the initial one have been destroyed.  */
  #pragma omp parallel
  {
    if (omp_get_thread_num () != 0 && t != 128)
      abort ();
    t = omp_get_thread_num () + 384;
  }
  #pragma omp parallel
  if (t != omp_get_thread_num () + 384)
    abort ();
  omp_pause_resource_all (omp_pause_hard);
  #pragma omp parallel
  {
    if (omp_get_thread_num () != 0 && t != 128)
      abort ();
    t = omp_get_thread_num () + 512;
  }
  #pragma omp parallel
  if (t != omp_get_thread_num () + 512)
    abort ();
  return 0;
}