You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the concerns @gliga brought up in gh-124 code review was the lack of concision in the ufunc dispatching to workunits with regard to data types and view dimensionality--we are currently quite verbose in checking first the string name of the data type of a view and then its shape/dimensionality, before manually calling out to a workunit for that particular dimensionality and type + functionality.
One possible solution I "pitched" to Nader and Neil at the PyKokkos meeting this morning was the usage of the Python standard library inspect module to obtain a list of function names for workunits/kernels, that we could then dispatch to using some templating/string logic.
In fact, we already use a strategy similar to this to call/pre-compile most of our ufunc workunits in pre_compile_tools/pre_compile_ufuncs.py, to avoid hypothesis timeout failures related to our slow compile times when running the array API standard conformance suite.
So, very roughly/crudely, we might do something like:
frominspectimportgetmembers, isfunctionfrompykokkos.libimportufuncskernel_dict=dict(getmembers(ufuncs, isfunction))
# should be a dictionary with structure similar to:# {function_name (string): function_object (actual workunit object)}# workunit sketch/pseudocodedefround(view):
out=pk.View(...)
ndims=view.ndimsdtype=view.dtypeop="round"# workunits are currently named like: round_impl_1d_doublefunction_name_str=f"{op}_impl_{ndims}d_{dtype}"desired_workunit=kernel_dict[function_name_str]
# call the kerneldesired_workunit(tid, view, out)
Of course, this is just a pseudocode prototype, and may require some careful thought/refactoring--for example, we may want to rename workunit functions or adjust call signatures a bit for templating/dispatching convenience, and probably also separate the workunits to a separate module so we get easy access to the dictionary of function_name:function_object on import, etc.
The text was updated successfully, but these errors were encountered:
One of the concerns @gliga brought up in gh-124 code review was the lack of concision in the ufunc dispatching to workunits with regard to data types and view dimensionality--we are currently quite verbose in checking first the string name of the data type of a view and then its shape/dimensionality, before manually calling out to a workunit for that particular dimensionality and type + functionality.
One possible solution I "pitched" to Nader and Neil at the PyKokkos meeting this morning was the usage of the Python standard library
inspect
module to obtain a list of function names for workunits/kernels, that we could then dispatch to using some templating/string logic.In fact, we already use a strategy similar to this to call/pre-compile most of our ufunc workunits in
pre_compile_tools/pre_compile_ufuncs.py
, to avoidhypothesis
timeout failures related to our slow compile times when running the array API standard conformance suite.So, very roughly/crudely, we might do something like:
Of course, this is just a pseudocode prototype, and may require some careful thought/refactoring--for example, we may want to rename workunit functions or adjust call signatures a bit for templating/dispatching convenience, and probably also separate the workunits to a separate module so we get easy access to the dictionary of function_name:function_object on import, etc.
The text was updated successfully, but these errors were encountered: