phdMesh  Version of the Day
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
TPI.h
1 /*------------------------------------------------------------------------*/
2 /* TPI: Thread Pool Interface */
3 /* Copyright (2008) Sandia Corporation */
4 /* */
5 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
6 /* license for use of this work by or on behalf of the U.S. Government. */
7 /* */
8 /* This library is free software; you can redistribute it and/or modify */
9 /* it under the terms of the GNU Lesser General Public License as */
10 /* published by the Free Software Foundation; either version 2.1 of the */
11 /* License, or (at your option) any later version. */
12 /* */
13 /* This library is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
16 /* Lesser General Public License for more details. */
17 /* */
18 /* You should have received a copy of the GNU Lesser General Public */
19 /* License along with this library; if not, write to the Free Software */
20 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 */
21 /* USA */
22 /*------------------------------------------------------------------------*/
46 #ifndef ThreadPoolInterface_h
47 #define ThreadPoolInterface_h
48 
49 #if defined( __cplusplus )
50 extern "C" {
51 #endif
52 
53 /*--------------------------------------------------------------------*/
57 double TPI_Walltime();
58 
59 /*--------------------------------------------------------------------*/
60 /* All functions return zero for success. */
61 
62 #define TPI_LOCK_BUSY ((int) 1 /* trylock or unlock failed */ )
63 #define TPI_ERROR_NULL ((int) -1 /* NULL input */ )
64 #define TPI_ERROR_SIZE ((int) -2 /* BAD input: size or index */ )
65 #define TPI_ERROR_LOCK ((int) -3 /* BAD lock or unlock */ )
66 #define TPI_ERROR_ACTIVE ((int) -4 /* BAD input: the pool is active */ )
67 #define TPI_ERROR_INTERNAL ((int) -5 /* internal resource error */ )
68 
69 /*--------------------------------------------------------------------*/
70 
71 struct TPI_ThreadPool_Private ;
72 
73 typedef struct TPI_ThreadPool_Private * TPI_ThreadPool ;
74 
75 /*--------------------------------------------------------------------*/
80 typedef void (*TPI_parallel_subprogram)( void * shared_data ,
81  TPI_ThreadPool pool );
82 
93 int TPI_Run( TPI_parallel_subprogram /* subprogram */ ,
94  void * /* shared data */ ,
95  int /* work size */ );
96 
106 int TPI_Rank( TPI_ThreadPool , int * /* rank */ , int * /* size */ );
107 
111 int TPI_Set_lock_size( int );
112 
116 int TPI_Lock( TPI_ThreadPool , int );
117 
121 int TPI_Trylock( TPI_ThreadPool , int );
122 
126 int TPI_Unlock( TPI_ThreadPool , int );
127 
128 /*--------------------------------------------------------------------*/
132 int TPI_Init( int /* thread pool size */ );
133 
137 int TPI_Size( int * );
138 
142 int TPI_Finalize();
143 
144 /*--------------------------------------------------------------------*/
148 int TPI_Concurrency();
149 
150 /*--------------------------------------------------------------------*/
156 int TPI_Partition( int /* Thread_Rank */ ,
157  int /* Thread_Size */ ,
158  int /* Number */ ,
159  int * /* Local_Begin */ ,
160  int * /* Local_Number */ );
161 
162 /*--------------------------------------------------------------------*/
163 
164 #if defined( __cplusplus )
165 }
166 #endif
167 
168 #endif
169