Source
printf ("PTHREADS get_thread_num: 1st call threadid=%lu maps to location %d\n", (unsigned long) mythreadid, n);
/*
** $Id: threadutil.c,v 1.28 2009/12/31 01:51:59 rosinski Exp $
**
** Author: Jim Rosinski
**
** Utility functions handle thread-based GPTL needs.
*/
/* Max allowable number of threads (used only when THREADED_PTHREADS is true) */
/* VERBOSE is a debugging ifdef local to this file */
/* Ensure that threadinit() is called only once */
static bool first = true;
/**********************************************************************************/
/*
** 3 sets of routines: OMP threading, PTHREADS, unthreaded
*/
/* array of thread ids used to determine if thread has been started (omp only) */
static int *threadid_omp;
/*
** threadinit: Initialize threadid_omp and set number of threads
**
** Output arguments:
** nthreads: number of threads (set to zero, reset to maxthreads by get_thread_num)
** maxthreads: max number of threads
*/
int threadinit (int *nthreads, int *maxthreads)
{
int t; /* loop index */
*maxthreads = MAX ((1), (omp_get_max_threads ()));
*nthreads = 0;
if (omp_get_thread_num () > 0)
return GPTLerror ("GPTL: threadinit: MUST be called only by master thread");