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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 779 - (show annotations)
Fri Jul 14 07:41:31 2006 UTC (13 years, 2 months ago) by woo409
Original Path: trunk/paso/src/Common.h
File MIME type: text/plain
File size: 4828 byte(s)
+ Updated compilation options for Cognac to squeeze out a bit more performance
+ Now compiles using the Intel Math headers (mathimf.h) rather than plain math.h on both Win32 and Linux platforms when using the Intel compiler. Gives a small boost to performance on Altix and is essential on Windows


1 /* $Id$ */
2
3 /*
4 ********************************************************************************
5 * Copyright 2006 by ACcESS MNRF *
6 * *
7 * http://www.access.edu.au *
8 * Primary Business: Queensland, Australia *
9 * Licensed under the Open Software License version 3.0 *
10 * http://www.opensource.org/licenses/osl-3.0.php *
11 ********************************************************************************
12 */
13
14 #ifndef INC_PASO_COMMON
15 #define INC_PASO_COMMON
16
17
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 #if ( defined __INTEL_COMPILER )
32 #include <mathimf.h>
33 #else
34 #include <math.h>
35 #endif
36
37 #include <float.h>
38 #include <stdio.h>
39 #include <limits.h>
40 #include <stdlib.h>
41 #include <string.h>
42
43 #define LenString_MAX FILENAME_MAX*2
44 #define LenErrorMsg_MAX LenString_MAX
45
46 /* on some arcitectures it could be a good idea to use long rather than int */
47 /* this has not really been tested */
48
49 typedef int dim_t;
50 typedef int index_t;
51 typedef int bool_t;
52 typedef int type_t;
53 typedef int err_t;
54
55 #define INDEX_T_MAX INT_MAX
56 #define EPSILON DBL_EPSILON
57
58 /**************************************************************/
59
60 /* some useful functions: */
61
62 #define FALSE 0
63 #define TRUE 1
64 #define UNKNOWN -1
65 #define DBLE(_x_) (double)(_x_)
66 #define INDEX1(_X1_) (_X1_)
67 #define INDEX2(_X1_,_X2_,_N1_) ((_X1_)+(_N1_)*(_X2_))
68 #define INDEX3(_X1_,_X2_,_X3_,_N1_,_N2_) ((_X1_)+(_N1_)*INDEX2(_X2_,_X3_,_N2_))
69 #define INDEX4(_X1_,_X2_,_X3_,_X4_,_N1_,_N2_,_N3_) ((_X1_)+(_N1_)*INDEX3(_X2_,_X3_,_X4_,_N2_,_N3_))
70 #define INDEX5(_X1_,_X2_,_X3_,_X4_,_X5_,_N1_,_N2_,_N3_,_N4_) ((_X1_)+(_N1_)*INDEX4(_X2_,_X3_,_X4_,_X5_,_N2_,_N3_,_N4_))
71 #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_))
72
73 #define MAX(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg1_) : (_arg2_))
74 #define MIN(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg2_) : (_arg1_))
75 #define ABS(_arg_) MAX((_arg_),-(_arg_))
76 /**************************************************************/
77
78 /* memory allocation: */
79
80 #define TMPMEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
81 #define TMPMEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
82 #ifdef __ECC
83 //#define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_)); if( !(_LENGTH_) ) printf( "Trying malloc(0) at %s %d\n", __FILE__, __LINE__ ); //else printf( "malloc(%d) at %s %d\n", _LENGTH_, __FILE__, __LINE__ );
84 #define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
85 #define MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
86 #ifdef _OPENMP
87 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) kmp_malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
88 #define THREAD_MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { kmp_free(_PTR_); (_PTR_) = NULL; }
89 #else
90 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) TMPMEMALLOC(_LENGTH_,_TYPE_)
91 #define THREAD_MEMFREE(_PTR_) TMPMEMFREE(_PTR_)
92 #endif
93 #define MEMREALLOC(_POINTER_,_LENGTH_,_TYPE_) if( (_POINTER_)!=NULL ){ _POINTER_ = (_TYPE_*)realloc((void*)(_POINTER_),((size_t)(_LENGTH_))*sizeof(_TYPE_) ); }else{ _POINTER_ = (_TYPE_*)malloc( ((size_t)(_LENGTH_))*sizeof(_TYPE_) ); }
94
95 #else
96 #define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
97 #define MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
98 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) TMPMEMALLOC(_LENGTH_,_TYPE_)
99 #define THREAD_MEMFREE(_PTR_) TMPMEMFREE(_PTR_)
100 #define MEMREALLOC(_POINTER_,_LENGTH_,_TYPE_) if( (_POINTER_)!=NULL ){ _POINTER_ = (_TYPE_*)realloc((void*)(_POINTER_),((size_t)(_LENGTH_))*sizeof(_TYPE_) ); }else{ _POINTER_ = (_TYPE_*)malloc( ((size_t)(_LENGTH_))*sizeof(_TYPE_) ); }
101 #endif
102
103 #endif /* #ifndef INC_PASO_COMMON */
104
105 /*
106 * $Log$
107 * Revision 1.2 2005/09/15 03:44:38 jgs
108 * Merge of development branch dev-02 back to main trunk on 2005-09-15
109 *
110 * Revision 1.1.2.1 2005/09/05 06:29:46 gross
111 * These files have been extracted from finley to define a stand alone libray for iterative
112 * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
113 * has not been tested yet.
114 *
115 *
116 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26