source: CIVL/examples/mpi-omp/AMG2013/utilities/threading.h

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*BHEADER**********************************************************************
2 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
3 * Produced at the Lawrence Livermore National Laboratory.
4 * This file is part of HYPRE. See file COPYRIGHT for details.
5 *
6 * HYPRE is free software; you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License (as published by the Free
8 * Software Foundation) version 2.1 dated February 1999.
9 *
10 * $Revision: 2.4 $
11 ***********************************************************************EHEADER*/
12
13
14#ifndef hypre_THREADING_HEADER
15#define hypre_THREADING_HEADER
16
17#if defined(HYPRE_USING_OPENMP) || defined (HYPRE_USING_PGCC_SMP)
18
19int hypre_NumThreads( void );
20
21#else
22
23#define hypre_NumThreads() 1
24
25#endif
26
27
28/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
29/* The pthreads stuff needs to be reworked */
30
31#ifdef HYPRE_USE_PTHREADS
32
33#ifndef MAX_QUEUE
34#define MAX_QUEUE 256
35#endif
36
37#include <pthread.h>
38
39/* hypre_work_proc_t typedef'd to be a pointer to a function with a void*
40 argument and a void return type */
41typedef void (*hypre_work_proc_t)(void *);
42
43typedef struct hypre_workqueue_struct {
44 pthread_mutex_t lock;
45 pthread_cond_t work_wait;
46 pthread_cond_t finish_wait;
47 hypre_work_proc_t worker_proc_queue[MAX_QUEUE];
48 int n_working;
49 int n_waiting;
50 int n_queue;
51 int inp;
52 int outp;
53 void *argqueue[MAX_QUEUE];
54} *hypre_workqueue_t;
55
56void hypre_work_put( hypre_work_proc_t funcptr, void *argptr );
57void hypre_work_wait( void );
58int HYPRE_InitPthreads( int num_threads );
59void HYPRE_DestroyPthreads( void );
60void hypre_pthread_worker( int threadid );
61int ifetchadd( int *w, pthread_mutex_t *mutex_fetchadd );
62int hypre_fetch_and_add( int *w );
63void hypre_barrier(pthread_mutex_t *mpi_mtx, int unthreaded);
64int hypre_GetThreadID( void );
65
66pthread_t initial_thread;
67pthread_t hypre_thread[hypre_MAX_THREADS];
68pthread_mutex_t hypre_mutex_boxloops;
69pthread_mutex_t talloc_mtx;
70pthread_mutex_t worker_mtx;
71hypre_workqueue_t hypre_qptr;
72pthread_mutex_t mpi_mtx;
73pthread_mutex_t time_mtx;
74volatile int hypre_thread_release;
75
76#ifdef HYPRE_THREAD_GLOBALS
77int hypre_NumThreads = 4;
78#else
79extern int hypre_NumThreads;
80#endif
81
82#endif
83/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
84
85#endif
Note: See TracBrowser for help on using the repository browser.