Skip to content

Commit

Permalink
Addressed formatting comments
Browse files Browse the repository at this point in the history
  • Loading branch information
HannanNaeem committed Nov 7, 2023
1 parent 00c7482 commit 5d5e31e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions pykokkos/core/parsers/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def fix_decorator(self, entity : PyKokkosEntity, updated_decorator: UpdatedDecor
return entity_tree


def get_keyword_node(self, view_name: str, specifier_dict: Dict[str, str]) -> ast.keyword:
def get_keyword_node(self, view_name: str, specifiers: Dict[str, str]) -> ast.keyword:
'''
Make the ast.keyword node to be added to the decorator list
Expand All @@ -319,10 +319,10 @@ def get_keyword_node(self, view_name: str, specifier_dict: Dict[str, str]) -> as
:returns: corresponding ast.keyword node that can be added to decorator list
'''

skip_space: bool = False if specifier_dict['trait'] == "Unmanaged" else True
skip_space: bool = False if specifiers['trait'] == "Unmanaged" else True
keywords_list: List[ast.keyword] = []
attr_names = {'layout' : 'Layout', 'space' : 'MemorySpace', 'trait' : 'Trait'}
for specifier, value in specifier_dict.items():
for specifier, value in specifiers.items():
if specifier == "space" and skip_space:
continue
keywords_list.append(
Expand Down
4 changes: 2 additions & 2 deletions pykokkos/core/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pykokkos.interface import (
DataType, ExecutionPolicy, ExecutionSpace, MemorySpace,
RandomPool, RangePolicy, TeamPolicy, View, ViewType, UpdatedTypes, UpdatedDecorator,
is_host_execution_space, get_types_sig
is_host_execution_space, get_types_signature
)
import pykokkos.kokkos_manager as km

Expand Down Expand Up @@ -126,7 +126,7 @@ def run_workunit(
raise RuntimeError("ERROR: operation cannot be None for Debug")
return run_workunit_debug(policy, workunit, operation, initial_value, **kwargs)

types_signature: str = get_types_sig(updated_types, updated_decorator, execution_space)
types_signature: str = get_types_signature(updated_types, updated_decorator, execution_space)
members: Optional[PyKokkosMembers] = self.precompile_workunit(workunit, execution_space, updated_decorator, updated_types, types_signature)
if members is None:
raise RuntimeError("ERROR: members cannot be none")
Expand Down
2 changes: 1 addition & 1 deletion pykokkos/interface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
)

from .ext_module import compile_into_module
from .args_type_inference import UpdatedTypes, UpdatedDecorator, get_annotations, get_type_str, get_types_sig
from .args_type_inference import UpdatedTypes, UpdatedDecorator, get_annotations, get_type_str, get_types_signature

def fence():
pass
Expand Down
13 changes: 8 additions & 5 deletions pykokkos/interface/args_type_inference.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import inspect
from dataclasses import dataclass
from typing import Callable, Dict, Optional, Tuple, Union, List
import hashlib

import pykokkos.kokkos_manager as km
from .execution_policy import MDRangePolicy, TeamPolicy, TeamThreadRange, RangePolicy, ExecutionPolicy, ExecutionSpace
from .views import View, ViewType, Trait
from .data_types import DataType, DataTypeClass
from hashlib import md5


@dataclass
class HandledArgs:
Expand Down Expand Up @@ -183,7 +185,8 @@ def get_views_decorator(handled_args: HandledArgs, passed_kwargs) -> UpdatedDeco
if not isinstance(value, View):
continue

if kwarg not in updated_decorator.inferred_decorator: updated_decorator.inferred_decorator[kwarg] = {}
if kwarg not in updated_decorator.inferred_decorator:
updated_decorator.inferred_decorator[kwarg] = {}
updated_decorator.inferred_decorator[kwarg]['trait'] = str(value.trait).split(".")[1]
updated_decorator.inferred_decorator[kwarg]['layout'] = str(value.layout).split(".")[1]
updated_decorator.inferred_decorator[kwarg]['space'] = str(value.space).split(".")[1]
Expand Down Expand Up @@ -305,7 +308,7 @@ def infer_other_args(

def get_pk_datatype(view_dtype):
'''
Infer the dataype of view e.g pk.View1D[<dinfer this>]
Infer the dataype of view e.g pk.View1D[<infer this>]
:param view_dtype: view.dtype whose datatype is to be determined as string
:returns: the type of custom pkDataType as string
Expand All @@ -324,7 +327,7 @@ def get_pk_datatype(view_dtype):
return dtype


def get_types_sig(updated_types: UpdatedTypes, updated_decorator: UpdatedDecorator, execution_space: ExecutionSpace) -> str:
def get_types_signature(updated_types: UpdatedTypes, updated_decorator: UpdatedDecorator, execution_space: ExecutionSpace) -> str:
'''
Generates a signature/hash to represent the signature of the workunit: used for module setup
Expand All @@ -351,7 +354,7 @@ def get_types_sig(updated_types: UpdatedTypes, updated_decorator: UpdatedDecorat
return None

# Compacting
signature = md5(signature.encode()).hexdigest()
signature = hashlib.md5(signature.encode()).hexdigest()

return signature

Expand Down
4 changes: 1 addition & 3 deletions tests/test_typeinference.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,4 @@ def test_no_view(self):

if __name__ == "__main__":
unittest.main()
# test = TestTypeInference()
# test.setUp()
# test.test_layout_switchL()

0 comments on commit 5d5e31e

Please sign in to comment.