diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 03c045268b1..0603d27a071 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,5 @@ # Copyright (c) 2023-2026 Arm Limited. +# SPDX-FileCopyrightText: 2026 Yusuf Efe # # SPDX-License-Identifier: MIT # @@ -96,7 +97,9 @@ repos: name: Commit Message Check language: python always_run: true - entry: bash -c "pip install -q commitizen && git log -1 --pretty=%s | cz check" + additional_dependencies: ['commitizen==4.18.0'] + entry: bash -c "git log -1 --pretty=%s | cz check" + pass_filenames: false stages: [pre-push] - id: check-signoff name: Check Signed-off-by @@ -104,6 +107,7 @@ repos: bash -c 'git log -1 --pretty=%B | grep -qiE "^Signed-off-by: .+ <.+@.+>$"' always_run: true + pass_filenames: false language: system stages: [pre-push] - repo: https://github.com/pre-commit/mirrors-clang-format diff --git a/scripts/check_bad_style.sh b/scripts/check_bad_style.sh index 4a36ba4f9f3..f4e4c4d1e58 100755 --- a/scripts/check_bad_style.sh +++ b/scripts/check_bad_style.sh @@ -1,6 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash # # SPDX-FileCopyrightText: 2017-2020, 2022, 2024-2025 Arm Limited +# SPDX-FileCopyrightText: 2026 Yusuf Efe # # SPDX-License-Identifier: MIT # @@ -35,7 +36,7 @@ else FILES=$@ fi -grep -HrnP --exclude-dir=assembly --exclude-dir=convolution --exclude_dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "/\*\*$" $FILES | tee bad_style.log +grep -HrnP --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "/\*\*$" $FILES | tee bad_style.log if (( `cat bad_style.log | wc -l` > 0 )) then echo "" @@ -43,7 +44,7 @@ then exit -1 fi -grep -Hnr --exclude-dir=assembly --exclude-dir=convolution --exclude_dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv --exclude=Doxyfile "@brief" $FILES | tee bad_style.log +grep -Hnr --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv --exclude=Doxyfile "@brief" $FILES | tee bad_style.log if (( `cat bad_style.log | wc -l` > 0 )) then echo "" @@ -51,7 +52,7 @@ then exit -1 fi -grep -HnRE --exclude-dir=assembly --exclude-dir=convolution --exclude_dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "\buint " --exclude-dir=cl_kernels --exclude-dir=cs_shaders $FILES | tee bad_style.log +grep -HnRE --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "\buint " --exclude-dir=cl_kernels --exclude-dir=cs_shaders $FILES | tee bad_style.log if [[ $(cat bad_style.log | wc -l) > 0 ]] then echo "" @@ -59,7 +60,7 @@ then exit -1 fi -grep -HnR --exclude-dir=assembly --exclude-dir=convolution --exclude_dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "/^float32_t/" $FILES | tee bad_style.log +grep -HnR --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "/^float32_t/" $FILES | tee bad_style.log if [[ $(cat bad_style.log | wc -l) > 0 ]] then echo "" @@ -67,7 +68,7 @@ then exit -1 fi -grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude_dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "arm[_ ]\?cv" $FILES | tee bad_style.log +grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "arm[_ ]\?cv" $FILES | tee bad_style.log if [[ $(cat bad_style.log | wc -l) > 0 ]] then echo "" @@ -75,7 +76,7 @@ then exit -1 fi -grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude_dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "#.*if.*defined[^(]" $FILES | tee bad_style.log +grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "#.*if.*defined[^(]" $FILES | tee bad_style.log if [[ $(cat bad_style.log | wc -l) > 0 ]] then echo "" @@ -83,7 +84,7 @@ then exit -1 fi -grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude_dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "#else$\|#endif$" $FILES | tee bad_style.log +grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "#else$\|#endif$" $FILES | tee bad_style.log if [[ $(cat bad_style.log | wc -l) > 0 ]] then echo "" @@ -91,7 +92,7 @@ then exit -1 fi -grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude_dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "ARM_COMPUTE_AARCH64_V8_2" ./tests/validation/CL | tee bad_style.log +grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=third_party --exclude-dir=arm_gemm --exclude-dir=arm_conv "ARM_COMPUTE_AARCH64_V8_2" ./tests/validation/CL | tee bad_style.log if [[ $(cat bad_style.log | wc -l) > 0 ]] then echo "" @@ -100,24 +101,21 @@ then fi spdx_missing=0 -for f in $(find $FILES -type f) +for f in $(find $FILES -type f -exec grep -L SPDX {} +) do - if [[ $(grep SPDX $f | wc -l) == 0 ]] - then - # List of exceptions: - case `basename $f` in - "arm_compute_version.embed");; - "filelist.json");; - ".clang-format");; - ".clang-tidy");; - "README.md");; - #It's an error for other files to not contain the MIT header: - *) - spdx_missing=1 - echo $f; - ;; - esac - fi; + # List of exceptions: + case `basename $f` in + "arm_compute_version.embed");; + "filelist.json");; + ".clang-format");; + ".clang-tidy");; + "README.md");; + #It's an error for other files to not contain the MIT header: + *) + spdx_missing=1 + echo $f; + ;; + esac done if [[ $spdx_missing > 0 ]] diff --git a/scripts/check_header_guards.py b/scripts/check_header_guards.py index 5c48b7501fb..e5c022fbf19 100644 --- a/scripts/check_header_guards.py +++ b/scripts/check_header_guards.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # # Copyright (c) 2023 Arm Limited. +# SPDX-FileCopyrightText: 2026 Yusuf Efe # # SPDX-License-Identifier: MIT # @@ -193,12 +194,12 @@ def skip_file(filepath: str, extensions: List[str], exclude: List[str], include: expected_header_guard : str = find_expected_header_guard(file, prefix, add_extension, drop_outermost_subdir) - with open(file, "r") as fd: + with open(file, "r", encoding="utf-8") as fd: lines: List = fd.readlines() new_lines, guards_updated = fix_header_guard(lines, expected_header_guard, comment_style) - with open(file, "w") as fd: + with open(file, "w", encoding="utf-8", newline='\n') as fd: fd.writelines([f"{line}" for line in new_lines]) if guards_updated: diff --git a/scripts/format_code.py b/scripts/format_code.py index cc7e233a6e4..5ccbc4454f4 100755 --- a/scripts/format_code.py +++ b/scripts/format_code.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # Copyright (c) 2023-2025 Arm Limited. +# SPDX-FileCopyrightText: 2026 Yusuf Efe # # SPDX-License-Identifier: MIT # @@ -248,13 +249,14 @@ def run(self): retval = 0 self.shell = Shell() self.shell.save_cwd() - this_dir = os.path.dirname(__file__) + this_dir = os.path.dirname(os.path.abspath(__file__)) logger.debug("Running Android.bp check") try: self.shell.cd(self.folder) - cmd = "%s/generate_android_bp.py --folder %s --output_file %s" % (this_dir, self.folder, self.bp_output_file) - output = self.shell.run_single_to_str(cmd) + cmd = [sys.executable, os.path.join(this_dir, "generate_android_bp.py"), + "--folder", self.folder, "--output_file", self.bp_output_file] + output = subprocess.check_output(cmd, env=self.shell.env, stderr=subprocess.STDOUT, text=True) if len(output) > 0: logger.info(output) except subprocess.CalledProcessError as e: @@ -266,8 +268,8 @@ def run(self): if not filecmp.cmp(self.bp_output_file, self.folder + "/Android.bp"): is_mismatched = True - with open(self.bp_output_file, 'r') as generated_file: - with open(self.folder + "/Android.bp", 'r') as review_file: + with open(self.bp_output_file, 'r', encoding='utf-8') as generated_file: + with open(self.folder + "/Android.bp", 'r', encoding='utf-8') as review_file: diff = list(difflib.unified_diff(generated_file.readlines(), review_file.readlines(), fromfile='Generated_Android.bp', tofile='Android.bp')) diff --git a/scripts/format_doxygen.py b/scripts/format_doxygen.py index b55603c3f78..27d8f8cf987 100755 --- a/scripts/format_doxygen.py +++ b/scripts/format_doxygen.py @@ -3,6 +3,7 @@ # SPDX-FileCopyrightText: 2017-2018, 2023-2025 Arm Limited # # SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2026 Yusuf Efe # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -123,7 +124,7 @@ def main(*args): n_file += 1 - with open(path,'r+', encoding="utf-8") as fd: + with open(path,'r+', encoding="utf-8", newline='\n') as fd: comment = list() first_param = -1 last_param = -1 diff --git a/scripts/generate_android_bp.py b/scripts/generate_android_bp.py index f9dbd892280..9f8db438607 100755 --- a/scripts/generate_android_bp.py +++ b/scripts/generate_android_bp.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # Copyright (c) 2023-2025 Arm Limited. +# SPDX-FileCopyrightText: 2026 Yusuf Efe # # SPDX-License-Identifier: MIT # @@ -171,6 +172,7 @@ def list_all_files(repo_path): :param repo_path: Path of the repository :return: The filtered list of useful filess """ + repo_path = repo_path.replace(os.sep, "/") if not repo_path.endswith('/'): repo_path = repo_path + "/" @@ -178,14 +180,15 @@ def list_all_files(repo_path): cpp_files = [] cl_files = [] for path, subdirs, files in os.walk(repo_path): + path = path.replace(os.sep, "/") for file in files: if file.endswith(".cpp"): - cpp_files.append(os.path.join(path, file)) + cpp_files.append(path + "/" + file) elif file.endswith(".cl"): - cl_files.append(os.path.join(path, file)) + cl_files.append(path + "/" + file) # Include CL headers if "src/core/CL/cl_kernels" in path and file.endswith(".h"): - cl_files.append(os.path.join(path, file)) + cl_files.append(path + "/" + file) # Filter out unused cpp files filtered_cpp_files = [] for cpp_file in cpp_files: @@ -212,5 +215,5 @@ def list_all_files(repo_path): cpp_files, opencl_files = list_all_files(args.folder) bp_file = generate_bp_file(cpp_files, opencl_files) - with open(args.output_file, 'w') as f: + with open(args.output_file, 'w', encoding='utf-8', newline='\n') as f: f.write(bp_file) diff --git a/scripts/generate_build_files.py b/scripts/generate_build_files.py index b5d18390494..f3d849a1d26 100644 --- a/scripts/generate_build_files.py +++ b/scripts/generate_build_files.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2023-2026 Arm Limited. +# SPDX-FileCopyrightText: 2026 Yusuf Efe # # SPDX-License-Identifier: MIT # @@ -276,6 +277,7 @@ def gather_sources(): # ------------------------------------- def strip_prefix(filename, prefix = "src/"): + filename = filename.replace("\\", "/") return filename[len(prefix):] if filename.startswith(prefix) else filename graph_files = sorted([strip_prefix(path, "src/") for path in graph_files]) @@ -302,13 +304,13 @@ def strip_prefix(filename, prefix = "src/"): bazel_build_string = build_from_template_bazel( graph_files, lib_files_sve, lib_files_sve2, lib_files + lib_files_neon_fp16) - with open("src/BUILD.bazel", "w") as fp: + with open("src/BUILD.bazel", "w", newline='\n') as fp: fp.write(bazel_build_string) if args.cmake: cmake_build_string = build_from_template_cmake( graph_files, lib_files_sve, lib_files_sve2, lib_files, lib_files_neon_fp16) - with open("src/CMakeLists.txt", "w") as fp: + with open("src/CMakeLists.txt", "w", newline='\n') as fp: fp.write(cmake_build_string) if not args.cmake and not args.bazel: diff --git a/scripts/include_functions_kernels.py b/scripts/include_functions_kernels.py index 3758d1b9b08..e5c3cfe1441 100644 --- a/scripts/include_functions_kernels.py +++ b/scripts/include_functions_kernels.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2017-2018, 2020-2021, 2023, 2025 Arm Limited. +# SPDX-FileCopyrightText: 2026 Yusuf Efe # # SPDX-License-Identifier: MIT # @@ -55,7 +56,7 @@ def read_file(file): def write_file(file, lines): - with open(file, "w") as f: + with open(file, "w", newline='\n') as f: for line in lines: f.write(line) @@ -73,7 +74,7 @@ def add_updated_includes(lines, pos, includes): def create_include_list(folder): files_path = folder + "/*.h" files = glob.glob(files_path) - updated_files = [include_str + folder + "/" + x.rsplit('/',1)[1] + "\"\n" for x in files] + updated_files = [include_str + folder + "/" + os.path.basename(x) + "\"\n" for x in files] updated_files.sort(key=lambda x: x.lower()) return updated_files diff --git a/scripts/tests/test_contributor_tools.py b/scripts/tests/test_contributor_tools.py new file mode 100644 index 00000000000..2adc164f15b --- /dev/null +++ b/scripts/tests/test_contributor_tools.py @@ -0,0 +1,186 @@ +# SPDX-FileCopyrightText: 2026 Yusuf Efe +# +# SPDX-License-Identifier: MIT + +"""Run with: python -m unittest discover -s scripts/tests -v.""" + +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import unittest + +SCRIPTS = Path(__file__).resolve().parents[1] +ROOT = SCRIPTS.parent +sys.path.insert(0, str(SCRIPTS)) + +import generate_android_bp +import format_doxygen +import include_functions_kernels + + +class ContributorToolsTest(unittest.TestCase): + def setUp(self): + self.temp_dir = tempfile.TemporaryDirectory(prefix="acl tools ") + self.addCleanup(self.temp_dir.cleanup) + self.directory = Path(self.temp_dir.name) + + def test_android_sources_use_relative_posix_paths_and_exclude_graph(self): + paths = [ + "src/core/Utils.cpp", + "src/graph/Graph.cpp", + "src/core/NEON/kernels/sve/kernel.cpp", + "examples/example.cpp", + "src/core/CL/cl_kernels/kernel.cl", + "src/core/CL/cl_kernels/helpers.h", + ] + for path in paths: + file = self.directory / path + file.parent.mkdir(parents=True, exist_ok=True) + file.write_text("") + sources, kernels = generate_android_bp.list_all_files(str(self.directory)) + self.assertEqual(sources, ["src/core/Utils.cpp"]) + self.assertEqual(set(kernels), {"src/core/CL/cl_kernels/kernel.cl", "src/core/CL/cl_kernels/helpers.h"}) + + def test_umbrella_header_uses_filename_without_duplicating_directory(self): + folder = self.directory / "kernels" + folder.mkdir() + (folder / "Alpha.h").write_text("") + (folder / "Beta.h").write_text("") + includes = include_functions_kernels.create_include_list(folder.as_posix()) + self.assertEqual( + includes, [f'#include "{folder.as_posix()}/Alpha.h"\n', f'#include "{folder.as_posix()}/Beta.h"\n'] + ) + + def test_umbrella_header_writes_lf_line_endings(self): + header = self.directory / "header.h" + include_functions_kernels.write_file(header, ["first\n", "second\n"]) + self.assertEqual(header.read_bytes(), b"first\nsecond\n") + + def test_doxygen_formatter_preserves_lf_line_endings(self): + source = self.directory / "source.cpp" + content = b"/* A comment */\nint value;\n" + source.write_bytes(content) + format_doxygen.main(str(source)) + self.assertEqual(source.read_bytes(), content) + + def test_header_guard_checker_preserves_utf8_and_lf(self): + header = self.directory / "header.h" + content = "// Unicode: π\n#ifndef ACL_HEADER_H\n#define ACL_HEADER_H\n#endif // ACL_HEADER_H\n".encode("utf-8") + header.write_bytes(content) + result = subprocess.run( + [ + sys.executable, + str(SCRIPTS / "check_header_guards.py"), + "header.h", + "--extensions=h", + "--comment_style=double_slash", + "--prefix=ACL", + "--add_extension", + ], + cwd=self.directory, + capture_output=True, + text=True, + timeout=30, + ) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertEqual(header.read_bytes(), content) + + def test_graph_build_sources_match_repository_paths(self): + result = subprocess.run( + [ + sys.executable, + "-c", + "import sys; sys.path.insert(0, 'scripts'); " + "import generate_build_files; " + "print('\\n'.join(generate_build_files.gather_sources()[0]))", + ], + cwd=ROOT, + capture_output=True, + text=True, + check=True, + ) + sources = result.stdout.splitlines() + self.assertTrue(sources) + self.assertTrue(all("\\" not in path and (ROOT / "src" / path).is_file() for path in sources)) + + def test_android_generator_emits_utf8_and_lf(self): + source = self.directory / "src/core/Utils.cpp" + source.parent.mkdir(parents=True) + source.write_text("") + output = self.directory / "Generated_Android.bp" + subprocess.run( + [ + sys.executable, + str(SCRIPTS / "generate_android_bp.py"), + "--folder", + str(self.directory), + "--output_file", + str(output), + ], + check=True, + capture_output=True, + text=True, + ) + data = output.read_bytes() + self.assertNotIn(b"\r\n", data) + self.assertIn("Copyright ©", data.decode("utf-8")) + + def test_android_check_accepts_repository_path_with_spaces(self): + source = self.directory / "src/core/Utils.cpp" + source.parent.mkdir(parents=True) + source.write_text("") + sources, kernels = generate_android_bp.list_all_files(str(self.directory)) + (self.directory / "Android.bp").write_bytes( + generate_android_bp.generate_bp_file(sources, kernels).encode("utf-8") + ) + result = subprocess.run( + [sys.executable, str(SCRIPTS / "format_code.py"), "--check_android_bp", "--folder", str(self.directory)], + capture_output=True, + text=True, + timeout=30, + ) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + + @unittest.skipUnless(shutil.which("bash"), "Bash is required for the style check") + def test_style_check_accepts_valid_file_and_rejects_invalid_type(self): + source = self.directory / "style.cpp" + (self.directory / "tests/validation/CL").mkdir(parents=True) + for declaration, expected_success in [("unsigned int value;", True), ("uint value;", False)]: + with self.subTest(declaration=declaration): + source.write_text("// SPDX-" + "License-Identifier: MIT\n" + declaration + "\n") + # The existing shell script expects its positional file list without spaces. + result = subprocess.run( + [shutil.which("bash"), str(SCRIPTS / "check_bad_style.sh"), source.name], + cwd=self.directory, + capture_output=True, + text=True, + timeout=30, + ) + self.assertEqual(result.returncode == 0, expected_success, result.stdout + result.stderr) + self.assertEqual(result.stderr, "") + if not expected_success: + self.assertIn("Use 'unsigned int' instead", result.stdout) + + @unittest.skipUnless(shutil.which("bash"), "Bash is required for the style check") + def test_style_check_rejects_missing_license_and_accepts_readme_exception(self): + (self.directory / "tests/validation/CL").mkdir(parents=True) + for name, expected_success in [("unlicensed.cpp", False), ("README.md", True)]: + with self.subTest(name=name): + (self.directory / name).write_text("A file without license metadata.\n") + result = subprocess.run( + [shutil.which("bash"), str(SCRIPTS / "check_bad_style.sh"), name], + cwd=self.directory, + capture_output=True, + text=True, + timeout=30, + ) + self.assertEqual(result.returncode == 0, expected_success, result.stdout + result.stderr) + self.assertEqual(result.stderr, "") + if not expected_success: + self.assertIn("MIT Copyright header missing", result.stdout) + + +if __name__ == "__main__": + unittest.main() diff --git a/src/common/utils/profile/acl_profile.cpp b/src/common/utils/profile/acl_profile.cpp index 9767dc08588..507b2294966 100644 --- a/src/common/utils/profile/acl_profile.cpp +++ b/src/common/utils/profile/acl_profile.cpp @@ -39,8 +39,8 @@ PerfettoProfiler::PerfettoProfiler() , opencl_clock(nullptr), opencl_tracing_enabled(false) -#else -#endif +#else // ARM_COMPUTE_CL +#endif // ARM_COMPUTE_CL { perfetto::TracingInitArgs args; args.backends = perfetto::ACL_PROFILE_MODE; @@ -79,7 +79,7 @@ void PerfettoProfiler::openclTraceBegin() { std::cerr << "Failed to create OpenCLClock instance." << std::endl; } -#endif +#endif // ARM_COMPUTE_CL opencl_clock->test_start(); opencl_clock->start(); opencl_tracing_enabled = true; @@ -104,7 +104,7 @@ void PerfettoProfiler::openclTraceEnd() { std::cout << instrument.first << ": " << instrument.second << std::endl; } -#endif +#endif // (ACL_PROFILE_LEVEL > 1) // The difference between the instrument map and this map is that. // MeasurementsMap elements does have an awareness of the timestamps in other GPU stages. @@ -178,7 +178,7 @@ void PerfettoProfiler::openclTraceEnd() std::cout << "Start: " << instrument.second[2] << " ns" << std::endl; std::cout << "End: " << instrument.second[3] << " ns" << std::endl; std::cout << std::endl; -#endif +#endif // (ACL_PROFILE_LEVEL > 1) ARM_COMPUTE_TRACE_CUSTOM_EVENT(ARM_COMPUTE_PROF_CAT_GPU, ARM_COMPUTE_PROF_LVL_GPU, instrument.second[0], instrument.second[1] - instrument.second[0], "GPU::Queue", @@ -193,7 +193,7 @@ void PerfettoProfiler::openclTraceEnd() opencl_clock.reset(); opencl_tracing_enabled = false; } -#endif +#endif // ARM_COMPUTE_CL uint64_t PerfettoProfiler::getTsNs() const { return perfetto::TrackEvent::GetTraceTimeNs() - trace_start_ns; @@ -209,4 +209,4 @@ PerfettoProfiler &get_profiler() } // namespace profile } // namespace arm_compute -#endif +#endif // defined(ACL_PROFILE_ENABLE) && (ACL_PROFILE_BACKEND == PERFETTO) diff --git a/src/common/utils/profile/acl_profile.h b/src/common/utils/profile/acl_profile.h index 407829c258f..78c1389a665 100644 --- a/src/common/utils/profile/acl_profile.h +++ b/src/common/utils/profile/acl_profile.h @@ -46,7 +46,7 @@ #ifdef ARM_COMPUTE_CL #include "tests/framework/instruments/OpenCLTimer.h" using namespace arm_compute::test::framework; -#endif +#endif // ARM_COMPUTE_CL PERFETTO_DEFINE_CATEGORIES( perfetto::Category(ARM_COMPUTE_PROF_CAT_NONE).SetTags("verbose").SetDescription("No Category"), @@ -74,7 +74,7 @@ class PerfettoProfiler final #ifdef ARM_COMPUTE_CL void openclTraceBegin(); void openclTraceEnd(); -#endif +#endif // ARM_COMPUTE_CL private: std::unique_ptr tracing_session; @@ -82,7 +82,7 @@ class PerfettoProfiler final #ifdef ARM_COMPUTE_CL std::unique_ptr> opencl_clock; bool opencl_tracing_enabled; -#endif +#endif // ARM_COMPUTE_CL }; // 👇 Singleton accessor declaration @@ -116,17 +116,17 @@ class ScopedPerfettoTrace final #ifdef ARM_COMPUTE_CL #define ARM_COMPUTE_TRACE_OPENCL_BEGIN() arm_compute::profile::get_profiler().openclTraceBegin() #define ARM_COMPUTE_TRACE_OPENCL_SYNC() arm_compute::profile::get_profiler().openclTraceEnd() -#else +#else // ARM_COMPUTE_CL #define ARM_COMPUTE_TRACE_OPENCL_BEGIN() (void)0 #define ARM_COMPUTE_TRACE_OPENCL_SYNC() (void)0 -#endif +#endif // ARM_COMPUTE_CL // This is useful to postprocess and recreate spans that did not happen on real time. // Typical use of this is to redraw GPU spans in the CPU timeline view. // Once we collect the GPU timestamps, we can use them to create spans in the CPU timeline. #if ACL_PROFILE_LEVEL >= 1 #define USE_CUSTOM_TIMESTAMP -#endif +#endif // ACL_PROFILE_LEVEL >= 1 #define ARM_COMPUTE_TRACE_CUSTOM_EVENT(category, level, timestamp_ns, duration_ns, name, arg) \ do \ @@ -174,7 +174,7 @@ class ScopedPerfettoTrace final uint64_t __ts_##__COUNTER__ = arm_compute::profile::get_profiler().getTsNs(); \ TRACE_EVENT_BEGIN(ARM_COMPUTE_PROF_CAT_NONE, name, __ts_##__COUNTER__); \ arm_compute::profile::ScopedPerfettoTrace __trace_scope_##__COUNTER__(__ts_##__COUNTER__); -#endif +#endif // ACL_PROFILE_LEVEL >= 0 #define ARM_COMPUTE_TRACE_EVENT_BEGIN(category, level, name) \ do \ { \ @@ -202,11 +202,11 @@ class ScopedPerfettoTrace final if ((int)(level) <= ACL_PROFILE_LEVEL) \ TRACE_COUNTER(category, name, (uint64_t)arm_compute::profile::get_profiler().getTsNs(), value); \ } while (0) -#else +#else // USE_CUSTOM_TIMESTAMP #if ACL_PROFILE_LEVEL >= 0 #define _ARM_COMPUTE_TRACE_EVENT_L0(category, name) TRACE_EVENT(category, name) -#endif +#endif // ACL_PROFILE_LEVEL >= 0 #define ARM_COMPUTE_TRACE_EVENT_BEGIN(category, level, name) \ do \ @@ -235,21 +235,21 @@ class ScopedPerfettoTrace final if ((int)(level) <= ACL_PROFILE_LEVEL) \ TRACE_COUNTER(category, name, value); \ } while (0) -#endif +#endif // USE_CUSTOM_TIMESTAMP #if ACL_PROFILE_LEVEL >= 1 #define _ARM_COMPUTE_TRACE_EVENT_L1(category, name) _ARM_COMPUTE_TRACE_EVENT_L0(category, name) -#else +#else // ACL_PROFILE_LEVEL >= 1 #define _ARM_COMPUTE_TRACE_EVENT_L1(category, name) -#endif +#endif // ACL_PROFILE_LEVEL >= 1 #if ACL_PROFILE_LEVEL >= 2 #define _ARM_COMPUTE_TRACE_EVENT_L2(category, name) _ARM_COMPUTE_TRACE_EVENT_L1(category, name) -#else +#else // ACL_PROFILE_LEVEL >= 2 #define _ARM_COMPUTE_TRACE_EVENT_L2(category, name) -#endif +#endif // ACL_PROFILE_LEVEL >= 2 -#else +#else // defined(ACL_PROFILE_ENABLE) && (ACL_PROFILE_BACKEND == PERFETTO) // Stub PROFILE macros to do nothing #define ARM_COMPUTE_TRACE_OPENCL_BEGIN() (void)0 #define ARM_COMPUTE_TRACE_OPENCL_SYNC() (void)0 diff --git a/src/core/CL/cl_kernels/common/gemm_reshaped_only_rhs_mmul.cl b/src/core/CL/cl_kernels/common/gemm_reshaped_only_rhs_mmul.cl index c762f0b0a1d..1f6733b8b74 100644 --- a/src/core/CL/cl_kernels/common/gemm_reshaped_only_rhs_mmul.cl +++ b/src/core/CL/cl_kernels/common/gemm_reshaped_only_rhs_mmul.cl @@ -354,11 +354,11 @@ __kernel void gemm_mm_reshaped_only_rhs_nt_mmul_fp16( { #if(N0 != 2 && N0 != 4 && N0 != 8 && N0 != 16) #error "N0 can only be 2,4,8,16" -#endif +#endif // (N0 != 2 && N0 != 4 && N0 != 8 && N0 != 16) #if(K0 != 1) #error "K0 can only be 1" -#endif +#endif // (K0 != 1) #define MMUL_BLOCK_SIZE (MMUL_N0 * MMUL_M0) @@ -426,19 +426,19 @@ __kernel void gemm_mm_reshaped_only_rhs_nt_mmul_fp16( { #if N0 == 2 c[m0].v = arm_matrix_multiply_af0(a[m0].v, b[0].v, c[m0].v); -#endif +#endif // N0 == 2 #if N0 == 4 c[m0].v.s01 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s01, c[m0].v.s01); c[m0].v.s23 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s23, c[m0].v.s23); -#endif +#endif // N0 == 4 #if N0 == 8 c[m0].v.s01 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s01, c[m0].v.s01); c[m0].v.s23 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s23, c[m0].v.s23); c[m0].v.s45 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s45, c[m0].v.s45); c[m0].v.s67 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s67, c[m0].v.s67); -#endif +#endif // N0 == 8 #if N0 == 16 c[m0].v.s01 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s01, c[m0].v.s01); @@ -449,7 +449,7 @@ __kernel void gemm_mm_reshaped_only_rhs_nt_mmul_fp16( c[m0].v.sab = arm_matrix_multiply_af0(a[m0].v, b[0].v.sab, c[m0].v.sab); c[m0].v.scd = arm_matrix_multiply_af0(a[m0].v, b[0].v.scd, c[m0].v.scd); c[m0].v.sef = arm_matrix_multiply_af0(a[m0].v, b[0].v.sef, c[m0].v.sef); -#endif +#endif // N0 == 16 }) lhs_offset_first_element_in_bytes += MMUL_K0 * sizeof(DATA_TYPE); @@ -914,11 +914,11 @@ __kernel void gemm_mm_reshaped_only_rhs_nt_mmul_texture_fp16( { #if(N0 != 2 && N0 != 4 && N0 != 8 && N0 != 16) #error "N0 can only be 2,4,8,16" -#endif +#endif // (N0 != 2 && N0 != 4 && N0 != 8 && N0 != 16) #if(K0 != 1) #error "K0 can only be 1" -#endif +#endif // (K0 != 1) #define MMUL_BLOCK_SIZE (MMUL_N0 * MMUL_M0) @@ -985,19 +985,19 @@ __kernel void gemm_mm_reshaped_only_rhs_nt_mmul_texture_fp16( { #if N0 == 2 c[m0].v = arm_matrix_multiply_af0(a[m0].v, b[0].v, c[m0].v); -#endif +#endif // N0 == 2 #if N0 == 4 c[m0].v.s01 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s01, c[m0].v.s01); c[m0].v.s23 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s23, c[m0].v.s23); -#endif +#endif // N0 == 4 #if N0 == 8 c[m0].v.s01 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s01, c[m0].v.s01); c[m0].v.s23 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s23, c[m0].v.s23); c[m0].v.s45 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s45, c[m0].v.s45); c[m0].v.s67 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s67, c[m0].v.s67); -#endif +#endif // N0 == 8 #if N0 == 16 c[m0].v.s01 = arm_matrix_multiply_af0(a[m0].v, b[0].v.s01, c[m0].v.s01); @@ -1008,7 +1008,7 @@ __kernel void gemm_mm_reshaped_only_rhs_nt_mmul_texture_fp16( c[m0].v.sab = arm_matrix_multiply_af0(a[m0].v, b[0].v.sab, c[m0].v.sab); c[m0].v.scd = arm_matrix_multiply_af0(a[m0].v, b[0].v.scd, c[m0].v.scd); c[m0].v.sef = arm_matrix_multiply_af0(a[m0].v, b[0].v.sef, c[m0].v.sef); -#endif +#endif // N0 == 16 }) lhs_offset_first_element_in_bytes += MMUL_K0 * sizeof(DATA_TYPE); diff --git a/src/cpu/kernels/topkv/generic/neon/fp16.cpp b/src/cpu/kernels/topkv/generic/neon/fp16.cpp index 215256e0b83..33b249e7b8f 100644 --- a/src/cpu/kernels/topkv/generic/neon/fp16.cpp +++ b/src/cpu/kernels/topkv/generic/neon/fp16.cpp @@ -38,11 +38,11 @@ static inline uint32_t reduce_u16x8(uint16x8_t v) { #if defined(__aarch64__) return vaddvq_u16(v); -#else +#else // __aarch64__ uint16x4_t s = vadd_u16(vget_low_u16(v), vget_high_u16(v)); s = vpadd_u16(s, s); return vget_lane_u16(s, 0); -#endif +#endif // __aarch64__ } template <> diff --git a/src/cpu/kernels/topkv/generic/neon/fp32.cpp b/src/cpu/kernels/topkv/generic/neon/fp32.cpp index 22d19538a3d..86f5613ed7b 100644 --- a/src/cpu/kernels/topkv/generic/neon/fp32.cpp +++ b/src/cpu/kernels/topkv/generic/neon/fp32.cpp @@ -38,11 +38,11 @@ static inline uint32_t reduce_u32x4(uint32x4_t v) { #if defined(__aarch64__) return vaddvq_u32(v); -#else +#else // __aarch64__ uint32x2_t s = vadd_u32(vget_low_u32(v), vget_high_u32(v)); s = vpadd_u32(s, s); return vget_lane_u32(s, 0); -#endif +#endif // __aarch64__ } // Explicit specialization for float: may use float32x4_t diff --git a/src/cpu/kernels/topkv/generic/neon/integer.cpp b/src/cpu/kernels/topkv/generic/neon/integer.cpp index 5820486e6eb..d599e9d53fc 100644 --- a/src/cpu/kernels/topkv/generic/neon/integer.cpp +++ b/src/cpu/kernels/topkv/generic/neon/integer.cpp @@ -35,11 +35,11 @@ static inline uint32_t reduce_u32x4(uint32x4_t v) { #if defined(__aarch64__) return vaddvq_u32(v); -#else +#else // __aarch64__ uint32x2_t s = vadd_u32(vget_low_u32(v), vget_high_u32(v)); s = vpadd_u32(s, s); return vget_lane_u32(s, 0); -#endif +#endif // __aarch64__ } template <> diff --git a/src/cpu/kernels/topkv/generic/neon/qasymm8.cpp b/src/cpu/kernels/topkv/generic/neon/qasymm8.cpp index 430c5bec3fa..53d6c5c8c4f 100644 --- a/src/cpu/kernels/topkv/generic/neon/qasymm8.cpp +++ b/src/cpu/kernels/topkv/generic/neon/qasymm8.cpp @@ -38,13 +38,13 @@ static inline uint32_t reduce_u8_to_count(uint8x16_t m) // mask is 0xFF where true, 0 otherwise -> shift to 0/1 then sum const uint8x16_t ones = vshrq_n_u8(m, 7); return vaddvq_u8(ones); -#else +#else // __aarch64__ const uint8x16_t ones = vshrq_n_u8(m, 7); uint16x8_t s16 = vpaddlq_u8(ones); uint32x4_t s32 = vpaddlq_u16(s16); uint64x2_t s64 = vpaddlq_u32(s32); return static_cast(vgetq_lane_u64(s64, 0) + vgetq_lane_u64(s64, 1)); -#endif +#endif // __aarch64__ } template <> diff --git a/src/cpu/kernels/topkv/generic/neon/qasymm8_signed.cpp b/src/cpu/kernels/topkv/generic/neon/qasymm8_signed.cpp index 1943889e3fc..cd05e14ceb2 100644 --- a/src/cpu/kernels/topkv/generic/neon/qasymm8_signed.cpp +++ b/src/cpu/kernels/topkv/generic/neon/qasymm8_signed.cpp @@ -36,13 +36,13 @@ static inline uint32_t reduce_u8_to_count(uint8x16_t m) #if defined(__aarch64__) const uint8x16_t ones = vshrq_n_u8(m, 7); return vaddvq_u8(ones); -#else +#else // __aarch64__ const uint8x16_t ones = vshrq_n_u8(m, 7); uint16x8_t s16 = vpaddlq_u8(ones); uint32x4_t s32 = vpaddlq_u16(s16); uint64x2_t s64 = vpaddlq_u32(s32); return static_cast(vgetq_lane_u64(s64, 0) + vgetq_lane_u64(s64, 1)); -#endif +#endif // __aarch64__ } template <> diff --git a/support/Half.h b/support/Half.h index ff860371bc1..ef1cb4b1754 100644 --- a/support/Half.h +++ b/support/Half.h @@ -39,7 +39,7 @@ #pragma GCC system_header #elif defined(__clang__) #pragma clang system_header -#endif +#endif // defined(__GNUC__) && !defined(__clang__) // CAUTION: All code below will be treated as system header code and will NOT be // subject to warnings. Consider carefully if your code belongs here or above // the system_header pragma. diff --git a/tests/validation/NEON/ActivationLayer.cpp b/tests/validation/NEON/ActivationLayer.cpp index ac1ee1d49ce..118c1cf2697 100644 --- a/tests/validation/NEON/ActivationLayer.cpp +++ b/tests/validation/NEON/ActivationLayer.cpp @@ -328,7 +328,7 @@ const auto QuantizedActivationFunctionsDataset = make("ActivationFunction", ActivationLayerInfo::ActivationFunction::LEAKY_RELU, #ifdef __aarch64__ ActivationLayerInfo::ActivationFunction::GELU, -#endif +#endif // __aarch64__ }); const auto QuantizedActivationDataset = diff --git a/tests/validation/fixtures/CpuGemmAssemblyDispatchFixture.h b/tests/validation/fixtures/CpuGemmAssemblyDispatchFixture.h index bc5430f1ac7..a3c843682b1 100644 --- a/tests/validation/fixtures/CpuGemmAssemblyDispatchFixture.h +++ b/tests/validation/fixtures/CpuGemmAssemblyDispatchFixture.h @@ -44,7 +44,7 @@ #ifndef BARE_METAL #include -#endif +#endif // BARE_METAL namespace arm_compute {