Skip to content

Commit

Permalink
Remove two warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
isazi committed Jun 26, 2024
1 parent ad2a6c2 commit 9b88aaa
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions kernel_tuner/utils/directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ class Cxx(Language):
def get(self) -> str:
return "cxx"

def end_string(self) -> str:
return "#pragma tuner stop"


class Fortran(Language):
"""Class to represent Fortran code"""

def get(self) -> str:
return "fortran"

def end_string(self) -> str:
return "!$tuner stop"


class Code(object):
"""Class to represent the directive and host code of the application"""
Expand Down Expand Up @@ -356,24 +362,20 @@ def extract_directive_code(code: str, langs: Code, kernel_name: str = None) -> d
"""Extract explicitly marked directive sections from code"""
if is_cxx(langs.language):
start_string = "#pragma tuner start"
end_string = "#pragma tuner stop"
elif is_fortran(langs.language):
start_string = "!$tuner start"
end_string = "!$tuner stop"

return extract_code(start_string, end_string, code, langs, kernel_name)
return extract_code(start_string, langs.language.end_string(), code, langs, kernel_name)


def extract_initialization_code(code: str, langs: Code) -> str:
"""Extract the initialization section from code"""
if is_cxx(langs.language):
start_string = "#pragma tuner initialize"
end_string = "#pragma tuner stop"
elif is_fortran(langs.language):
start_string = "!$tuner initialize"
end_string = "!$tuner stop"

init_code = extract_code(start_string, end_string, code, langs)
init_code = extract_code(start_string, langs.language.end_string(), code, langs)
if len(init_code) >= 1:
return "\n".join(init_code.values()) + "\n"
else:
Expand All @@ -384,12 +386,10 @@ def extract_deinitialization_code(code: str, langs: Code) -> str:
"""Extract the deinitialization section from code"""
if is_cxx(langs.language):
start_string = "#pragma tuner deinitialize"
end_string = "#pragma tuner stop"
elif is_fortran(langs.language):
start_string = "!$tuner deinitialize"
end_string = "!$tuner stop"

init_code = extract_code(start_string, end_string, code, langs)
init_code = extract_code(start_string, langs.language.end_string(), code, langs)
if len(init_code) >= 1:
return "\n".join(init_code.values()) + "\n"
else:
Expand Down

0 comments on commit 9b88aaa

Please sign in to comment.