blitz Version 0.10
|
00001 // -*- C++ -*- 00002 /*************************************************************************** 00003 * blitz/blitz.h Includes all the important header files 00004 * 00005 * $Id: blitz.h,v 1.19 2011/03/25 22:41:16 julianc Exp $ 00006 * 00007 * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org> 00008 * 00009 * This file is a part of Blitz. 00010 * 00011 * Blitz is free software: you can redistribute it and/or modify 00012 * it under the terms of the GNU Lesser General Public License 00013 * as published by the Free Software Foundation, either version 3 00014 * of the License, or (at your option) any later version. 00015 * 00016 * Blitz is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with Blitz. If not, see <http://www.gnu.org/licenses/>. 00023 * 00024 * Suggestions: blitz-devel@lists.sourceforge.net 00025 * Bugs: blitz-support@lists.sourceforge.net 00026 * 00027 * For more information, please see the Blitz++ Home Page: 00028 * https://sourceforge.net/projects/blitz/ 00029 * 00030 ***************************************************************************/ 00031 00032 #ifndef BZ_BLITZ_H 00033 #define BZ_BLITZ_H 00034 00035 /* 00036 * These symbols allow use of the IEEE and System V math libraries 00037 * (libm.a and libmsaa.a) on some platforms. 00038 */ 00039 00040 #ifdef BZ_ENABLE_XOPEN_SOURCE 00041 #ifndef _ALL_SOURCE 00042 #define _ALL_SOURCE 00043 #endif 00044 #ifndef _XOPEN_SOURCE 00045 #define _XOPEN_SOURCE 00046 #endif 00047 #ifndef _XOPEN_SOURCE_EXTENDED 00048 #define _XOPEN_SOURCE_EXTENDED 1 00049 #endif 00050 #endif 00051 00052 #include <blitz/compiler.h> // Compiler-specific directives 00053 #include <blitz/tuning.h> // Performance tuning 00054 #include <blitz/tau.h> // Profiling 00055 00056 #ifdef BZ_HAVE_STL 00057 #include <string> 00058 #endif 00059 00060 #ifdef BZ_HAVE_STD 00061 #include <iostream> 00062 #include <iomanip> 00063 #include <cstdio> // sprintf, etc. 00064 #include <cmath> 00065 #else 00066 #include <iostream.h> 00067 #include <iomanip.h> 00068 #include <stdio.h> // sprintf, etc. 00069 #include <math.h> 00070 #endif 00071 00072 #ifdef BZ_HAVE_COMPLEX 00073 #include <complex> 00074 #endif 00075 00076 #define BZ_THROW // Needed in <blitz/numinquire.h> 00077 00078 BZ_NAMESPACE(blitz) 00079 00080 #ifdef BZ_HAVE_STD 00081 BZ_USING_NAMESPACE(std) 00082 #endif 00083 00084 #ifdef BZ_GENERATE_GLOBAL_INSTANCES 00085 #define _bz_global 00086 #define BZ_GLOBAL_INIT(X) =X 00087 #else 00088 #define _bz_global extern 00089 #define BZ_GLOBAL_INIT(X) 00090 #endif 00091 00092 /* Define types for indexing, depending on whether 64- or 32-bit 00093 indices are desired. There are separate typedefs for sizeType and 00094 indexType, because it might be useful to have possibility of arrays 00095 with 64-bit numbers of elements without paying the size overhead of 00096 making all dimensional indexes 64-bit. 00097 */ 00098 // Used for dimensional indexes (not implemented yet). 00099 #ifdef BZ_FULLY64BIT 00100 #warning 64-bit array dimensions not yet implemented 00101 typedef ptrdiff_t indexType; 00102 #else 00103 typedef int indexType; 00104 #endif 00105 typedef size_t sizeType; // Used for memory indexing 00106 typedef ptrdiff_t diffType; // Used for memory index differences, ie strides 00107 00108 BZ_NAMESPACE_END 00109 00110 /* 00111 * Thread safety issues. 00112 * Compiling with -pthread under gcc, or -mt under solaris, 00113 * should automatically define _REENTRANT. Also have support 00114 * for OpenMP (which defines _OPENMP) or Windows thread implementation. 00115 * The --enable-threadsafe configure option now defines BZ_THREADSAFE. 00116 */ 00117 00118 /* 00119 * Which mutex implementation should be used for synchronizing 00120 * reference counts. Options are pthreads, OpenMP, or Windows threads. 00121 */ 00122 #ifdef BZ_THREADSAFE 00123 #if defined(_REENTRANT) 00124 #define BZ_THREADSAFE_USE_PTHREADS 00125 #elif defined (_OPENMP) 00126 #define BZ_THREADSAFE_USE_OPENMP 00127 #elif defined(_WIN32) 00128 #define BZ_THREADSAFE_USE_WINDOWS 00129 #endif 00130 #endif 00131 00132 #ifdef BZ_THREADSAFE_USE_PTHREADS 00133 #include <pthread.h> 00134 00135 #define BZ_MUTEX_DECLARE(name) mutable pthread_mutex_t name; 00136 #define BZ_MUTEX_INIT(name) pthread_mutex_init(&name,NULL); 00137 #define BZ_MUTEX_LOCK(name) pthread_mutex_lock(&name); 00138 #define BZ_MUTEX_UNLOCK(name) pthread_mutex_unlock(&name); 00139 #define BZ_MUTEX_DESTROY(name) pthread_mutex_destroy(&name); 00140 #elif defined (BZ_THREADSAFE_USE_WINDOWS) 00141 // Include Windows.h header in case user has not already done so. 00142 // Disable Windows min/max macro definitions 00143 #define NOMINMAX 00144 #include <Windows.h> 00145 00146 #define BZ_MUTEX_DECLARE(name) mutable CRITICAL_SECTION name; 00147 #define BZ_MUTEX_INIT(name) ::InitializeCriticalSection(&name); 00148 #define BZ_MUTEX_LOCK(name) ::EnterCriticalSection(&name); 00149 #define BZ_MUTEX_UNLOCK(name) ::LeaveCriticalSection(&name); 00150 #define BZ_MUTEX_DESTROY(name) ::DeleteCriticalSection(&name); 00151 #elif defined (BZ_THREADSAFE_USE_OPENMP) 00152 #include <omp.h> 00153 00154 #define BZ_MUTEX_DECLARE(name) mutable omp_lock_t name; 00155 #define BZ_MUTEX_INIT(name) omp_init_lock(&name); 00156 #define BZ_MUTEX_LOCK(name) omp_set_lock(&name); 00157 #define BZ_MUTEX_UNLOCK(name) omp_unset_lock(&name); 00158 #define BZ_MUTEX_DESTROY(name) omp_destroy_lock(&name); 00159 #else 00160 #define BZ_MUTEX_DECLARE(name) 00161 #define BZ_MUTEX_INIT(name) 00162 #define BZ_MUTEX_LOCK(name) 00163 #define BZ_MUTEX_UNLOCK(name) 00164 #define BZ_MUTEX_DESTROY(name) 00165 #endif 00166 00167 #include <blitz/bzdebug.h> // Debugging macros 00168 00169 #endif // BZ_BLITZ_H