コード例 #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;
  }
}
コード例 #2
0
ファイル: epk_pomp2.c プロジェクト: linearregression/scalasca
void POMP2_Init_nest_lock(omp_nest_lock_t *s) {
  if ( pomp2_tracing ) {
    esd_enter(epk_omp_regid[EPK__OMP_INIT_NEST_LOCK]);
    omp_init_nest_lock(s);
    epk_lock_init(s);
    esd_exit(epk_omp_regid[EPK__OMP_INIT_NEST_LOCK]);
  } else {
    omp_init_nest_lock(s);
    epk_lock_init(s);
  }
}
コード例 #3
0
ファイル: vt_pomp.c プロジェクト: hpc/cce-mpi-openmpi-1.4.3
DEF_FPOMP_FUNC(void POMP_Init_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_INIT_NEST_LOCK]);
    omp_init_nest_lock(s);
    vt_lock_init(s);
    time = vt_pform_wtime();
    vt_exit(&time);
  } else {
    omp_init_nest_lock(s);
    vt_lock_init(s);
  }
} VT_GENERATE_F77_BINDINGS(pomp_init_nest_lock, POMP_INIT_NEST_LOCK,
コード例 #4
0
ファイル: vt_pomp.c プロジェクト: hpc/cce-mpi-openmpi-1.4.3
void POMP_Init_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_INIT_NEST_LOCK]);
    omp_init_nest_lock(s);
    vt_lock_init(s);
    time = vt_pform_wtime();
    vt_exit(&time);
  } else {
    omp_init_nest_lock(s);
    vt_lock_init(s);
  }
}
コード例 #5
0
VT_DECLDEF(void POMP_Init_nest_lock_f(omp_nest_lock_t *s)) {
  if ( !pomp_initialized ) POMP_Init();

  if ( IS_POMP_TRACE_ON ) {
    uint64_t time;
    time = vt_pform_wtime();
    vt_enter(VT_CURRENT_THREAD, &time, vt_omp_regid[VT__OMP_INIT_NEST_LOCK]);
    omp_init_nest_lock(s);
    time = vt_pform_wtime();
    vt_exit(VT_CURRENT_THREAD, &time);
  } else {
    omp_init_nest_lock(s);
  }
} VT_GENERATE_F77_BINDINGS(pomp_init_nest_lock, POMP_INIT_NEST_LOCK,
コード例 #6
0
void POMP_Init_nest_lock(omp_nest_lock_t *s) {
  if ( !pomp_initialized ) POMP_Init();

  if ( IS_POMP_TRACE_ON ) {
    uint64_t time;
    time = vt_pform_wtime();
    vt_enter(VT_CURRENT_THREAD, &time, vt_omp_regid[VT__OMP_INIT_NEST_LOCK]);
    omp_init_nest_lock(s);
    time = vt_pform_wtime();
    vt_exit(VT_CURRENT_THREAD, &time);
  } else {
    omp_init_nest_lock(s);
  }
}
コード例 #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));
}
コード例 #8
0
void mexFunction(int32_T nlhs, mxArray *plhs[], int32_T nrhs, const mxArray
                 *prhs[])
{
  emlrtStack st = { NULL, NULL, NULL };

  mexAtExit(rffe_test_atexit);

  /* Initialize the memory manager. */
  omp_init_lock(&emlrtLockGlobal);
  omp_init_nest_lock(&emlrtNestLockGlobal);
  emlrtLoadLibrary("/usr/local/MATLAB/R2015b/sys/os/glnxa64/libiomp5.so");

  /* Module initialization. */
  rffe_test_initialize();
  st.tls = emlrtRootTLSGlobal;
  emlrtSetJmpBuf(&st, &emlrtJBEnviron);
  if (setjmp(emlrtJBEnviron) == 0) {
    /* Dispatch the entry-point. */
    rffe_test_mexFunction(nlhs, plhs, nrhs, prhs);
    omp_destroy_lock(&emlrtLockGlobal);
    omp_destroy_nest_lock(&emlrtNestLockGlobal);
  } else {
    omp_destroy_lock(&emlrtLockGlobal);
    omp_destroy_nest_lock(&emlrtNestLockGlobal);
    emlrtReportParallelRunTimeError(&st);
  }
}
コード例 #9
0
ファイル: lock-2.c プロジェクト: 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;
}
コード例 #10
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;
  }
}
コード例 #11
0
int
main (void)
{
  pthread_t th;
  omp_init_nest_lock (&lock);
  pthread_barrier_init (&bar, NULL, 2);
  pthread_create (&th, NULL, tf, NULL);
  tf ("");
  pthread_join (th, NULL);
  omp_destroy_nest_lock (&lock);
  return 0;
}
コード例 #12
0
ファイル: llcrit.c プロジェクト: heinerbilch/flang
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);
}
コード例 #13
0
ファイル: test_nest_lock.c プロジェクト: cot/eztrace-test
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;
}
コード例 #14
0
ファイル: exm.c プロジェクト: bwlewis/flexmem
/* Exm initialization
 *
 * Initializes synchronizing lock variable and address/file key/value map.
 * This function may be called multiple times, be aware of that and keep
 * this as tiny/simple as possible and thread-safe.
 *
 * Oddly, exm_init is invoked lazily by calloc, which will be triggered
 * either directly by a program calloc call, or on first use of any of the
 * intercepted functions because all of them except for calloc call dlsym,
 * which itself calls calloc.
 *
 */
static void
exm_init ()
{
  char *endptr, *EXM_CHILD_COW, *EXM_THRESHOLD, *EXM_TMPDIR;
  if (READY < 0)
    {
      omp_init_nest_lock (&lock);
      READY = 1;
      openlog ("exm", LOG_PERROR | LOG_PID, LOG_USER);
      EXM_TMPDIR = getenv ("TMPDIR");
      if( EXM_TMPDIR != NULL)
        {
          snprintf (exm_data_path, EXM_MAX_PATH_LEN, "%s", EXM_TMPDIR);
        }
      else snprintf (exm_data_path, EXM_MAX_PATH_LEN, "%s", TMPDIR);
      EXM_THRESHOLD = getenv ("EXM_THRESHOLD");
      if (EXM_THRESHOLD != NULL)
        {
          errno = 0;
          unsigned long _threshold = strtoul (EXM_THRESHOLD, &endptr, 0);
          if (errno == 0)
            exm_alloc_threshold = (size_t) _threshold;
        }
      EXM_CHILD_COW = getenv ("EXM_CHILD_COW");
      if (EXM_CHILD_COW != NULL)
        {
          errno = 0;
          long _child_cow = strtol (EXM_CHILD_COW, &endptr, 10);
          if (errno == 0)
            exm_child_cow = (int) _child_cow;
        }
    }
  if (!exm_hook)
    exm_hook = __libc_malloc;
  if (!exm_default_free)
    exm_default_free = (void *(*)(void *)) dlsym (RTLD_NEXT, "free");
}
コード例 #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;
  }
}
コード例 #16
0
/* Function Definitions */
void simulate_initialize(void)
{
  rt_InitInfAndNaN(8U);
  omp_init_nest_lock(&emlrtNestLockGlobal);
}
コード例 #17
0
ファイル: lib-1.c プロジェクト: 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;
}