TPI.h

00001 /*------------------------------------------------------------------------*/
00002 /*                    TPI: Thread Pool Interface                          */
00003 /*                Copyright (2008) Sandia Corporation                     */
00004 /*                                                                        */
00005 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00006 /*  license for use of this work by or on behalf of the U.S. Government.  */
00007 /*                                                                        */
00008 /*  This library is free software; you can redistribute it and/or modify  */
00009 /*  it under the terms of the GNU Lesser General Public License as        */
00010 /*  published by the Free Software Foundation; either version 2.1 of the  */
00011 /*  License, or (at your option) any later version.                       */
00012 /*                                                                        */
00013 /*  This library is distributed in the hope that it will be useful,       */
00014 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of        */
00015 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     */
00016 /*  Lesser General Public License for more details.                       */
00017 /*                                                                        */
00018 /*  You should have received a copy of the GNU Lesser General Public      */
00019 /*  License along with this library; if not, write to the Free Software   */
00020 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307   */
00021 /*  USA                                                                   */
00022 /*------------------------------------------------------------------------*/
00046 #ifndef ThreadPoolInterface_h
00047 #define ThreadPoolInterface_h
00048 
00049 #if defined( __cplusplus )
00050 extern "C" {
00051 #endif
00052 
00053 /*--------------------------------------------------------------------*/
00057 double TPI_Walltime();
00058 
00059 /*--------------------------------------------------------------------*/
00060 /* All functions return zero for success. */
00061 
00062 #define TPI_LOCK_BUSY      ((int)  1  /* trylock or unlock failed */ )
00063 #define TPI_ERROR_NULL     ((int) -1  /* NULL input */ )
00064 #define TPI_ERROR_SIZE     ((int) -2  /* BAD input: size or index */ )
00065 #define TPI_ERROR_LOCK     ((int) -3  /* BAD lock or unlock */ )
00066 #define TPI_ERROR_ACTIVE   ((int) -4  /* BAD input: the pool is active  */ )
00067 #define TPI_ERROR_INTERNAL ((int) -5  /* internal resource error */ )
00068 
00069 /*--------------------------------------------------------------------*/
00070 
00071 struct TPI_ThreadPool_Private ; 
00072 
00073 typedef struct TPI_ThreadPool_Private * TPI_ThreadPool ;
00074 
00075 /*--------------------------------------------------------------------*/
00080 typedef void (*TPI_parallel_subprogram)( void * shared_data ,
00081                                          TPI_ThreadPool pool );
00082 
00093 int TPI_Run( TPI_parallel_subprogram /* subprogram  */ ,
00094              void *                  /* shared data */ ,
00095              int                     /* work size   */ );
00096 
00106 int TPI_Rank( TPI_ThreadPool , int * /* rank */ , int * /* size */ );
00107 
00111 int TPI_Set_lock_size( int );
00112 
00116 int TPI_Lock( TPI_ThreadPool , int );
00117 
00121 int TPI_Trylock( TPI_ThreadPool , int );
00122 
00126 int TPI_Unlock( TPI_ThreadPool , int );
00127 
00128 /*--------------------------------------------------------------------*/
00132 int TPI_Init( int /* thread pool size */ );
00133 
00137 int TPI_Size( int * );
00138 
00142 int TPI_Finalize();
00143 
00144 /*--------------------------------------------------------------------*/
00148 int TPI_Concurrency();
00149 
00150 /*--------------------------------------------------------------------*/
00156 int TPI_Partition( int   /* Thread_Rank */ ,
00157                    int   /* Thread_Size */ ,
00158                    int   /* Number */ ,
00159                    int * /* Local_Begin */ ,
00160                    int * /* Local_Number */ );
00161 
00162 /*--------------------------------------------------------------------*/
00163 
00164 #if defined( __cplusplus )
00165 }
00166 #endif
00167 
00168 #endif
00169 

Generated on Wed May 12 21:24:30 2010 for phdMesh by  doxygen 1.4.7