Remove NumPy specific code from llvm-py
This commit is contained in:
parent
45177bbeb0
commit
88d4f62e16
2 changed files with 2 additions and 56 deletions
53
llvm/_core.c
53
llvm/_core.c
|
|
@ -36,8 +36,6 @@
|
||||||
|
|
||||||
// Python include
|
// Python include
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "numpy/ndarrayobject.h"
|
|
||||||
#include "numpy/ufuncobject.h"
|
|
||||||
|
|
||||||
/* LLVM includes */
|
/* LLVM includes */
|
||||||
#include "llvm-c/Analysis.h"
|
#include "llvm-c/Analysis.h"
|
||||||
|
|
@ -1315,53 +1313,6 @@ _wPyCObjectVoidPtrToPyLong(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
#endif
|
#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[] = {
|
static PyMethodDef core_methods[] = {
|
||||||
|
|
||||||
/* Modules */
|
/* Modules */
|
||||||
|
|
@ -1845,7 +1796,6 @@ static PyMethodDef core_methods[] = {
|
||||||
_method( LLVMLoadLibraryPermanently )
|
_method( LLVMLoadLibraryPermanently )
|
||||||
//_method( LLVMInlineFunction )
|
//_method( LLVMInlineFunction )
|
||||||
_method( PyCObjectVoidPtrToPyLong )
|
_method( PyCObjectVoidPtrToPyLong )
|
||||||
{"make_ufunc", ufunc_from_ptr, METH_VARARGS},
|
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1871,9 +1821,6 @@ PyMODINIT_FUNC
|
||||||
init_core(void)
|
init_core(void)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
import_array();
|
|
||||||
import_umath();
|
|
||||||
|
|
||||||
LLVMLinkInJIT();
|
LLVMLinkInJIT();
|
||||||
LLVMLinkInInterpreter();
|
LLVMLinkInInterpreter();
|
||||||
LLVMInitializeNativeTarget();
|
LLVMInitializeNativeTarget();
|
||||||
|
|
|
||||||
5
setup.py
5
setup.py
|
|
@ -31,9 +31,8 @@
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
from distutils.core import setup, Extension
|
from distutils.core import setup, Extension
|
||||||
import numpy
|
|
||||||
|
|
||||||
LLVM_PY_VERSION = '0.7'
|
LLVM_PY_VERSION = '0.8'
|
||||||
|
|
||||||
|
|
||||||
def _run(cmd):
|
def _run(cmd):
|
||||||
|
|
@ -101,7 +100,7 @@ def call_setup(llvm_config):
|
||||||
('__STDC_CONSTANT_MACROS', None),
|
('__STDC_CONSTANT_MACROS', None),
|
||||||
('__STDC_LIMIT_MACROS', None),
|
('__STDC_LIMIT_MACROS', None),
|
||||||
('_GNU_SOURCE', None)],
|
('_GNU_SOURCE', None)],
|
||||||
include_dirs = ['/usr/include', incdir, numpy.get_include()],
|
include_dirs = ['/usr/include', incdir],
|
||||||
library_dirs = [libdir],
|
library_dirs = [libdir],
|
||||||
libraries = std_libs + libs_core,
|
libraries = std_libs + libs_core,
|
||||||
extra_objects = objs_core,
|
extra_objects = objs_core,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue