Ejemplo n.º 1
0
main ()
{
  omp_nest_lock_t	lck;

  int			errors = 0;


  omp_init_nest_lock (&lck);
  omp_set_nest_lock (&lck);
  omp_set_nest_lock (&lck);
  omp_unset_nest_lock (&lck);
  omp_unset_nest_lock (&lck);
  omp_destroy_nest_lock (&lck);

  omp_init_nest_lock (&lck);
  omp_set_nest_lock (&lck);
  omp_unset_nest_lock (&lck);

  omp_set_nest_lock (&lck);
  omp_set_nest_lock (&lck);
  omp_unset_nest_lock (&lck);
  omp_unset_nest_lock (&lck);
  


  if (errors == 0) {
    printf ("omp_unset_nest_lock 001 : SUCCESS\n");
    return 0;
  } else {
    printf ("omp_unset_nest_lock 001 : FAILED\n");
    return 1;
  }
}
Ejemplo n.º 2
0
void POMP2_Set_nest_lock(omp_nest_lock_t *s) {
  if ( pomp2_tracing ) {
    esd_enter(epk_omp_regid[EPK__OMP_SET_NEST_LOCK]);
    omp_set_nest_lock(s);
    if ( pomp2_tracing > 1 ) esd_omp_alock(epk_lock_id(s));
    esd_exit(epk_omp_regid[EPK__OMP_SET_NEST_LOCK]);
  } else {
    omp_set_nest_lock(s);
  }
}
Ejemplo n.º 3
0
DEF_FPOMP_FUNC(void POMP_Set_nest_lock_f(omp_nest_lock_t *s)) {
  if ( IS_POMP_TRACE_ON ) {
    uint64_t time = vt_pform_wtime();
    vt_enter(&time, vt_omp_regid[VT__OMP_SET_NEST_LOCK]);
    omp_set_nest_lock(s);
    time = vt_pform_wtime();
    vt_omp_alock(&time, vt_lock_id(s));
    vt_exit(&time);
  } else {
    omp_set_nest_lock(s);
  }
} VT_GENERATE_F77_BINDINGS(pomp_set_nest_lock, POMP_SET_NEST_LOCK,
Ejemplo n.º 4
0
void POMP_Set_nest_lock(omp_nest_lock_t *s) {
  if ( IS_POMP_TRACE_ON ) {
    uint64_t time = vt_pform_wtime();
    vt_enter(&time, vt_omp_regid[VT__OMP_SET_NEST_LOCK]);
    omp_set_nest_lock(s);
    time = vt_pform_wtime();
    vt_omp_alock(&time, vt_lock_id(s));
    vt_exit(&time);
  } else {
    omp_set_nest_lock(s);
  }
}
Ejemplo n.º 5
0
VT_DECLDEF(void POMP_Set_nest_lock_f(omp_nest_lock_t *s)) {
  if ( IS_POMP_TRACE_ON ) {
    uint64_t time;
    time = vt_pform_wtime();
    vt_enter(VT_CURRENT_THREAD, &time, vt_omp_regid[VT__OMP_SET_NEST_LOCK]);
    omp_set_nest_lock(s);
    time = vt_pform_wtime();
    vt_exit(VT_CURRENT_THREAD, &time);
  } else {
    omp_set_nest_lock(s);
  }
} VT_GENERATE_F77_BINDINGS(pomp_set_nest_lock, POMP_SET_NEST_LOCK,
Ejemplo n.º 6
0
/* Exm finalization
 * Remove any left over allocations, but we don't destroy the lock--XXX
 */
static void
exm_finalize ()
{
#if defined(DEBUG) || defined(DEBUG1)
  syslog (LOG_DEBUG, "finalize READY=%d\n", READY);
#endif
  struct map *m, *tmp;
  pid_t pid;
  omp_set_nest_lock (&lock);
  READY = 0;
  HASH_ITER (hh, flexmap, m, tmp)
  {
#if defined(DEBUG) || defined(DEBUG1)
    syslog (LOG_DEBUG, "finalize unmap address %p of size %lu\n", m->addr,
            (unsigned long int) m->length);
#endif
    munmap (m->addr, m->length);
    pid = getpid ();
    if (pid == m->pid)
      {
#if defined(DEBUG) || defined(DEBUG1)
        syslog (LOG_DEBUG, "finalize unlink %p:%s\n", m->addr, m->path);
#endif
        unlink (m->path);
        HASH_DEL (flexmap, m);
        freemap (m);
      }
  }
Ejemplo n.º 7
0
int test_omp_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_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));
}
Ejemplo n.º 8
0
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;
  }
}
Ejemplo n.º 9
0
Archivo: a.40.1.c Proyecto: 0day-ci/gcc
void
incr_pair (pair * p, int a, int b)
{
  omp_set_nest_lock (&p->lck);
  incr_a (p, a);
  incr_b (p, b);
  omp_unset_nest_lock (&p->lck);
}
Ejemplo n.º 10
0
int main(void)
{
	int i;
	int *A = malloc(sizeof(int)*SIZE);
	int *B = malloc(sizeof(int)*SIZE);
	int *C = malloc(sizeof(int)*SIZE);

	for(i=0;i<SIZE; i++)
	{
		A[i]=i*17%7;
		B[i]=i*19%7;
		C[i]=0;
	}

	omp_nest_lock_t lock;
	omp_init_nest_lock(&lock);

	int somme = 0;
//compute for real!
	int j;
	for(j=0;j<1; j++) {
		debug("loop %d\n", j);
		debug("\trunning parallel for schedule(static)\n");
#pragma omp parallel for
 		for(i=0;i<SIZE; i++)
 		{
 			C[i]=A[i]+B[i];
			if(i%1000 == 0) {
			  omp_set_nest_lock(&lock);
			  compute(10);
			  {
			    omp_set_nest_lock(&lock);
			    compute(10);
			    omp_unset_nest_lock(&lock);
			  }
			  somme+= C[i];
			  omp_unset_nest_lock(&lock);
			}
 		}

	}

	debug("somme = %d\n", somme);
	return 0;
}
Ejemplo n.º 11
0
Archivo: a.40.1.c Proyecto: 0day-ci/gcc
void
incr_b (pair * p, int b)
{
  /* Called both from incr_pair and elsewhere, */
  /* so need a nestable lock. */
  omp_set_nest_lock (&p->lck);
  p->b += b;
  omp_unset_nest_lock (&p->lck);
}
Ejemplo n.º 12
0
void
_mp_bcs_nest(void)
{
  if (!is_init_nest) {
    _mp_p(&nest_sem);
    if (!is_init_nest) {
      omp_init_nest_lock(&nest_lock);
      is_init_nest = 1;
    }
    _mp_v(&nest_sem);
  }
  omp_set_nest_lock(&nest_lock);
}
Ejemplo n.º 13
0
int omp_test_nest_lock ( omp_nest_lock_t *arg )

/******************************************************************************/
/*
  Purpose:

    OMP_TEST_NEST_LOCK tests a nestable lock.

  Discussion:

    Calling this routine with an uninitialized lock causes an error.

  Licensing:

    This code is distributed under the GNU LGPL license. 

  Modified:

    17 May 2012

  Author:

    John Burkardt

  Reference:

    OpenMP Application Program Interface,
    Version 3.1,
    July 2011.

  Parameters:

    Input/output, omp_nest_lock_t *ARG, the nestable lock.
    If the lock was initialized but not set, it is set by this call.

    Output, int OMP_TEST_NEST_LOCK, returns the new nesting count,
    if the call was successful.  Otherwise, the value 0 is returned.
*/
{
  struct __omp_nest_lock *nlock = ( struct __omp_nest_lock * ) arg;
  omp_set_nest_lock ( arg) ;
  return nlock->count;
}
Ejemplo n.º 14
0
Archivo: lib-1.c Proyecto: 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;
}
Ejemplo n.º 15
0
main ()
{
  omp_nest_lock_t	lck;
  int			thds;
  volatile int		i;

  int		errors = 0;


  thds = omp_get_max_threads ();
  if (thds == 1) {
    printf ("should be run this program on multi thread.\n");
    exit (0);
  }

  omp_init_nest_lock(&lck);
  i = 0;

  #pragma omp parallel
  {
    int	tmp;

    #pragma omp barrier

    omp_set_nest_lock (&lck);

    #pragma omp flush (i)	/* SCASH need flush, here */
    i = i + 1;
    tmp  = i;
    waittime(1);

    #pragma omp flush (i)	/* SCASH need flush, here */
    if (i != tmp) {	
      #pragma omp critical
      errors += 1;
    }
    omp_set_nest_lock (&lck);
    omp_unset_nest_lock (&lck);
    waittime(1);

    #pragma omp flush (i)	/* SCASH need flush, here */
    if (i != tmp) {	
      #pragma omp critical
      errors += 1;
    }

    omp_unset_nest_lock (&lck);
  }

  if (i != thds) {
    errors += 1;
  }


  if (errors == 0) {
    printf ("omp_unset_nest_lock 002 : SUCCESS\n");
    return 0;
  } else {
    printf ("omp_unset_nest_lock 002 : FAILED\n");
    return 1;
  }
}
Ejemplo n.º 16
0
int
omp_test_nest_lock(omp_nest_lock_t* nlock)
{
  omp_set_nest_lock(nlock);
  return nlock->count;
}