Esempio n. 1
0
File: lock-2.c Progetto: 0day-ci/gcc
int
main (void)
{
  int l = 0;
  omp_nest_lock_t lock;
  omp_init_nest_lock (&lock);
#pragma omp parallel reduction (+:l) num_threads (1)
  {
    if (omp_test_nest_lock (&lock) != 1)
      l++;
    if (omp_test_nest_lock (&lock) != 2)
      l++;
  #pragma omp task if (0) shared (lock, l)
    {
      if (omp_test_nest_lock (&lock) != 0)
	l++;
    }
  #pragma omp taskwait
    if (omp_test_nest_lock (&lock) != 3)
      l++;
    omp_unset_nest_lock (&lock);
    omp_unset_nest_lock (&lock);
    omp_unset_nest_lock (&lock);
  }
  if (l)
    abort ();
  omp_destroy_nest_lock (&lock);
  return 0;
}
Esempio n. 2
0
int  POMP2_Test_nest_lock(omp_nest_lock_t *s) {
  if ( pomp2_tracing ) {
    int result;

    esd_enter(epk_omp_regid[EPK__OMP_TEST_NEST_LOCK]);
    result = omp_test_nest_lock(s);
    if (result) if ( pomp2_tracing > 1 ) esd_omp_alock(epk_lock_id(s));
    esd_exit(epk_omp_regid[EPK__OMP_TEST_NEST_LOCK]);
    return result;
  } else {
    return omp_test_nest_lock(s);
  }
}
Esempio n. 3
0
VT_DECLDEF(int POMP_Test_nest_lock_f(omp_nest_lock_t *s)) {
  if ( IS_POMP_TRACE_ON ) {
    int result;
    uint64_t time;
    time = vt_pform_wtime();
    vt_enter(VT_CURRENT_THREAD, &time, vt_omp_regid[VT__OMP_TEST_NEST_LOCK]);
    result = omp_test_nest_lock(s);
    time = vt_pform_wtime();
    vt_exit(VT_CURRENT_THREAD, &time);
    return result;
  } else {
    return omp_test_nest_lock(s);
  }
} VT_GENERATE_F77_BINDINGS(pomp_test_nest_lock, POMP_TEST_NEST_LOCK,
Esempio n. 4
0
int POMP_Test_nest_lock(omp_nest_lock_t *s) {
  if ( IS_POMP_TRACE_ON ) {
    int result;
    uint64_t time;
    time = vt_pform_wtime();
    vt_enter(VT_CURRENT_THREAD, &time, vt_omp_regid[VT__OMP_TEST_NEST_LOCK]);
    result = omp_test_nest_lock(s);
    time = vt_pform_wtime();
    vt_exit(VT_CURRENT_THREAD, &time);
    return result;
  } else {
    return omp_test_nest_lock(s);
  }
}
Esempio n. 5
0
DEF_FPOMP_FUNC(int POMP_Test_nest_lock_f(omp_nest_lock_t *s)) {
  if ( IS_POMP_TRACE_ON ) {
    int result;
    uint64_t time = vt_pform_wtime();

    vt_enter(&time, vt_omp_regid[VT__OMP_TEST_NEST_LOCK]);
    result = omp_test_nest_lock(s);
    time = vt_pform_wtime();
    if (result) vt_omp_alock(&time, vt_lock_id(s));
    vt_exit(&time);
    return result;
  } else {
    return omp_test_nest_lock(s);
  }
} VT_GENERATE_F77_BINDINGS(pomp_test_nest_lock, POMP_TEST_NEST_LOCK,
Esempio n. 6
0
int POMP_Test_nest_lock(omp_nest_lock_t *s) {
  if ( IS_POMP_TRACE_ON ) {
    int result;
    uint64_t time = vt_pform_wtime();

    vt_enter(&time, vt_omp_regid[VT__OMP_TEST_NEST_LOCK]);
    result = omp_test_nest_lock(s);
    time = vt_pform_wtime();
    if (result) vt_omp_alock(&time, vt_lock_id(s));
    vt_exit(&time);
    return result;
  } else {
    return omp_test_nest_lock(s);
  }
}
Esempio n. 7
0
int test_omp_test_nest_lock()
{
  int nr_threads_in_single = 0;
  int result = 0;
  int nr_iterations = 0;
  int i;

  omp_init_nest_lock (&lck);
  #pragma omp parallel shared(lck)
  {
    #pragma omp for
    for (i = 0; i < LOOPCOUNT; i++)
    {
      /*omp_set_lock(&lck);*/
      while(!omp_test_nest_lock (&lck))
      {};
      #pragma omp flush
      nr_threads_in_single++;
      #pragma omp flush
      nr_iterations++;
      nr_threads_in_single--;
      result = result + nr_threads_in_single;
      omp_unset_nest_lock (&lck);
    }
  }
  omp_destroy_nest_lock (&lck);
  return ((result == 0) && (nr_iterations == LOOPCOUNT));
}
main ()
{
  omp_nest_lock_t	lck;
  int			t;

  int	errors = 0;


  omp_init_nest_lock (&lck);	      /* 1st initialize */
  omp_set_nest_lock (&lck);
  omp_unset_nest_lock (&lck);
  omp_destroy_nest_lock (&lck);

  omp_init_nest_lock (&lck);	      /* 2nd initialize */
  omp_set_nest_lock (&lck);
  omp_unset_nest_lock (&lck);
  omp_destroy_nest_lock (&lck);

  omp_init_nest_lock (&lck);	      /* 3rd initialize */
  t = omp_test_nest_lock (&lck);
  if (t == 0) {
    errors += 1;
  }
  omp_unset_nest_lock (&lck);
  omp_destroy_nest_lock (&lck);

  omp_init_nest_lock (&lck);	      /* 4th initialize */
  t = omp_test_nest_lock (&lck);
  if (t != 1) {
    errors += 1;
  }
  t = omp_test_nest_lock (&lck);
  if (t != 2) {
    errors += 1;
  }
  omp_unset_nest_lock (&lck);
  omp_unset_nest_lock (&lck);
  omp_destroy_nest_lock (&lck);

  if (errors == 0) {
    printf ("omp_init_nest_lock 001 : SUCCESS\n");
    return 0;
  } else {
    printf ("omp_init_nest_lock 001 : FAILED\n");
    return 1;
  }
}
void *tf (void *p)
{
  int l;
  if (p)
    {
      if (omp_test_nest_lock (&lock) != 1)
	abort ();
      if (omp_test_nest_lock (&lock) != 2)
	abort ();
    }
  pthread_barrier_wait (&bar);
  if (!p && omp_test_nest_lock (&lock) != 0)
    abort ();
  pthread_barrier_wait (&bar);
  if (p)
    {
      if (omp_test_nest_lock (&lock) != 3)
	abort ();
      omp_unset_nest_lock (&lock);
      omp_unset_nest_lock (&lock);
      omp_unset_nest_lock (&lock);
    }
  pthread_barrier_wait (&bar);
  if (!p)
    {
      if (omp_test_nest_lock (&lock) != 1)
	abort ();
      if (omp_test_nest_lock (&lock) != 2)
	abort ();
      omp_unset_nest_lock (&lock);
      omp_unset_nest_lock (&lock);
    }
  return NULL;
}
Esempio n. 10
0
File: lib-1.c Progetto: 0day-ci/gcc
int
main (void)
{
  double d, e;
  int l;
  omp_lock_t lck;
  omp_nest_lock_t nlck;

  d = omp_get_wtime ();

  omp_init_lock (&lck);
  omp_set_lock (&lck);
  if (omp_test_lock (&lck))
    abort ();
  omp_unset_lock (&lck);
  if (! omp_test_lock (&lck))
    abort ();
  if (omp_test_lock (&lck))
    abort ();
  omp_unset_lock (&lck);
  omp_destroy_lock (&lck);

  omp_init_nest_lock (&nlck);
  if (omp_test_nest_lock (&nlck) != 1)
    abort ();
  omp_set_nest_lock (&nlck);
  if (omp_test_nest_lock (&nlck) != 3)
    abort ();
  omp_unset_nest_lock (&nlck);
  omp_unset_nest_lock (&nlck);
  if (omp_test_nest_lock (&nlck) != 2)
    abort ();
  omp_unset_nest_lock (&nlck);
  omp_unset_nest_lock (&nlck);
  omp_destroy_nest_lock (&nlck);

  omp_set_dynamic (1);
  if (! omp_get_dynamic ())
    abort ();
  omp_set_dynamic (0);
  if (omp_get_dynamic ())
    abort ();

  omp_set_nested (1);
  if (! omp_get_nested ())
    abort ();
  omp_set_nested (0);
  if (omp_get_nested ())
    abort ();

  omp_set_num_threads (5);
  if (omp_get_num_threads () != 1)
    abort ();
  if (omp_get_max_threads () != 5)
    abort ();
  if (omp_get_thread_num () != 0)
    abort ();
  omp_set_num_threads (3);
  if (omp_get_num_threads () != 1)
    abort ();
  if (omp_get_max_threads () != 3)
    abort ();
  if (omp_get_thread_num () != 0)
    abort ();
  l = 0;
#pragma omp parallel reduction (|:l)
  {
    l = omp_get_num_threads () != 3;
    l |= omp_get_thread_num () < 0;
    l |= omp_get_thread_num () >= 3;
#pragma omp master
    l |= omp_get_thread_num () != 0;
  }
  if (l)
    abort ();

  if (omp_get_num_procs () <= 0)
    abort ();
  if (omp_in_parallel ())
    abort ();
#pragma omp parallel reduction (|:l)
  l = ! omp_in_parallel ();
#pragma omp parallel reduction (|:l) if (1)
  l = ! omp_in_parallel ();
  if (l)
    abort ();

  e = omp_get_wtime ();
  if (d > e)
    abort ();
  d = omp_get_wtick ();
  /* Negative precision is definitely wrong,
     bigger than 1s clock resolution is also strange.  */
  if (d <= 0 || d > 1)
    abort ();

  return 0;
}