Exemple #1
0
static void *
__upc_start_pthread (void *arg)
{
  upc_startup_args_p startup_args = arg;
  int thread_id = startup_args->thread_id;
  upc_info_p u = __upc_info;
  int *status_ptr;
  if (!u)
    __upc_fatal ("UPC runtime not initialized");
  /* MYTHREAD is located in thread local storage */
  MYTHREAD = thread_id;
  __upc_affinity_set (u, thread_id);
  /* Perform per thread initialization.  */
  __upc_per_thread_init (u);
  /* Initialize random number generator seed.
     Note: C99 requires an initial seed value of 1, per 7.20.2.2. */
  __upc_srand (1);
  status_ptr = &u->thread_info[thread_id].exit_status;
  __upc_barrier (GUPCR_RUNTIME_BARRIER_ID);
  __upc_pupc_init (&startup_args->argc, &startup_args->argv);
  *status_ptr = GUPCR_MAIN (startup_args->argc, startup_args->argv);
  p_startx (GASP_UPC_COLLECTIVE_EXIT, *status_ptr);
  p_endx (GASP_UPC_COLLECTIVE_EXIT, *status_ptr);
  return status_ptr;
}
Exemple #2
0
/** @}*/
int
GUPCR_START (int argc, char *argv[])
{
  int status;

  /* Install exit handler.  */
  atexit (gupcr_exit);

  /* Set program name for debug/trace diagnostics.  */
  gupcr_set_pgm_name (argv[0]);

  /* Initialize all runtime components.  */
  gupcr_init ();

  /* Initialize language specific variables.  */
  __upc_forall_depth = 0;

  /* Wait for all threads to finish initialization.  */
  gupcr_startup_barrier ();

  /* Perform per thread initialization.  */
  gupcr_per_thread_init ();

  /* Wait for all threads to complete per thread initialization.  */
  __upc_barrier (GUPCR_RUNTIME_BARRIER_ID);

  /* Call user main program.  */
  status = GUPCR_MAIN (argc, argv);

  /* Wait for all threads to complete.  */
  __upc_barrier (GUPCR_RUNTIME_BARRIER_ID);

  return status;
}
Exemple #3
0
static void
__upc_run_this_thread (upc_info_p u, int argc, char *argv[],
		       unsigned int thread_id)
{
  int status;
  MYTHREAD = thread_id;
  /* Perform per thread initialization.  */
  __upc_per_thread_init (u);
  if (THREADS == 1)
    {
      /* A single thread is handled as a special case.
         No child process is created to run the thread. */
      MPIR_being_debugged = 0;
      /* Give the debugger a chance to pick up runtime info.  */
      MPIR_Breakpoint ();
      /* It is safe to unlink the temporary file, after the breakpoint
         is hit.  This gives the debugger a chance to open the mmap
         global memory file so that it can access UPC shared memory.  */
      if (unlink (u->mmap_file_name) < 0)
	{
	  perror ("cannot unlink global shared memory file");
	  abort ();
	}
    }
  else if (MPIR_being_debugged)
    {
      /* Wait for partial attach flag.  */
      while (!u->partial_attach_start)
	__upc_yield_cpu ();
    
      /* Wait for the debugger to acquire us.  */
      while (!MPIR_debug_gate)
	__upc_yield_cpu ();
    }
#if GUPCR_HAVE_GUM_DEBUG
  if (__upc_gum_debug)
    {
      __upc_gum_init (THREADS, thread_id);
    }
#endif
  __upc_barrier (GUPCR_RUNTIME_BARRIER_ID);
  __upc_pupc_init (&argc, &argv);
  status = GUPCR_MAIN (argc, argv);
  p_startx (GASP_UPC_COLLECTIVE_EXIT, status);
  p_endx (GASP_UPC_COLLECTIVE_EXIT, status);
  __upc_exit (status);
}