Add doc for parallel_vectorize_from_func.

Add FunctionAlreadyExists exception.
This commit is contained in:
Siu Kwan Lam 2012-08-08 17:46:20 -07:00
commit 9ccc6782c7
2 changed files with 11 additions and 2 deletions

View file

@ -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_):

View file

@ -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),