diff --git a/llvm_cbuilder/builder.py b/llvm_cbuilder/builder.py index 15ef477..fc4baa3 100644 --- a/llvm_cbuilder/builder.py +++ b/llvm_cbuilder/builder.py @@ -12,6 +12,9 @@ from . import shortnames as types # Utilities ### +class FunctionAlreadyExists(NameError): + pass + def _is_int(ty): return isinstance(ty, lc.IntegerType) @@ -651,7 +654,7 @@ class _DeclareCDef(object): def __call__(self, module): try: func = self.cdef.define(module) - except NameError as e: + except FunctionAlreadyExists as e: (func,) = e return func @@ -740,7 +743,7 @@ class CDefinition(CBuilder): func = module.get_or_insert_function(functype, name=name) if not func.is_declaration: # already defined? - raise NameError(func) + raise FunctionAlreadyExists(func) # Name all arguments for i, (name, _) in enumerate(cls._argtys_): diff --git a/parallel_vectorize.py b/parallel_vectorize.py index f70954b..210dea8 100644 --- a/parallel_vectorize.py +++ b/parallel_vectorize.py @@ -410,6 +410,12 @@ else: def parallel_vectorize_from_func(lfunc, engine=None): + '''create ufunc from a llvm.core.Function + + If engine is given, return a function object which can be called + from python. (This needs Jay's numpy.fromfunc). + Otherwise, return the specialized ufunc as a llvm.core.Function + ''' fntype = lfunc.type.pointee def_spuf = SpecializedParallelUFunc(ParallelUFuncPlatform(num_thread=2), UFuncCoreGeneric(fntype),