Skip to content

Commit

Permalink
Merge pull request #11 from naromero77/present_clause
Browse files Browse the repository at this point in the history
Present clause and lower case bug fix
  • Loading branch information
naromero77 authored Mar 13, 2020
2 parents cfeccb4 + 81b9d0c commit f7226a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

Notable changes to ACC2OMP are documented in this file

## [0.2.1] - 2020-1-23
## [0.2.2] - 2020-XX-YY

Minor enhancements:
- Support OpenACC present directive
- More robust handling of directives that translates into nothing

Bug fix:
- Arguements to directives were being forced into lowercase

## [0.2.1] - 2020-01-23

Minor enhancements:
- Original OpenACC directives can be maintained in output.
Expand Down
24 changes: 14 additions & 10 deletions acc2omp_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@
accDirContinue = '!$acc&'
nextLineContinue = '&'

emptyString = ''
singleSpaceString = ' '
transitionArrow = ' -> '
backupExtString = '.bak'

# directives without arguements
singleDirDict = {
'loop': 'parallel do',
'gang': '',
'gang': emptyString,
'parallel': 'target teams distribute',
'vector': 'simd',
'routine': 'declare target',
'seq': '',
'seq': emptyString,
'data': 'data',
'end': 'end',
'enter': 'target enter',
Expand All @@ -63,7 +64,8 @@
'collapse': 'collapse(',
'private': 'private(',
'vector_length': 'simd simdlen(',
'num_gangs': 'num_teams('
'num_gangs': 'num_teams(',
'present': emptyString,
}

dualDirwargsDict = {
Expand Down Expand Up @@ -226,11 +228,6 @@ def add_space_after_commas(origString):
dualDirwargsFound = False
dirwargsFound = False
for i, dir in enumDirs:
# Convert directive to lowercase for pattern matching purpose,
# later on the output line will be written out in the native
# capitalization of the source code (determined on a per line
# basis)
dir = dir.lower()
# first iteration just put the OMP directive or continuation
# version of it into a string and go to the next iteration
if i == 0:
Expand Down Expand Up @@ -269,10 +266,13 @@ def add_space_after_commas(origString):
# those. The maxsplit arguement to the split method in dirwards
# is needed to identify arrays properly. We split *only* on the
# first parenthesis from the left hand side.
#
# Note that currentDir and dualDir must be in lowercase for pattern
# matching purposes.
dirwargs = dir.split('(', 1)
lenDirwargs = len(dirwargs)
currentDir = dirwargs[0]
dualDir = prevdir + singleSpaceString + currentDir
currentDir = dirwargs[0].lower()
dualDir = prevdir.lower() + singleSpaceString + currentDir

if lenDirwargs > 1: dirwargsFound = True # Boolean unused for now
if debug:
Expand Down Expand Up @@ -319,6 +319,7 @@ def add_space_after_commas(origString):
if debug:
print 'OpenACC Directive Single with no argument found'
newDir = singleDirDict[currentDir]
if newDir == emptyString: continue
if accDirUpperCase: newDir = newDir.upper()
if debug: print currentDir + transitionArrow + newDir
newLine = newLine + singleSpaceString + newDir
Expand All @@ -328,6 +329,7 @@ def add_space_after_commas(origString):
totalDirsFound = totalDirsFound + 1
if debug: print 'OpenACC Directive Single with argument found'
newDir = singleDirwargsDict[currentDir]
if newDir == emptyString: continue
if accDirUpperCase: newDir = newDir.upper()
newLine = newLine + singleSpaceString + newDir
# for-loop handles the arguement component
Expand All @@ -342,6 +344,7 @@ def add_space_after_commas(origString):
if debug:
print 'OpenACC Directive Dual with no arguement found'
newDir = dualDirDict[dualDir]
if newDir == emptyString: continue
if accDirUpperCase: newDir = newDir.upper()
if debug:
print dualDir + transitionArrow + newDir
Expand All @@ -352,6 +355,7 @@ def add_space_after_commas(origString):
totalDirsFound = totalDirsFound + 2
if debug: print 'OpenACC Directive Dual with an argument'
newDir = dualDirwargsDict[dualDir]
if newDir == emptyString: continue
if accDirUpperCase: newDir = newDir.upper()
newLine = newLine + singleSpaceString + newDir
# for-loop handles the arguement component
Expand Down

0 comments on commit f7226a0

Please sign in to comment.