Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion pykokkos/interface/parallel_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def handle_args(is_for: bool, *args) -> HandledArgs:

name: Optional[str] = None
policy: Union[ExecutionPolicy, int]
workunit: Callable
workunit: Union[Callable, List[Callable]]
view: Optional[ViewType] = None
initial_value: Union[int, float] = 0

Expand Down Expand Up @@ -145,6 +145,27 @@ def handle_args(is_for: bool, *args) -> HandledArgs:
if isinstance(policy, (int, np.integer)):
policy = RangePolicy(ExecutionSpace.Default, 0, int(policy))

# check type instance for input args
if name is not None:
if not isinstance(name, str):
raise TypeError(
f"ERROR: name expected to be type 'str', got '{name}' of type '{type(name)}'"
)
if not (isinstance(policy, ExecutionPolicy) or isinstance(policy, int)):
raise TypeError(
f"ERROR: policy expected to be type 'ExecutionPolicy' or 'int', got '{policy}' of type '{type(policy)}'"
)
if not (
isinstance(workunit, Callable)
or (
isinstance(workunit, list)
and all(isinstance(w, Callable) for w in workunit)
)
):
raise TypeError(
f"ERROR: workunit expected to be type 'Callable' or 'List[Callable]', got '{workunit}' of type '{type(workunit)}'"
)

return HandledArgs(name, policy, workunit, view, initial_value)


Expand Down