Remove NumPy specific code from llvm-py

This commit is contained in:
Travis E. Oliphant 2012-03-08 05:56:37 -06:00
commit 88d4f62e16
2 changed files with 2 additions and 56 deletions

View file

@ -36,8 +36,6 @@
// Python include
#include "Python.h"
#include "numpy/ndarrayobject.h"
#include "numpy/ufuncobject.h"
/* LLVM includes */
#include "llvm-c/Analysis.h"
@ -1315,53 +1313,6 @@ _wPyCObjectVoidPtrToPyLong(PyObject *self, PyObject *args)
#endif
#define UNARY_LOOP\
char *ip1 = args[0], *op1 = args[1];\
npy_intp is1 = steps[0], os1 = steps[1];\
npy_intp n = dimensions[0];\
npy_intp i;\
for(i = 0; i < n; i++, ip1 += is1, op1 += os1)
typedef npy_cdouble cunaryfunc(npy_cdouble);
NPY_NO_EXPORT void
MyUFunc_D_D(char **args, npy_intp *dimensions, npy_intp *steps, void *func)
{
cunaryfunc *f = (cunaryfunc *)func;
UNARY_LOOP {
npy_cdouble in1 = *(npy_cdouble *)ip1;
npy_cdouble *out = (npy_cdouble *)op1;
*out = f(in1);
}
}
PyUFuncGenericFunction funcs[1] = {MyUFunc_D_D};
static char types[2] = {NPY_DOUBLE, NPY_DOUBLE};
static PyObject *
ufunc_from_ptr(PyObject *self, PyObject *args)
{
Py_ssize_t func_ptr;
char *func_name = "temp";
void **data;
PyObject *ret;
double(*func)(double);
/* FIXME: This will not be freed */
data = (void **)malloc(sizeof(void **));
if (!PyArg_ParseTuple(args, "n|s", &func_ptr, &func_name)) return NULL;
data[0] = (void *)func_ptr;
func = data[0];
printf("%f" , func(4.3));
ret = PyUFunc_FromFuncAndData(funcs, data, types, 1, 1, 1, PyUFunc_None, func_name, "doc", 0);
return ret;
}
static PyMethodDef core_methods[] = {
/* Modules */
@ -1845,7 +1796,6 @@ static PyMethodDef core_methods[] = {
_method( LLVMLoadLibraryPermanently )
//_method( LLVMInlineFunction )
_method( PyCObjectVoidPtrToPyLong )
{"make_ufunc", ufunc_from_ptr, METH_VARARGS},
{ NULL }
};
@ -1871,9 +1821,6 @@ PyMODINIT_FUNC
init_core(void)
#endif
{
import_array();
import_umath();
LLVMLinkInJIT();
LLVMLinkInInterpreter();
LLVMInitializeNativeTarget();

View file

@ -31,9 +31,8 @@
import sys, os
from distutils.core import setup, Extension
import numpy
LLVM_PY_VERSION = '0.7'
LLVM_PY_VERSION = '0.8'
def _run(cmd):
@ -101,7 +100,7 @@ def call_setup(llvm_config):
('__STDC_CONSTANT_MACROS', None),
('__STDC_LIMIT_MACROS', None),
('_GNU_SOURCE', None)],
include_dirs = ['/usr/include', incdir, numpy.get_include()],
include_dirs = ['/usr/include', incdir],
library_dirs = [libdir],
libraries = std_libs + libs_core,
extra_objects = objs_core,