/[escript]/trunk/esysUtils/src/maths.h
ViewVC logotype

Contents of /trunk/esysUtils/src/maths.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1628 - (show annotations)
Fri Jul 11 13:12:46 2008 UTC (11 years, 2 months ago) by phornby
Original Path: trunk/paso/src/Common.h
File MIME type: text/plain
File size: 7357 byte(s)

Merge in /branches/windows_from_1456_trunk_1620_merged_in branch.

You will find a preserved pre-merge trunk in tags under tags/trunk_at_1625.
That will be useful for diffing & checking on my stupidity.

Here is a list of the conflicts and their resolution at this
point in time.


=================================================================================
(LLWS == looks like white space).

finley/src/Assemble_addToSystemMatrix.c - resolve to branch - unused var. may be wrong.....
finley/src/CPPAdapter/SystemMatrixAdapter.cpp - resolve to branch - LLWS
finley/src/CPPAdapter/MeshAdapter.cpp - resolve to branch - LLWS
paso/src/PCG.c - resolve to branch - unused var fixes.
paso/src/SolverFCT.c - resolve to branch - LLWS
paso/src/FGMRES.c - resolve to branch - LLWS
paso/src/Common.h - resolve to trunk version. It's omp.h's include... not sure it's needed,
but for the sake of saftey.....
paso/src/Functions.c - resolve to branch version, indentation/tab removal and return error
on bad unimplemented Paso_FunctionCall.
paso/src/SolverFCT_solve.c - resolve to branch version, unused vars
paso/src/SparseMatrix_MatrixVector.c - resolve to branch version, unused vars.
escript/src/Utils.cpp - resloved to branch, needs WinSock2.h
escript/src/DataExpanded.cpp - resolved to branch version - LLWS
escript/src/DataFactory.cpp - resolve to branch version
=================================================================================

This currently passes tests on linux (debian), but is not checked on windows or Altix yet.

This checkin is to make a trunk I can check out for windows to do tests on it.

Known outstanding problem is in the operator=() method of exceptions
causing warning messages on the intel compilers.

May the God of doughnuts have mercy on my soul.


1
2 /* $Id$ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 #ifndef INC_PASO_COMMON
17 #define INC_PASO_COMMON
18
19 /**************************************************************/
20
21 /* Finley finite element solver: common include file */
22
23 /**************************************************************/
24
25 /* Copyrights by ACcESS Australia, 2003 */
26 /* Version: $Id$ */
27
28 /**************************************************************/
29
30 /* some system values */
31 /* FIXME: This is not satisfactory. */
32 /* _ECC, __INTEL_COMPILER, and other */
33 /* intel compiler pre-defines need to be handled */
34 /* (__ICL, __ICC come to mind) */
35 #if ( defined __INTEL_COMPILER )
36 #include <mathimf.h>
37 #else
38 #include <math.h>
39 #endif
40
41 #if (defined __OPENMP)
42 #include <omp.h>
43 #endif
44
45 #include <float.h>
46 #include <stdio.h>
47 #include <limits.h>
48 #include <stdlib.h>
49 #include <string.h>
50
51 #define LenString_MAX FILENAME_MAX*2
52 #define LenErrorMsg_MAX LenString_MAX
53
54 /* on some arcitectures it could be a good idea to use long rather than int */
55 /* this has not really been tested */
56
57 typedef int dim_t;
58 typedef int index_t;
59 typedef int bool_t;
60 typedef int type_t;
61 typedef int err_t;
62
63 #define INDEX_T_MAX INT_MAX
64 #define EPSILON DBL_EPSILON
65 #define LARGE_POSITIVE_FLOAT DBL_MAX
66
67 /**************************************************************/
68
69 /* some useful functions: */
70
71 #define FALSE 0
72 #define TRUE 1
73 #define UNKNOWN -1
74 #define DBLE(_x_) (double)(_x_)
75 #define INDEX1(_X1_) (_X1_)
76 #define INDEX2(_X1_,_X2_,_N1_) ((_X1_)+(_N1_)*(_X2_))
77 #define INDEX3(_X1_,_X2_,_X3_,_N1_,_N2_) ((_X1_)+(_N1_)*INDEX2(_X2_,_X3_,_N2_))
78 #define INDEX4(_X1_,_X2_,_X3_,_X4_,_N1_,_N2_,_N3_) ((_X1_)+(_N1_)*INDEX3(_X2_,_X3_,_X4_,_N2_,_N3_))
79 #define INDEX5(_X1_,_X2_,_X3_,_X4_,_X5_,_N1_,_N2_,_N3_,_N4_) ((_X1_)+(_N1_)*INDEX4(_X2_,_X3_,_X4_,_X5_,_N2_,_N3_,_N4_))
80 #define INDEX6(_X1_,_X2_,_X3_,_X4_,_X5_,_X6_,_N1_,_N2_,_N3_,_N4_,_N5_) ((_X1_)+(_N1_)*INDEX5(_X2_,_X3_,_X4_,_X5_,_X6_,_N2_,_N3_,_N4_,_N5_))
81
82 #define MAX(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg1_) : (_arg2_))
83 #define MAX3(_arg1_,_arg2_,_arg3_) MAX(_arg1_,MAX(_arg2_,_arg3_))
84 #define MIN(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg2_) : (_arg1_))
85 #define MIN3(_arg1_,_arg2_,_arg3_) MIN(_arg1_,MIN(_arg2_,_arg3_))
86 #define ABS(_arg_) MAX((_arg_),-(_arg_))
87 #define SIGN(_arg_) ((_arg_)>0 ? 1 : ((_arg_)<0 ? -1 : 0 ))
88 #define SWAP(_a0_,_a1_,_type_) { \
89 _type_ s; \
90 s=(_a0_); \
91 _a0_= (_a1_); \
92 _a1_=s; \
93 }
94 /**************************************************************/
95 /* memory allocation: */
96 /* Wise to not use PASO_MALLOC/FREE/REALLOC and */
97 /* PASO_THREAD... directly. These are only for tailoring */
98 /* the main macros that follow */
99 /**************************************************************/
100
101 #if defined(_WIN32) /* Use python for memory management on windows. */
102
103 #include <python.h>
104
105 #define PASO_MALLOC PyMem_Malloc
106 #define PASO_FREE PyMem_Free
107 #define PASO_REALLOC PyMem_Realloc
108
109 #else
110
111 #include <malloc.h>
112
113 #define PASO_MALLOC malloc
114 #define PASO_FREE free
115 #define PASO_REALLOC realloc
116
117 #endif
118
119
120 /* FIXME: This is not satisfactory. */
121 /* _ECC, __INTEL_COMPILER, and other */
122 /* intel compiler pre-defines need to be handled */
123 /* (__ICL, __ICC come to mind) */
124 /* Also, _WIN32 may take this branch one day... */
125 /* SO KEEP ALL THREAD_MEMALLOC/FREEs CONFINED TO THE PASO LIBRARY. */
126
127 #if defined(__ECC) && defined(_OPENMP) /* ECC version of intel compiler with openmp. */
128 #include <omp.h>
129 #define PASO_THREAD_MALLOC kmp_malloc
130 #define PASO_THREAD_FREE kmp_free
131 #else
132 #define PASO_THREAD_MALLOC PASO_MALLOC
133 #define PASO_THREAD_FREE PASO_FREE
134 #endif
135
136 /******************The main macros ************************************/
137
138 #define MEMALLOC(_LENGTH_,_TYPE_) \
139 (_TYPE_*) PASO_MALLOC(((size_t)(_LENGTH_))*sizeof(_TYPE_))
140
141 /* do {} while(0) - an old trick for bracketing a macro that */
142 /* makes sure a semi-colon does no harm. */
143
144 #define MEMFREE(_PTR_) \
145 do \
146 { \
147 if ((void *)(_PTR_) != NULL ) { PASO_FREE(_PTR_); (_PTR_) = NULL; } \
148 } while(0)
149
150 #define MEMREALLOC(_POINTER_,_LENGTH_,_TYPE_) \
151 do \
152 { \
153 if( (_POINTER_)!=NULL ) \
154 { \
155 _POINTER_ = (_TYPE_*)PASO_REALLOC((void*)(_POINTER_), \
156 ((size_t)(_LENGTH_))*sizeof(_TYPE_) ); \
157 } \
158 else \
159 { \
160 _POINTER_ = (_TYPE_*)PASO_MALLOC( ((size_t)(_LENGTH_))*sizeof(_TYPE_) ); \
161 } \
162 } while(0)
163
164 #define TMPMEMALLOC MEMALLOC
165 #define TMPMEMFREE MEMFREE
166
167 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) \
168 (_TYPE_*) PASO_THREAD_MALLOC/**/(((size_t)(_LENGTH_))*sizeof(_TYPE_))
169
170 #define THREAD_MEMFREE(_PTR_) \
171 do \
172 { \
173 if ((void *)(_PTR_) != NULL ) { PASO_THREAD_FREE(_PTR_); (_PTR_) = NULL; } \
174 } while(0)
175
176
177 /*
178 This was useful for seeing what memory is being allocated if you get an "Out of memory" error
179 if used again, bracket with do {} while(0)
180 #define TMPMEMALLOC(_LENGTH_,_TYPE_) (printf("TMPMEMALLOC at %s %d #bytes=%d*%d=%d\n", __FILE__, __LINE__, _LENGTH_, sizeof(_TYPE_), ((size_t)(_LENGTH_) * sizeof(_TYPE_))) , (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_)))
181
182 This was useful for seeing where memory is being freed if you get an "glibc detected...free" error
183 if used again, bracket with do {} while(0)
184 #define TMPMEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { printf("TMPMEMFREE AAA %s %d\n", __FILE__, __LINE__); free(_PTR_); (_PTR_) = NULL; printf("TMPMEMFREE BBB %s %d\n", __FILE__, __LINE__); }
185 */
186
187 #endif /* #ifndef INC_PASO_COMMON */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26