From 9b88aaad712ff138d2511746f4a5e8b92620c1ed Mon Sep 17 00:00:00 2001 From: Alessio Sclocco Date: Wed, 26 Jun 2024 14:10:59 +0200 Subject: [PATCH] Remove two warnings. --- kernel_tuner/utils/directives.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel_tuner/utils/directives.py b/kernel_tuner/utils/directives.py index 23863dee..7d9bb4e7 100644 --- a/kernel_tuner/utils/directives.py +++ b/kernel_tuner/utils/directives.py @@ -32,6 +32,9 @@ 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""" @@ -39,6 +42,9 @@ class Fortran(Language): 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""" @@ -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: @@ -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: