Skip to content

Commit

Permalink
Changed option name to assume_deviceptr
Browse files Browse the repository at this point in the history
  • Loading branch information
awnawab committed Sep 13, 2023
1 parent ebe4f25 commit b972d49
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions cmake/loki_transform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ endmacro()

function( loki_transform_convert )

set( options CPP DATA_OFFLOAD REMOVE_OPENMP DEVICEPTR GLOBAL_VAR_OFFLOAD TRIM_VECTOR_SECTIONS REMOVE_DERIVED_ARGS )
set( options CPP DATA_OFFLOAD REMOVE_OPENMP ASSUME_DEVICEPTR GLOBAL_VAR_OFFLOAD TRIM_VECTOR_SECTIONS REMOVE_DERIVED_ARGS )
set( oneValueArgs MODE DIRECTIVE FRONTEND CONFIG PATH OUTPATH )
set( multiValueArgs OUTPUT DEPENDS INCLUDES INCLUDE HEADERS HEADER DEFINITIONS DEFINE OMNI_INCLUDE XMOD )

Expand Down Expand Up @@ -236,8 +236,8 @@ function( loki_transform_convert )
list( APPEND _ARGS --remove-openmp )
endif()

if( ${_PAR_DEVICEPTR} )
list( APPEND _ARGS --deviceptr )
if( ${_PAR_ASSUME_DEVICEPTR} )
list( APPEND _ARGS --assume_deviceptr )
endif()

if( ${_PAR_GLOBAL_VAR_OFFLOAD} )
Expand Down
6 changes: 3 additions & 3 deletions scripts/loki_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def cli(debug):
help='Run transformation to insert custom data offload regions.')
@click.option('--remove-openmp', is_flag=True, default=False,
help='Removes existing OpenMP pragmas in "!$loki data" regions.')
@click.option('--deviceptr', is_flag=True, default=False,
@click.option('--assume_deviceptr', is_flag=True, default=False,
help='Mark the relevant arguments as true device-pointers in "!$loki data" regions.')
@click.option('--frontend', default='fp', type=click.Choice(['fp', 'ofp', 'omni']),
help='Frontend parser to use (default FP)')
Expand All @@ -104,7 +104,7 @@ def cli(debug):
help="Remove derived-type arguments and replace with canonical arguments")
def convert(
mode, config, build, source, header, cpp, directive, include, define, omni_include, xmod,
data_offload, remove_openmp, deviceptr, frontend, trim_vector_sections,
data_offload, remove_openmp, assume_deviceptr, frontend, trim_vector_sections,
global_var_offload, remove_derived_args
):
"""
Expand Down Expand Up @@ -167,7 +167,7 @@ def convert(
# Insert data offload regions for GPUs and remove OpenMP threading directives
use_claw_offload = True
if data_offload:
offload_transform = DataOffloadTransformation(remove_openmp=remove_openmp, deviceptr=deviceptr)
offload_transform = DataOffloadTransformation(remove_openmp=remove_openmp, assume_deviceptr=assume_deviceptr)
scheduler.process(transformation=offload_transform)
use_claw_offload = not offload_transform.has_data_regions

Expand Down
14 changes: 8 additions & 6 deletions transformations/transformations/data_offload.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class DataOffloadTransformation(Transformation):
----------
remove_openmp : bool
Remove any existing OpenMP pragmas inside the marked region.
deviceptr : bool
assume_deviceptr : bool
Mark all offloaded arrays as true device-pointers if data offload
is being managed outside of structured Openacc data regions.
is being managed outside of structured OpenACC data regions.
"""

def __init__(self, **kwargs):
Expand Down Expand Up @@ -139,10 +139,12 @@ def insert_data_offload_pragmas(self, routine, targets):

# Now geenerate the pre- and post pragmas (OpenACC)
if self.deviceptr:
deviceptr = ''
if inargs+outargs+inoutargs:
deviceptr = f'deviceptr({", ".join(inargs+outargs+inoutargs)})'
pragma = Pragma(keyword='acc', content=f'data {deviceptr}')
offload_args = inargs + outargs + inoutargs
if offload_args:
deviceptr = f' deviceptr({", ".join(offload_args)})'
else:
deviceptr = ''
pragma = Pragma(keyword='acc', content=f'data{deviceptr}')
else:
copyin = f'copyin({", ".join(inargs)})' if inargs else ''
copy = f'copy({", ".join(inoutargs)})' if inoutargs else ''
Expand Down

0 comments on commit b972d49

Please sign in to comment.