1998-11-07 07:33:33 +08:00
|
|
|
/*BHEADER**********************************************************************
|
|
|
|
|
* (c) 1997 The Regents of the University of California
|
|
|
|
|
*
|
|
|
|
|
* See the file COPYRIGHT_and_DISCLAIMER for a complete copyright
|
|
|
|
|
* notice, contact person, and disclaimer.
|
|
|
|
|
*
|
|
|
|
|
* $Revision$
|
|
|
|
|
*********************************************************************EHEADER*/
|
|
|
|
|
|
|
|
|
|
#ifndef hypre_THREADING_HEADER
|
|
|
|
|
#define hypre_THREADING_HEADER
|
|
|
|
|
|
1998-11-12 04:25:14 +08:00
|
|
|
#ifdef HYPRE_USE_PTHREADS
|
|
|
|
|
|
1998-11-07 07:33:33 +08:00
|
|
|
#ifndef MAX_QUEUE
|
|
|
|
|
#define MAX_QUEUE 256
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include<pthread.h>
|
1999-02-11 00:47:41 +08:00
|
|
|
#include "utilities.h"
|
1998-11-07 07:33:33 +08:00
|
|
|
|
|
|
|
|
/* hypre_work_proc_t typedef'd to be a pointer to a function with a void*
|
|
|
|
|
argument and a void return type */
|
|
|
|
|
typedef void (*hypre_work_proc_t)(void *);
|
|
|
|
|
|
|
|
|
|
typedef struct hypre_workqueue_struct {
|
|
|
|
|
pthread_mutex_t lock;
|
|
|
|
|
pthread_cond_t work_wait;
|
|
|
|
|
pthread_cond_t finish_wait;
|
|
|
|
|
hypre_work_proc_t worker_proc_queue[MAX_QUEUE];
|
|
|
|
|
int n_working;
|
|
|
|
|
int n_waiting;
|
|
|
|
|
int n_queue;
|
|
|
|
|
int inp;
|
|
|
|
|
int outp;
|
|
|
|
|
void *argqueue[MAX_QUEUE];
|
|
|
|
|
} *hypre_workqueue_t;
|
|
|
|
|
|
1998-11-10 07:20:53 +08:00
|
|
|
void hypre_work_put( hypre_work_proc_t funcptr, void *argptr );
|
|
|
|
|
void hypre_work_wait( void );
|
1998-12-23 02:24:55 +08:00
|
|
|
int HYPRE_InitPthreads( int num_threads );
|
1998-11-10 07:20:53 +08:00
|
|
|
void HYPRE_DestroyPthreads( void );
|
|
|
|
|
void hypre_pthread_worker( int threadid );
|
|
|
|
|
int ifetchadd( int *w, pthread_mutex_t *mutex_fetchadd );
|
|
|
|
|
int hypre_fetch_and_add( int *w );
|
1998-11-24 01:19:00 +08:00
|
|
|
void hypre_barrier(pthread_mutex_t *mpi_mtx, int unthreaded);
|
1998-12-18 06:08:26 +08:00
|
|
|
int hypre_GetThreadID( void );
|
|
|
|
|
|
1998-11-21 08:14:52 +08:00
|
|
|
pthread_t initial_thread;
|
1998-12-19 07:53:24 +08:00
|
|
|
pthread_t hypre_thread[hypre_MAX_THREADS];
|
1998-11-07 07:33:33 +08:00
|
|
|
pthread_mutex_t hypre_mutex_boxloops;
|
1998-12-10 01:45:48 +08:00
|
|
|
pthread_mutex_t talloc_mtx;
|
1998-12-24 08:09:29 +08:00
|
|
|
pthread_mutex_t worker_mtx;
|
1998-11-07 07:33:33 +08:00
|
|
|
hypre_workqueue_t hypre_qptr;
|
1998-11-10 07:52:17 +08:00
|
|
|
pthread_mutex_t mpi_mtx;
|
1998-12-18 06:08:26 +08:00
|
|
|
pthread_mutex_t time_mtx;
|
1999-01-12 01:31:02 +08:00
|
|
|
volatile int hypre_thread_release;
|
1998-11-07 07:33:33 +08:00
|
|
|
|
1998-12-19 07:53:24 +08:00
|
|
|
#ifdef HYPRE_THREAD_GLOBALS
|
|
|
|
|
int hypre_NumThreads = 4;
|
|
|
|
|
#else
|
|
|
|
|
extern int hypre_NumThreads;
|
|
|
|
|
#endif
|
|
|
|
|
|
1998-11-07 07:33:33 +08:00
|
|
|
#endif
|
1998-11-12 04:25:14 +08:00
|
|
|
|
|
|
|
|
#endif
|