Changeset 1855 for inundation
- Timestamp:
- Sep 28, 2005, 6:00:46 PM (19 years ago)
- Location:
- inundation/pypar/mandelbrot_example
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pypar/mandelbrot_example/compile.py
r1852 r1855 111 111 include = os.path.join(os.path.join(sys.exec_prefix, 'include'), 112 112 'python'+sys.version[:3]) 113 headerfile = os.path.join(include, 'Python.h')114 113 114 115 # Check existence of Python.h 116 # 117 headerfile = include + '/Python.h' 115 118 try: 116 # unix style include directory117 119 open(headerfile, 'r') 118 120 except: 119 # windows style include directory 120 include = os.path.join(sys.exec_prefix, 'include') 121 headerfile = os.path.join(include, 'Python.h') 122 try: 123 open(headerfile, 'r') 124 except: 125 raise """Did not find Python header file. 126 Make sure files for Python C-extensions are installed.""" 121 raise """Did not find Python header file %s. 122 Make sure files for Python C-extensions are installed. 123 In debian linux, for example, you need to install a 124 package called something like python2.1-dev""" %headerfile 125 127 126 128 127 # Check filename(s) … … 147 146 # Compile 148 147 # 148 s = "%s -c %s -I%s -o %s.o" %(compiler, FN, include, root) 149 if os.name == 'posix' and os.uname()[4] == 'x86_64': 150 #Extra flags for 64 bit architectures 151 #s += ' -fPIC -m64' #gcc 152 s += ' -fPIC -tp amd64' #pgcc 153 149 154 150 s = "%s -c %s -I%s -o %s.o -Wall -O" %(compiler, FN, include, root)151 155 if verbose: 152 156 print s … … 161 165 162 166 # Make shared library (*.so) 167 s = "%s -%s %s -o %s.so" %(loader, sharedflag, object_files, root1) 168 169 if os.name == 'posix' and os.uname()[4] == 'x86_64': 170 #Extra flags for 64 bit architectures using Portland compilers 171 s += ' -mcmodel=medium' 163 172 164 s = "%s -%s %s -o %s.so -lm" %(loader, sharedflag, object_files, root1)165 173 if verbose: 166 174 print s -
inundation/pypar/mandelbrot_example/mandel_ext.c
r1852 r1855 1 / /Python - C extension for fast computation of the Mandelbrot iteration1 /* Python - C extension for fast computation of the Mandelbrot iteration 2 2 // 3 3 // To compile: … … 12 12 // k = calculate_point(c, kmax) 13 13 // 14 // Ole Nielsen, SUT 2003 14 // Ole Nielsen, SUT 2003 */ 15 15 16 16 #include "Python.h" 17 17 18 / / Computational function18 /* Computational function */ 19 19 int _calculate_point(Py_complex c, int kmax) { 20 20 int count; … … 37 37 38 38 39 / / Interface to Python39 /* Interface to Python */ 40 40 PyObject *calculate_point(PyObject *self, PyObject *args) { 41 PyComplexObject *C; / / Python Complex object42 Py_complex c; / / C Complex structure41 PyComplexObject *C; /* Python Complex object */ 42 Py_complex c; /* C Complex structure */ 43 43 int kmax, count; 44 44 45 / / Convert Python arguments to C45 /* Convert Python arguments to C */ 46 46 if (!PyArg_ParseTuple(args, "Oi", &C, &kmax)) 47 47 return NULL; 48 48 c = PyComplex_AsCComplex((PyObject*) C); 49 49 50 / / Call underlying routine50 /* Call underlying routine */ 51 51 count = _calculate_point(c, kmax); 52 52 53 / / Return results as a Python object53 /* Return results as a Python object */ 54 54 return Py_BuildValue("i", count); 55 55 } 56 56 57 57 58 / / Method table for python module58 /* Method table for python module */ 59 59 static struct PyMethodDef MethodTable[] = { 60 60 {"calculate_point", calculate_point, METH_VARARGS}, … … 63 63 64 64 65 / / Module initialisation65 /* Module initialisation */ 66 66 void initmandel_ext(void){ 67 67 Py_InitModule("mandel_ext", MethodTable);
Note: See TracChangeset
for help on using the changeset viewer.