Add doc for parallel_vectorize_from_func.
Add FunctionAlreadyExists exception.
This commit is contained in:
parent
c6d5538ead
commit
9ccc6782c7
2 changed files with 11 additions and 2 deletions
|
|
@ -12,6 +12,9 @@ from . import shortnames as types
|
||||||
# Utilities
|
# Utilities
|
||||||
###
|
###
|
||||||
|
|
||||||
|
class FunctionAlreadyExists(NameError):
|
||||||
|
pass
|
||||||
|
|
||||||
def _is_int(ty):
|
def _is_int(ty):
|
||||||
return isinstance(ty, lc.IntegerType)
|
return isinstance(ty, lc.IntegerType)
|
||||||
|
|
||||||
|
|
@ -651,7 +654,7 @@ class _DeclareCDef(object):
|
||||||
def __call__(self, module):
|
def __call__(self, module):
|
||||||
try:
|
try:
|
||||||
func = self.cdef.define(module)
|
func = self.cdef.define(module)
|
||||||
except NameError as e:
|
except FunctionAlreadyExists as e:
|
||||||
(func,) = e
|
(func,) = e
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
|
@ -740,7 +743,7 @@ class CDefinition(CBuilder):
|
||||||
func = module.get_or_insert_function(functype, name=name)
|
func = module.get_or_insert_function(functype, name=name)
|
||||||
|
|
||||||
if not func.is_declaration: # already defined?
|
if not func.is_declaration: # already defined?
|
||||||
raise NameError(func)
|
raise FunctionAlreadyExists(func)
|
||||||
|
|
||||||
# Name all arguments
|
# Name all arguments
|
||||||
for i, (name, _) in enumerate(cls._argtys_):
|
for i, (name, _) in enumerate(cls._argtys_):
|
||||||
|
|
|
||||||
|
|
@ -410,6 +410,12 @@ else:
|
||||||
|
|
||||||
|
|
||||||
def parallel_vectorize_from_func(lfunc, engine=None):
|
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
|
fntype = lfunc.type.pointee
|
||||||
def_spuf = SpecializedParallelUFunc(ParallelUFuncPlatform(num_thread=2),
|
def_spuf = SpecializedParallelUFunc(ParallelUFuncPlatform(num_thread=2),
|
||||||
UFuncCoreGeneric(fntype),
|
UFuncCoreGeneric(fntype),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue