Skip to content

Commit

Permalink
clean and linter error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wertysas committed Nov 15, 2024
1 parent ff5ddee commit b7f0512
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
23 changes: 11 additions & 12 deletions loki/transformations/data_offload.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def insert_data_offload_pragmas(self, routine, targets):
continue

for param, arg in call.arg_iter():
if isinstance(param, Array) and param.type.intent.lower() == 'in': inargs += (str(arg.name).lower(),)
if isinstance(param, Array) and param.type.intent.lower() == 'in':
inargs += (str(arg.name).lower(),)
if isinstance(param, Array) and param.type.intent.lower() == 'inout':
inoutargs += (str(arg.name).lower(),)
if isinstance(param, Array) and param.type.intent.lower() == 'out':
Expand Down Expand Up @@ -963,7 +964,9 @@ def out_pairs(self):

def __init__(self, **kwargs):
self.deviceptr_prefix = kwargs.get('devptr_prefix', 'loki_devptr_')
field_group_types = kwargs.get('field_group_types', ['CLOUDSC_STATE_TYPE', 'CLOUDSC_AUX_TYPE', 'CLOUDSC_FLUX_TYPE'])
field_group_types = kwargs.get('field_group_types', ['CLOUDSC_STATE_TYPE',
'CLOUDSC_AUX_TYPE',
'CLOUDSC_FLUX_TYPE'])
self.field_group_types = tuple(typename.lower() for typename in field_group_types)
self.offload_index = kwargs.get('offload_index', 'IBL')

Expand Down Expand Up @@ -1008,11 +1011,11 @@ def find_offload_variables(self, driver, calls):
try:
parent = arg.parent
if parent.type.dtype.name.lower() not in self.field_group_types:
warning(f'[Loki] The parent object {parent.name} of type {parent.type.dtype} is not in the list of' +
' field wrapper types')
warning(f'[Loki] The parent object {parent.name} of type ' +
f'{parent.type.dtype} is not in the list of field wrapper types')
except AttributeError:
warning(f'[Loki] Field data offload: Raw array object {arg.name} encountered in' +
f'{driver.name} that is not wrapped by a Field API object') # ofc we cant know this for sure
warning(f'[Loki] Field data offload: Raw array object {arg.name} encountered in'
+ f'{driver.name} that is not wrapped by a Field API object')
continue

if param.type.intent.lower() == 'in':
Expand Down Expand Up @@ -1045,12 +1048,9 @@ def _devptr_from_array(self, driver, a: sym.Array):
devptr_type = a.type.clone(pointer=True, contiguous=True, shape=shape, intent=None)
base_name = a.name if a.parent is None else '_'.join(a.name.split('%'))
devptr_name = self.deviceptr_prefix + base_name
try:
driver.variable_map[devptr_name]
if devptr_name in driver.variable_map:
warning(f'[Loki] Field data offload: The routine {driver.name} already has a' +
f'variable named {devptr_name}')
except KeyError:
pass
devptr = sym.Variable(name=devptr_name, type=devptr_type, dimensions=shape)
return devptr

Expand All @@ -1068,7 +1068,7 @@ def _add_field_offload_calls(self, driver, region, offload_map):

def _is_field_group_update(self, driver, call):
try:
*_, parent, call_name = call.name.name.split('%')
*_, parent, _call_name = call.name.name.split('%')
parent = driver.variable_map.get(parent)
if parent is not None and parent.type.dtype.name.lower() in self.field_group_types:
return True
Expand All @@ -1090,4 +1090,3 @@ def _replace_kernel_args(self, driver, kernel_calls, offload_map):
arg_transformer = SubstituteExpressions(change_map, inplace=True)
for call in kernel_calls:
arg_transformer.visit(call)

12 changes: 7 additions & 5 deletions loki/transformations/parallel/field_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def remove_field_api_view_updates(routine, field_group_types, dim_object=None):
"""
Remove FIELD API boilerplate calls for view updates of derived types.
This utility is intended to remove the IFS-specific group type objects that provide block-scope view pointers to deep kernel trees. It will remove all calls to ``UPDATE_VIEW`` on derive-type
This utility is intended to remove the IFS-specific group type
objects that provide block-scope view pointers to deep kernel
trees. It will remove all calls to ``UPDATE_VIEW`` on derive-type
objects with the respective types.
Parameters
Expand Down Expand Up @@ -201,10 +203,12 @@ def field_get_device_data(field_ptr, dev_ptr, transfer_type: FieldAPITransferTyp
raise TypeError(f"transfer_type must be of type FieldAPITransferType, but is of type {type(transfer_type)}")
if transfer_type == FieldAPITransferType.READ_ONLY:
suffix = 'RDONLY'
if transfer_type == FieldAPITransferType.READ_WRITE:
elif transfer_type == FieldAPITransferType.READ_WRITE:
suffix = 'RDWR'
if transfer_type == FieldAPITransferType.WRITE_ONLY:
elif transfer_type == FieldAPITransferType.WRITE_ONLY:
suffix = 'WRONLY'
else:
suffix = ''
procedure_name = 'GET_DEVICE_DATA_' + suffix
return ir.CallStatement(name=sym.ProcedureSymbol(procedure_name, parent=field_ptr, scope=scope),
arguments=(dev_ptr.clone(dimensions=None),), )
Expand All @@ -213,5 +217,3 @@ def field_get_device_data(field_ptr, dev_ptr, transfer_type: FieldAPITransferTyp
def field_sync_host(field_ptr, scope):
procedure_name = 'SYNC_HOST_RDWR'
return ir.CallStatement(name=sym.ProcedureSymbol(procedure_name, parent=field_ptr, scope=scope), arguments=())


0 comments on commit b7f0512

Please sign in to comment.