diff options
author | bjacob <jacob.benoit.1@gmail.com> | 2021-01-20 07:35:11 +0300 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2021-01-20 07:35:42 +0300 |
commit | 45a876f72309a444cf01f9cd0e844ac06c520987 (patch) | |
tree | eba9d87d464186485108eee5b64acce5698ad56e | |
parent | 25df4d3c9028e6c52d4f791771dd4a1d1f0a2f90 (diff) |
Revert "Revert "Add CMake support with a converter from Bazel""
Reverts google/ruy#243
Closes https://github.com/google/ruy/pull/244
PiperOrigin-RevId: 352711630
-rw-r--r-- | CMakeLists.txt | 42 | ||||
-rwxr-xr-x | cmake/bazel_to_cmake.py | 279 | ||||
-rwxr-xr-x | cmake/bazel_to_cmake.sh | 35 | ||||
-rwxr-xr-x | cmake/run_android_test.sh | 16 | ||||
-rw-r--r-- | cmake/ruy_add_all_subdirs.cmake | 37 | ||||
-rw-r--r-- | cmake/ruy_cc_binary.cmake | 57 | ||||
-rw-r--r-- | cmake/ruy_cc_library.cmake | 85 | ||||
-rw-r--r-- | cmake/ruy_cc_test.cmake | 76 | ||||
-rw-r--r-- | cmake/ruy_include_directories.cmake | 33 | ||||
-rw-r--r-- | example/CMakeLists.txt | 23 | ||||
-rw-r--r-- | ruy/CMakeLists.txt | 1696 | ||||
-rw-r--r-- | ruy/profiler/CMakeLists.txt | 72 | ||||
-rw-r--r-- | third_party/CMakeLists.txt | 5 |
13 files changed, 2456 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6577dd8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,42 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_policy(SET CMP0012 NEW) +cmake_policy(SET CMP0048 NEW) +project(ruy CXX) +cmake_minimum_required(VERSION 3.13) # Copied from IREE +set(CMAKE_CXX_STANDARD 14) + +option(RUY_ENABLE_TESTS "Enable ruy's tests" ON) +if (RUY_ENABLE_TESTS) + enable_testing() +endif() + +option(RUY_PROFILER "Enable ruy's built-in profiler (harms performance)" OFF) + +include(cmake/ruy_add_all_subdirs.cmake) +include(cmake/ruy_cc_library.cmake) +include(cmake/ruy_cc_binary.cmake) +include(cmake/ruy_cc_test.cmake) + +# Disabling cpuinfo's tests and benchmarks to prevent a copy of its +# googletest dependency getting downloaded into a 'deps' directory in the +# source tree! +set(CPUINFO_BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE) +set(CPUINFO_BUILD_UNIT_TESTS OFF CACHE BOOL "" FORCE) +set(CPUINFO_BUILD_MOCK_TESTS OFF CACHE BOOL "" FORCE) +add_subdirectory("third_party/cpuinfo" EXCLUDE_FROM_ALL) +add_subdirectory("third_party/googletest" EXCLUDE_FROM_ALL) + +ruy_add_all_subdirs() diff --git a/cmake/bazel_to_cmake.py b/cmake/bazel_to_cmake.py new file mode 100755 index 0000000..ba1a38b --- /dev/null +++ b/cmake/bazel_to_cmake.py @@ -0,0 +1,279 @@ +#!/usr/bin/env python3 +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""This is yet another bazel-to-cmake converter. It's independently written from +scratch but relies on the same basic idea as others (including IREE's), namely: +to let the python interpreter do the bulk of the work, exploiting the fact that +both Bazel's BUILD syntax and Starlark (".bzl") languages are more or less +subsets of Python. + +The main features that this converter supports and that others don't, justifying +its existence as of early 2021, are: + 1. Ad-hoc support for select(), generating CMake if()...elseif()... chains + parsing the condition keys (e.g. anything ending in ":windows" is + interpreted as the condition "the target platform is Windows"). This allows + to just ignore config_setting, as we only care about the config_setting + names, not their actual implementation, as well as all the variants from + the Bazel 'selects' library. + 2. Support for load(), loading macros from Starlark files. +""" + +import re +import os +import os.path +import pickle +import sys +import datetime +import itertools + +# Ruy's dependencies. +external_targets = ['gtest', 'gtest_main', 'cpuinfo'] + +# Text replacements [oldstring, newstring] pairs, applied on all BUILD and +# Starlark files that we load. Only used by preprocess_input_text. +replacements = [ + ['$(STACK_FRAME_UNLIMITED)', ''], + ['native.cc_', 'cc_'], + ['selects.config_setting_group', 'config_setting_group'], + ['@com_google_googletest//:gtest', 'gtest'], + ['@com_google_googletest//:gtest_main', 'gtest_main'], + ['@cpuinfo//:cpuinfo_with_unstripped_include_path', 'cpuinfo'], +] + + +def preprocess_input_text(text): + result = text + for replacement in replacements: + result = result.replace(replacement[0], replacement[1]) + return result + + +def set_cmake_list(list_name, values, indent): + semicolon_separated = ";".join(values) + print(f'{indent}set({list_name} "{semicolon_separated}")') + + +def generate_cmake_select(select_name, dict): + new_if_branch_keyword = 'if' + default_value = [] + for key in dict: + condition = '' + if key == '//conditions:default': + default_value = dict[key] + continue + elif re.search(r':windows$', key): + condition = 'CMAKE_SYSTEM_NAME STREQUAL Windows' + elif re.search(r':ppc$', key): + condition = 'CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le' + elif re.search(r':s390x$', key): + condition = 'CMAKE_SYSTEM_PROCESSOR STREQUAL s390 OR CMAKE_SYSTEM_PROCESSOR STREQUAL s390x' + elif re.search(r':fuchsia$', key): + condition = 'CMAKE_SYSTEM_NAME STREQUAL Fuchsia' + elif re.search(r':arm32_assuming_neon$', key): + condition = 'CMAKE_SYSTEM_PROCESSOR STREQUAL arm' + elif re.search(r':do_not_want_O3$', key): + # Ruy is a specialist library: we always want code to be compiled + # with -O3 unless the build type is Debug or the compiler does not + # support that flag syntax. + condition = '(CMAKE_BUILD_TYPE STREQUAL Debug) OR MSVC' + elif re.search(r':x86_64_and_not_msvc$', key): + condition = '(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64) AND NOT MSVC' + elif re.search(r':windows_msvc$', key): + condition = 'MSVC' + elif re.search(r':ruy_profiler$', key): + condition = '${RUY_PROFILER}' + else: + raise ValueError(f'Unhandled key in select: {key}') + + print(f'{new_if_branch_keyword}({condition})') + set_cmake_list(select_name, dict[key], ' ') + new_if_branch_keyword = 'elseif' + + print('else()') + set_cmake_list(select_name, default_value, ' ') + + print('endif()\n') + + +def trim_multiple_ruy_prefixes(name): + return re.sub(r'(ruy_)+ruy', 'ruy', name) + +def get_cmake_local_target_name(name): + global package_prefix + return trim_multiple_ruy_prefixes(f'ruy_{package_prefix}_{name}') + + +def get_cmake_dep_target_name(name): + if name in external_targets: + return name + if name.startswith('$'): + # Happens for deps that are the result of expanding a select() that we + # have compiled to expanding a variable. + return name + if name.startswith('//'): + after_last_slash = name.split('/')[-1] + if not ':' in after_last_slash: + name = f'{name}:{after_last_slash}' + raw=name[2:].replace('/', '_').replace(':', '_') + return trim_multiple_ruy_prefixes(raw) + if name.startswith(':'): + name = name[1:] + return get_cmake_local_target_name(name) + + +# +# Functions implementing BUILD functions +# + + +def package(**kwargs): + pass + + +def exports_files(*args): + pass + + +def load(filename, *args): + if filename.startswith('@'): + return + elif filename.startswith(':'): + filename = os.path.join(bazel_package_dir, filename[1:]) + elif filename.startswith('//'): + split = filename[2:].split(':') + filename = os.path.join(bazel_workspace_dir, split[0], split[1]) + + src_file_content = open(filename).read() + processed_file_content = preprocess_input_text(src_file_content) + exec(processed_file_content, globals(), globals()) + + +def config_setting(**kwargs): + # Nothing to do since our implementation of select() is based on parsing + # the names of config_settings, not looking deep into their actual + # implementation. + pass + + +def filegroup(**kwargs): + pass + + +def config_setting_group(**kwargs): + # See config_setting. + pass + + +def bzl_library(**kwargs): + pass + + +select_index = 0 +select_cache = {} + + +def select(select_dict): + global select_index + global select_cache + global package_prefix + key = pickle.dumps(sorted(select_dict.items())) + if key in select_cache: + select_name = select_cache[key] + else: + unique_values = sorted(set(itertools.chain.from_iterable(select_dict.values()))) # sorting ensures determinism, no spurious diffs + description = '_'.join(unique_values) + select_name = f'{package_prefix}_{select_index}_{description}' + select_name = select_name.replace('c++', 'cxx') + select_name = re.sub(r'[^a-zA-Z0-9]+', '_', select_name) + select_index = select_index + 1 + select_cache[key] = select_name + generate_cmake_select(select_name, select_dict) + + return [f'${{{select_name}}}'] + + +def generic_rule(rule_name, **kwargs): + print(f'{rule_name}(') + for key in kwargs.keys(): + values = kwargs[key] + if type(values) is bool: + if values: + print(f' {key.upper()}') + continue + else: + raise ValueError( + 'Cannot specify FALSE boolean args in CMake') + if key == 'visibility': + if values == ['//visibility:public']: + print(f' PUBLIC') + continue + if key == 'tags': + values = list(filter(lambda x : not x.startswith('req_dep'), values)) + if not values: + continue + print(f' {key.upper()}') + if type(values) is list: + for value in values: + if key == 'deps': + target_name = get_cmake_dep_target_name(value) + print(f' {target_name}') + else: + print(f' {value}') + else: + if key == 'name': + target_name = get_cmake_local_target_name(values) + print(f' {target_name}') + else: + print(f' {values}') + print(')\n') + + +def cc_library(**kwargs): + generic_rule('ruy_cc_library', **kwargs) + + +def cc_test(**kwargs): + generic_rule('ruy_cc_test', **kwargs) + + +def cc_binary(**kwargs): + generic_rule('ruy_cc_binary', **kwargs) + + +# +# Program entry point. +# +if __name__ == "__main__": + if len(sys.argv) != 3: + print("Usage: bazel_to_cmake.py bazel_workspace_dir bazel_package_dir") + sys.exit(1) + + bazel_workspace_dir = sys.argv[1] + bazel_package_dir = sys.argv[2] + bazel_package_relative_dir = os.path.relpath( + bazel_package_dir, bazel_workspace_dir) + package_prefix = bazel_package_relative_dir.replace(os.path.sep, '_') + + print("""# This file is generated (whence no license header). Do not edit! +# To regenerate, run: +# cmake/bazel_to_cmake.sh +""") + + src_build_file = os.path.join(bazel_package_dir, "BUILD") + src_build_content = open(src_build_file).read() + processed_build_content = preprocess_input_text(src_build_content) + exec(processed_build_content) + + print("ruy_add_all_subdirs()") diff --git a/cmake/bazel_to_cmake.sh b/cmake/bazel_to_cmake.sh new file mode 100755 index 0000000..296219e --- /dev/null +++ b/cmake/bazel_to_cmake.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +this_script_dir="$(dirname "$0")" + +root_dir="$(git -C "${this_script_dir}" rev-parse --show-toplevel)" + +build_files="$(find "${root_dir}" -type f -name BUILD)" + +if ! command -v python3 &> /dev/null; then + python_command=python +else + python_command=python3 +fi + +for build_file in ${build_files}; do + package_dir="$(dirname "${build_file}")" + if [[ "${package_dir}" == "${root_dir}" ]]; then + # The root CMakeLists.txt is not generated. + continue + fi + "${python_command}" "${this_script_dir}/bazel_to_cmake.py" "${root_dir}" "${package_dir}" > "${package_dir}/CMakeLists.txt" +done diff --git a/cmake/run_android_test.sh b/cmake/run_android_test.sh new file mode 100755 index 0000000..d643232 --- /dev/null +++ b/cmake/run_android_test.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Minimal script pushing and running a file on device! +# Contemporary versions of ADB properly propagate exit codes so nothing more +# is needed to let CTest report test success/failure. + +# TODO: consider clearing temporary files after testing, although that will +# get in the way of debugging and will make code more complex... also, +# Ruy's test files aren't huge and people running these probably have +# bigger clutter issues in their /data/local/tmp anyway. Anyway, if we want +# to do this, we could copy IREE's code. + +device_tmpdir=/data/local/tmp + +adb push "$1" "${device_tmpdir}" +adb shell "${device_tmpdir}/$(basename "$1")" diff --git a/cmake/ruy_add_all_subdirs.cmake b/cmake/ruy_add_all_subdirs.cmake new file mode 100644 index 0000000..1a7d126 --- /dev/null +++ b/cmake/ruy_add_all_subdirs.cmake @@ -0,0 +1,37 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Forked from IREE's iree_add_all_subdirs.cmake. + +# add_all_subidrs +# +# CMake function to add all subdirectories of the current directory that contain +# a CMakeLists.txt file +# +# Takes no arguments. +function(ruy_add_all_subdirs) + FILE(GLOB _CHILDREN RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) + SET(_DIRLIST "") + foreach(_CHILD ${_CHILDREN}) + if((NOT(subdir MATCHES third_party)) AND + (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_CHILD}) AND + (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_CHILD}/CMakeLists.txt)) + LIST(APPEND _DIRLIST ${_CHILD}) + endif() + endforeach() + + foreach(subdir ${_DIRLIST}) + add_subdirectory(${subdir}) + endforeach() +endfunction() diff --git a/cmake/ruy_cc_binary.cmake b/cmake/ruy_cc_binary.cmake new file mode 100644 index 0000000..21dbb9d --- /dev/null +++ b/cmake/ruy_cc_binary.cmake @@ -0,0 +1,57 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Forked from IREE's iree_cc_binary.cmake. + +include(CMakeParseArguments) +include(cmake/ruy_include_directories.cmake) + +# ruy_cc_binary() +# +# CMake function to imitate Bazel's cc_binary rule. +function(ruy_cc_binary) + cmake_parse_arguments( + _RULE + "TESTONLY" + "NAME" + "SRCS;COPTS;LINKOPTS;DEPS;TAGS" + ${ARGN} + ) + + if(_RULE_TESTONLY AND NOT RUY_ENABLE_TESTS) + return() + endif() + + set(_NAME "${_RULE_NAME}") + + add_executable(${_NAME} "") + target_sources(${_NAME} + PRIVATE + ${_RULE_SRCS} + ) + set_target_properties(${_NAME} PROPERTIES OUTPUT_NAME "${_RULE_NAME}") + ruy_include_directories(${_NAME} "${_RULE_DEPS}") + target_compile_options(${_NAME} + PRIVATE + ${_RULE_COPTS} + ) + target_link_options(${_NAME} + PRIVATE + ${_RULE_LINKOPTS} + ) + target_link_libraries(${_NAME} + PUBLIC + ${_RULE_DEPS} + ) +endfunction() diff --git a/cmake/ruy_cc_library.cmake b/cmake/ruy_cc_library.cmake new file mode 100644 index 0000000..2fa413f --- /dev/null +++ b/cmake/ruy_cc_library.cmake @@ -0,0 +1,85 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Forked from IREE's iree_cc_library.cmake. + +include(CMakeParseArguments) +include(cmake/ruy_include_directories.cmake) + +# ruy_cc_library() +# +# CMake function to imitate Bazel's cc_library rule. +function(ruy_cc_library) + cmake_parse_arguments( + _RULE + "PUBLIC;TESTONLY" + "NAME" + "HDRS;SRCS;COPTS;DEFINES;LINKOPTS;DEPS" + ${ARGN} + ) + + if(_RULE_TESTONLY AND NOT RUY_ENABLE_TESTS) + return() + endif() + + set(_NAME "${_RULE_NAME}") + + # Check if this is a header-only library. + if("${_RULE_SRCS}" STREQUAL "") + set(_RULE_IS_INTERFACE 1) + else() + set(_RULE_IS_INTERFACE 0) + endif() + + if(_RULE_IS_INTERFACE) + # Generating a header-only library. + add_library(${_NAME} INTERFACE) + target_include_directories(${_NAME} + INTERFACE + "${PROJECT_SOURCE_DIR}" + ) + target_link_libraries(${_NAME} + INTERFACE + ${_RULE_DEPS} + ${_RULE_LINKOPTS} + ) + target_compile_definitions(${_NAME} + INTERFACE + ${_RULE_DEFINES} + ) + else() + # Generating a static binary library. + add_library(${_NAME} STATIC "") + target_sources(${_NAME} + PRIVATE + ${_RULE_SRCS} + ${_RULE_HDRS} + ) + ruy_include_directories(${_NAME} "${_RULE_DEPS}") + target_compile_options(${_NAME} + PRIVATE + ${_RULE_COPTS} + ) + target_link_libraries(${_NAME} + PUBLIC + ${_RULE_DEPS} + PRIVATE + ${_RULE_LINKOPTS} + ) + target_compile_definitions(${_NAME} + PUBLIC + ${_RULE_DEFINES} + ) + endif() +endfunction() diff --git a/cmake/ruy_cc_test.cmake b/cmake/ruy_cc_test.cmake new file mode 100644 index 0000000..2d78697 --- /dev/null +++ b/cmake/ruy_cc_test.cmake @@ -0,0 +1,76 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Forked from IREE's iree_cc_test.cmake. + +include(CMakeParseArguments) +include(cmake/ruy_include_directories.cmake) + +# ruy_cc_test() +# +# CMake function to imitate Bazel's cc_test rule. +function(ruy_cc_test) + cmake_parse_arguments( + _RULE + "" + "NAME" + "SRCS;COPTS;LINKOPTS;DEPS;TAGS" + ${ARGN} + ) + + if(NOT RUY_ENABLE_TESTS) + return() + endif() + + set(_NAME "${_RULE_NAME}") + + add_executable(${_NAME} "") + target_sources(${_NAME} + PRIVATE + ${_RULE_SRCS} + ) + set_target_properties(${_NAME} PROPERTIES OUTPUT_NAME "${_RULE_NAME}") + ruy_include_directories(${_NAME} "${_RULE_DEPS}") + target_compile_options(${_NAME} + PRIVATE + ${_RULE_COPTS} + ) + target_link_options(${_NAME} + PRIVATE + ${_RULE_LINKOPTS} + ) + target_link_libraries(${_NAME} + PUBLIC + ${_RULE_DEPS} + ) + if(ANDROID) + add_test( + NAME + ${_NAME} + COMMAND + "${CMAKE_SOURCE_DIR}/cmake/run_android_test.sh" + "$<TARGET_FILE:${_NAME}>" + ) + else() + add_test( + NAME + ${_NAME} + COMMAND + "$<TARGET_FILE:${_NAME}>" + ) + endif() + if (_RULE_TAGS) + set_property(TEST ${_NAME} PROPERTY LABELS ${_RULE_TAGS}) + endif() +endfunction() diff --git a/cmake/ruy_include_directories.cmake b/cmake/ruy_include_directories.cmake new file mode 100644 index 0000000..d2e0ad1 --- /dev/null +++ b/cmake/ruy_include_directories.cmake @@ -0,0 +1,33 @@ +# Copyright 2019-2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +function(ruy_include_directories NAME DEPS) + target_include_directories(${NAME} + PUBLIC + "${PROJECT_SOURCE_DIR}" + ) + if (cpuinfo IN_LIST DEPS) + target_include_directories(${NAME} + PRIVATE + "${PROJECT_SOURCE_DIR}/third_party/cpuinfo" + ) + endif() + if ((gtest IN_LIST DEPS) OR + (gtest_main IN_LIST DEPS)) + target_include_directories(${NAME} + PRIVATE + "${PROJECT_SOURCE_DIR}/third_party/googletest/googletest" + ) + endif() +endfunction()
\ No newline at end of file diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000..63fbd66 --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,23 @@ +# This file is generated (whence no license header). Do not edit! +# To regenerate, run: +# cmake/bazel_to_cmake.sh + +ruy_cc_binary( + NAME + ruy_example_example + SRCS + example.cc + DEPS + ruy +) + +ruy_cc_binary( + NAME + ruy_example_parametrized_example + SRCS + parametrized_example.cc + DEPS + ruy +) + +ruy_add_all_subdirs() diff --git a/ruy/CMakeLists.txt b/ruy/CMakeLists.txt new file mode 100644 index 0000000..4c3e394 --- /dev/null +++ b/ruy/CMakeLists.txt @@ -0,0 +1,1696 @@ +# This file is generated (whence no license header). Do not edit! +# To regenerate, run: +# cmake/bazel_to_cmake.sh + +if(CMAKE_SYSTEM_NAME STREQUAL Windows) + set(ruy_0_Wall_Wcxx14_compat_Wextra_Wundef "") +else() + set(ruy_0_Wall_Wcxx14_compat_Wextra_Wundef "-Wall;-Wextra;-Wc++14-compat;-Wundef") +endif() + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + set(ruy_1_mfpu_neon "-mfpu=neon") +else() + set(ruy_1_mfpu_neon "") +endif() + +if((CMAKE_BUILD_TYPE STREQUAL Debug) OR MSVC) + set(ruy_2_O3 "") +else() + set(ruy_2_O3 "-O3") +endif() + +ruy_cc_library( + NAME + ruy_trace + HDRS + trace.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_mat + ruy_matrix + ruy_path + ruy_platform + ruy_side_pair +) + +ruy_cc_library( + NAME + ruy_platform + HDRS + platform.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} +) + +ruy_cc_library( + NAME + ruy_gtest_wrapper + TESTONLY + HDRS + gtest_wrapper.h + DEPS + gtest +) + +ruy_cc_library( + NAME + ruy_check_macros + HDRS + check_macros.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} +) + +ruy_cc_test( + NAME + ruy_check_macros_test + SRCS + check_macros_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_check_macros + ruy_gtest_wrapper +) + +ruy_cc_library( + NAME + ruy_opt_set + HDRS + opt_set.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} +) + +ruy_cc_library( + NAME + ruy_time + HDRS + time.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} +) + +if(CMAKE_SYSTEM_NAME STREQUAL Windows) + set(ruy_3_pthread "") +else() + set(ruy_3_pthread "-pthread") +endif() + +ruy_cc_library( + NAME + ruy_wait + SRCS + wait.cc + HDRS + wait.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + LINKOPTS + ${ruy_3_pthread} + DEPS + ruy_time +) + +ruy_cc_test( + NAME + ruy_wait_test + SRCS + wait_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + LINKOPTS + ${ruy_3_pthread} + DEPS + ruy_gtest_wrapper + ruy_platform + ruy_wait +) + +ruy_cc_library( + NAME + ruy_size_util + HDRS + size_util.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_check_macros +) + +ruy_cc_test( + NAME + ruy_size_util_test + SRCS + size_util_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_gtest_wrapper + ruy_size_util +) + +ruy_cc_library( + NAME + ruy_tune + SRCS + tune.cc + HDRS + tune.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_cpu_cache_params + ruy_cpuinfo + ruy_opt_set + ruy_platform + ruy_time +) + +ruy_cc_library( + NAME + ruy_system_aligned_alloc + SRCS + system_aligned_alloc.cc + HDRS + system_aligned_alloc.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} +) + +ruy_cc_library( + NAME + ruy_prepacked_cache + SRCS + prepacked_cache.cc + HDRS + prepacked_cache.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_mat + ruy_system_aligned_alloc + ruy_profiler_instrumentation +) + +ruy_cc_test( + NAME + ruy_tune_test + SRCS + tune_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_cpuinfo + ruy_gtest_wrapper + ruy_tune +) + +ruy_cc_test( + NAME + ruy_prepacked_cache_test + SRCS + prepacked_cache_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_context + ruy_context_get_ctx + ruy_ctx + ruy_gtest_wrapper + ruy_mat + ruy_matrix + ruy_prepacked_cache + ruy + ruy_time +) + +ruy_cc_library( + NAME + ruy_allocator + SRCS + allocator.cc + HDRS + allocator.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_opt_set + ruy_size_util + ruy_system_aligned_alloc +) + +ruy_cc_test( + NAME + ruy_allocator_test + SRCS + allocator_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_allocator + ruy_gtest_wrapper +) + +ruy_cc_library( + NAME + ruy_side_pair + HDRS + side_pair.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_check_macros +) + +ruy_cc_library( + NAME + ruy_block_map + SRCS + block_map.cc + HDRS + block_map.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_check_macros + ruy_cpu_cache_params + ruy_opt_set + ruy_side_pair + ruy_size_util + ruy_trace + ruy_profiler_instrumentation +) + +ruy_cc_test( + NAME + ruy_block_map_test + SRCS + block_map_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_block_map + ruy_cpu_cache_params + ruy_gtest_wrapper + ruy_path + ruy_platform + ruy_side_pair +) + +ruy_cc_library( + NAME + ruy_blocking_counter + SRCS + blocking_counter.cc + HDRS + blocking_counter.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + LINKOPTS + ${ruy_3_pthread} + DEPS + ruy_check_macros + ruy_time + ruy_wait +) + +ruy_cc_library( + NAME + ruy_thread_pool + SRCS + thread_pool.cc + HDRS + thread_pool.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + LINKOPTS + ${ruy_3_pthread} + PUBLIC + DEPS + ruy_blocking_counter + ruy_check_macros + ruy_time + ruy_trace + ruy_wait +) + +ruy_cc_library( + NAME + ruy_cpu_cache_params + HDRS + cpu_cache_params.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} +) + +if(CMAKE_SYSTEM_NAME STREQUAL Windows) + set(ruy_4_Wno_undef "") +else() + set(ruy_4_Wno_undef "-Wno-undef") +endif() + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le) + set(ruy_5_DRUY_HAVE_CPUINFO "") +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL s390 OR CMAKE_SYSTEM_PROCESSOR STREQUAL s390x) + set(ruy_5_DRUY_HAVE_CPUINFO "") +elseif(CMAKE_SYSTEM_NAME STREQUAL Fuchsia) + set(ruy_5_DRUY_HAVE_CPUINFO "") +else() + set(ruy_5_DRUY_HAVE_CPUINFO "-DRUY_HAVE_CPUINFO") +endif() + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le) + set(ruy_6_cpuinfo "") +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL s390 OR CMAKE_SYSTEM_PROCESSOR STREQUAL s390x) + set(ruy_6_cpuinfo "") +elseif(CMAKE_SYSTEM_NAME STREQUAL Fuchsia) + set(ruy_6_cpuinfo "") +else() + set(ruy_6_cpuinfo "cpuinfo") +endif() + +ruy_cc_library( + NAME + ruy_cpuinfo + SRCS + cpuinfo.cc + HDRS + cpuinfo.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + ${ruy_4_Wno_undef} + ${ruy_5_DRUY_HAVE_CPUINFO} + DEPS + ruy_platform + ruy_check_macros + ruy_cpu_cache_params + ${ruy_6_cpuinfo} +) + +ruy_cc_library( + NAME + ruy_path + HDRS + path.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + PUBLIC + DEPS + ruy_platform + ruy_size_util +) + +ruy_cc_library( + NAME + ruy_performance_advisory + HDRS + performance_advisory.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + PUBLIC +) + +ruy_cc_library( + NAME + ruy_matrix + HDRS + matrix.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + PUBLIC + DEPS + ruy_check_macros +) + +ruy_cc_test( + NAME + ruy_matrix_test + SRCS + matrix_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_gtest_wrapper + ruy_matrix +) + +ruy_cc_library( + NAME + ruy_mul_params + HDRS + mul_params.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + PUBLIC + DEPS + ruy_check_macros + ruy_size_util +) + +ruy_cc_test( + NAME + ruy_mul_params_test + SRCS + mul_params_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_gtest_wrapper + ruy_mul_params +) + +ruy_cc_library( + NAME + ruy_mat + HDRS + mat.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_check_macros + ruy_matrix + ruy_size_util +) + +ruy_cc_library( + NAME + ruy_asm_helpers + HDRS + asm_helpers.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_opt_set +) + +ruy_cc_library( + NAME + ruy_apply_multiplier + SRCS + apply_multiplier.cc + HDRS + apply_multiplier.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_check_macros + ruy_mul_params +) + +ruy_cc_test( + NAME + ruy_apply_multiplier_test + SRCS + apply_multiplier_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_apply_multiplier + ruy_gtest_wrapper + ruy_mul_params +) + +ruy_cc_library( + NAME + ruy_kernel_common + HDRS + kernel_common.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_apply_multiplier + ruy_check_macros + ruy_mat + ruy_matrix + ruy_mul_params + ruy_opt_set + ruy_path + ruy_platform + ruy_side_pair + ruy_size_util + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_pack_common + HDRS + pack_common.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_check_macros + ruy_mat + ruy_matrix + ruy_opt_set + ruy_path + ruy_platform + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_kernel_arm + SRCS + kernel_arm32.cc + kernel_arm64.cc + HDRS + kernel_arm.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_asm_helpers + ruy_check_macros + ruy_kernel_common + ruy_mat + ruy_mul_params + ruy_opt_set + ruy_path + ruy_platform + ruy_side_pair + ruy_size_util + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_pack_arm + SRCS + pack_arm.cc + HDRS + pack_arm.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_asm_helpers + ruy_check_macros + ruy_mat + ruy_opt_set + ruy_pack_common + ruy_path + ruy_platform + ruy_tune + ruy_profiler_instrumentation +) + +if((CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64) AND NOT MSVC) + set(ruy_7_mavx512bw_mavx512cd_mavx512dq_mavx512f_mavx512vl_arch_AVX512 ";-mavx512f;-mavx512vl;-mavx512cd;-mavx512bw;-mavx512dq") +elseif(MSVC) + set(ruy_7_mavx512bw_mavx512cd_mavx512dq_mavx512f_mavx512vl_arch_AVX512 "/arch:AVX512") +else() + set(ruy_7_mavx512bw_mavx512cd_mavx512dq_mavx512f_mavx512vl_arch_AVX512 "") +endif() + +ruy_cc_library( + NAME + ruy_kernel_avx512 + SRCS + kernel_avx512.cc + HDRS + kernel_x86.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + ${ruy_7_mavx512bw_mavx512cd_mavx512dq_mavx512f_mavx512vl_arch_AVX512} + DEPS + ruy_check_macros + ruy_kernel_common + ruy_mat + ruy_mul_params + ruy_opt_set + ruy_path + ruy_platform + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_pack_avx512 + SRCS + pack_avx512.cc + HDRS + pack_x86.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + ${ruy_7_mavx512bw_mavx512cd_mavx512dq_mavx512f_mavx512vl_arch_AVX512} + DEPS + ruy_check_macros + ruy_mat + ruy_opt_set + ruy_pack_common + ruy_path + ruy_platform + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_have_built_path_for_avx512 + SRCS + have_built_path_for_avx512.cc + HDRS + have_built_path_for.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + ${ruy_7_mavx512bw_mavx512cd_mavx512dq_mavx512f_mavx512vl_arch_AVX512} + DEPS + ruy_opt_set + ruy_platform +) + +if((CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64) AND NOT MSVC) + set(ruy_8_mavx2_mfma_arch_AVX2 "-mavx2;-mfma") +elseif(MSVC) + set(ruy_8_mavx2_mfma_arch_AVX2 "/arch:AVX2") +else() + set(ruy_8_mavx2_mfma_arch_AVX2 "") +endif() + +ruy_cc_library( + NAME + ruy_kernel_avx2_fma + SRCS + kernel_avx2_fma.cc + HDRS + kernel_x86.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + ${ruy_8_mavx2_mfma_arch_AVX2} + DEPS + ruy_check_macros + ruy_kernel_common + ruy_mat + ruy_mul_params + ruy_opt_set + ruy_path + ruy_platform + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_pack_avx2_fma + SRCS + pack_avx2_fma.cc + HDRS + pack_x86.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + ${ruy_8_mavx2_mfma_arch_AVX2} + DEPS + ruy_check_macros + ruy_mat + ruy_opt_set + ruy_pack_common + ruy_path + ruy_platform + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_have_built_path_for_avx2_fma + SRCS + have_built_path_for_avx2_fma.cc + HDRS + have_built_path_for.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + ${ruy_8_mavx2_mfma_arch_AVX2} + DEPS + ruy_opt_set + ruy_platform +) + +if((CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64) AND NOT MSVC) + set(ruy_9_mavx_arch_AVX "-mavx") +elseif(MSVC) + set(ruy_9_mavx_arch_AVX "/arch:AVX") +else() + set(ruy_9_mavx_arch_AVX "") +endif() + +ruy_cc_library( + NAME + ruy_kernel_avx + SRCS + kernel_avx.cc + HDRS + kernel_x86.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + ${ruy_9_mavx_arch_AVX} + DEPS + ruy_check_macros + ruy_kernel_common + ruy_mat + ruy_mul_params + ruy_opt_set + ruy_path + ruy_platform + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_pack_avx + SRCS + pack_avx.cc + HDRS + pack_x86.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + ${ruy_9_mavx_arch_AVX} + DEPS + ruy_check_macros + ruy_mat + ruy_opt_set + ruy_pack_common + ruy_path + ruy_platform + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_have_built_path_for_avx + SRCS + have_built_path_for_avx.cc + HDRS + have_built_path_for.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + ${ruy_9_mavx_arch_AVX} + DEPS + ruy_opt_set + ruy_platform +) + +ruy_cc_library( + NAME + ruy_kernel + HDRS + kernel.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_apply_multiplier + ruy_check_macros + ruy_kernel_arm + ruy_kernel_avx + ruy_kernel_avx2_fma + ruy_kernel_avx512 + ruy_kernel_common + ruy_mat + ruy_matrix + ruy_mul_params + ruy_opt_set + ruy_path + ruy_platform + ruy_side_pair + ruy_size_util + ruy_trace + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_pack + HDRS + pack.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_check_macros + ruy_mat + ruy_matrix + ruy_opt_set + ruy_pack_arm + ruy_pack_avx + ruy_pack_avx2_fma + ruy_pack_avx512 + ruy_pack_common + ruy_path + ruy_platform + ruy_trace + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_have_built_path_for + HDRS + have_built_path_for.h + DEPS + ruy_have_built_path_for_avx + ruy_have_built_path_for_avx2_fma + ruy_have_built_path_for_avx512 + ruy_platform +) + +ruy_cc_library( + NAME + ruy_context + SRCS + context.cc + HDRS + context.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + PUBLIC + DEPS + ruy_allocator + ruy_check_macros + ruy_ctx + ruy_path + ruy_performance_advisory + ruy_platform + ruy_prepacked_cache + ruy_thread_pool + ruy_tune +) + +ruy_cc_test( + NAME + ruy_context_test + SRCS + context_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_context + ruy_gtest_wrapper + ruy_path + ruy_platform + ruy_prepacked_cache + ruy_tune +) + +ruy_cc_library( + NAME + ruy_ctx_header_only_should_not_include_other_ruy_headers + TESTONLY + HDRS + ctx.h +) + +ruy_cc_library( + NAME + ruy_ctx + SRCS + ctx.cc + HDRS + ctx.h + ctx_impl.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_allocator + ruy_check_macros + ruy_cpuinfo + ruy_have_built_path_for + ruy_path + ruy_performance_advisory + ruy_platform + ruy_prepacked_cache + ruy_thread_pool + ruy_trace + ruy_tune +) + +ruy_cc_library( + NAME + ruy_context_get_ctx + SRCS + context_get_ctx.cc + HDRS + context_get_ctx.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_context + ruy_ctx +) + +ruy_cc_test( + NAME + ruy_ctx_test + SRCS + ctx_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_ctx + ruy_gtest_wrapper + ruy_path + ruy_platform +) + +ruy_cc_library( + NAME + ruy_trmul_params + HDRS + trmul_params.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_mat + ruy_mul_params + ruy_path + ruy_side_pair + ruy_tune +) + +ruy_cc_library( + NAME + ruy_trmul + SRCS + trmul.cc + HDRS + trmul.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_allocator + ruy_block_map + ruy_check_macros + ruy_cpu_cache_params + ruy_cpuinfo + ruy_ctx + ruy_mat + ruy_matrix + ruy_mul_params + ruy_opt_set + ruy_side_pair + ruy_size_util + ruy_thread_pool + ruy_trace + ruy_trmul_params + ruy_tune + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_prepare_packed_matrices + SRCS + prepare_packed_matrices.cc + HDRS + prepare_packed_matrices.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_allocator + ruy_ctx + ruy_matrix + ruy_prepacked_cache + ruy_side_pair + ruy_trace + ruy_trmul_params +) + +ruy_cc_library( + NAME + ruy_create_trmul_params + HDRS + create_trmul_params.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_allocator + ruy_check_macros + ruy_ctx + ruy_kernel + ruy_mat + ruy_mul_params + ruy_pack + ruy_path + ruy_performance_advisory + ruy_platform + ruy_side_pair + ruy_trace + ruy_trmul_params +) + +ruy_cc_library( + NAME + ruy_validate + HDRS + validate.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_check_macros + ruy_mat + ruy_mul_params + ruy_side_pair +) + +ruy_cc_library( + NAME + ruy_frontend + SRCS + frontend.cc + HDRS + frontend.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_allocator + ruy_create_trmul_params + ruy_ctx + ruy_mat + ruy_mul_params + ruy_prepare_packed_matrices + ruy_trace + ruy_trmul + ruy_trmul_params + ruy_validate + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy + HDRS + context.h + matrix.h + mul_params.h + path.h + ruy.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + PUBLIC + DEPS + ruy_check_macros + ruy_context + ruy_context_get_ctx + ruy_frontend + ruy_mat + ruy_matrix + ruy_mul_params + ruy_path + ruy_platform + ruy_size_util + ruy_trace +) + +ruy_cc_test( + NAME + ruy_perchannel_buffers_reallocation_test + SRCS + perchannel_buffers_reallocation_test.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_context + ruy_gtest_wrapper + ruy_kernel + ruy_matrix + ruy_path + ruy_performance_advisory + ruy +) + +ruy_cc_library( + NAME + ruy_pmu + TESTONLY + SRCS + pmu.cc + HDRS + pmu.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + DEPS + ruy_check_macros +) + +ruy_cc_library( + NAME + ruy_reference_mul + HDRS + reference_mul.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + PUBLIC + DEPS + ruy_apply_multiplier + ruy_matrix + ruy_mul_params +) + +if(CMAKE_SYSTEM_NAME STREQUAL Windows) + set(ruy_10_lm "") +else() + set(ruy_10_lm "-lm") +endif() + +ruy_cc_library( + NAME + ruy_test_lib + TESTONLY + HDRS + test.h + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + LINKOPTS + ${ruy_10_lm} + DEPS + ruy_allocator + ruy_size_util + ruy_reference_mul + ruy_matrix + ruy_pmu + ruy + ruy_mul_params + ruy_time + ruy_gtest_wrapper + ruy_platform + ruy_context + ruy_ctx + ruy_context_get_ctx + ruy_pack_common + ruy_profiler_profiler +) + +ruy_cc_binary( + NAME + ruy_benchmark_f32_f32_f32_f32 + TESTONLY + SRCS + benchmark.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=f32 + -DRUY_TEST_RHSSCALAR=f32 + -DRUY_TEST_ACCUMSCALAR=f32 + -DRUY_TEST_DSTSCALAR=f32 + DEPS + ruy_test_lib + ruy_profiler_instrumentation +) + +ruy_cc_binary( + NAME + ruy_benchmark_u8_u8_i32_u8 + TESTONLY + SRCS + benchmark.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=u8 + -DRUY_TEST_RHSSCALAR=u8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=u8 + DEPS + ruy_test_lib + ruy_profiler_instrumentation +) + +ruy_cc_binary( + NAME + ruy_benchmark_i8_i8_i32_u8 + TESTONLY + SRCS + benchmark.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=i8 + -DRUY_TEST_RHSSCALAR=i8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=u8 + DEPS + ruy_test_lib + ruy_profiler_instrumentation +) + +ruy_cc_binary( + NAME + ruy_benchmark_i8_i8_i32_i8 + TESTONLY + SRCS + benchmark.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=i8 + -DRUY_TEST_RHSSCALAR=i8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=i8 + DEPS + ruy_test_lib + ruy_profiler_instrumentation +) + +ruy_cc_binary( + NAME + ruy_benchmark_u8_u8_i32_i16 + TESTONLY + SRCS + benchmark.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=u8 + -DRUY_TEST_RHSSCALAR=u8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=i16 + DEPS + ruy_test_lib + ruy_profiler_instrumentation +) + +ruy_cc_binary( + NAME + ruy_benchmark_i8_i8_i32_i32 + TESTONLY + SRCS + benchmark.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=i8 + -DRUY_TEST_RHSSCALAR=i8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=i32 + DEPS + ruy_test_lib + ruy_profiler_instrumentation +) + +ruy_cc_test( + NAME + ruy_test_fast_f32_f32_f32_f32 + SRCS + test_fast.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=f32 + -DRUY_TEST_RHSSCALAR=f32 + -DRUY_TEST_ACCUMSCALAR=f32 + -DRUY_TEST_DSTSCALAR=f32 + DEPS + ruy_test_lib + gtest_main +) + +ruy_cc_test( + NAME + ruy_test_fast_f64_f32_f64_f32 + SRCS + test_fast.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=f64 + -DRUY_TEST_RHSSCALAR=f32 + -DRUY_TEST_ACCUMSCALAR=f64 + -DRUY_TEST_DSTSCALAR=f32 + DEPS + ruy_test_lib + gtest_main +) + +ruy_cc_test( + NAME + ruy_test_fast_f32_f64_f64_f64 + SRCS + test_fast.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=f32 + -DRUY_TEST_RHSSCALAR=f64 + -DRUY_TEST_ACCUMSCALAR=f64 + -DRUY_TEST_DSTSCALAR=f64 + DEPS + ruy_test_lib + gtest_main +) + +ruy_cc_test( + NAME + ruy_test_fast_u8_u8_i32_u8 + SRCS + test_fast.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=u8 + -DRUY_TEST_RHSSCALAR=u8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=u8 + DEPS + ruy_test_lib + gtest_main +) + +ruy_cc_test( + NAME + ruy_test_fast_i8_i8_i32_i8 + SRCS + test_fast.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=i8 + -DRUY_TEST_RHSSCALAR=i8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=i8 + DEPS + ruy_test_lib + gtest_main +) + +ruy_cc_test( + NAME + ruy_test_fast_i8_u8_i32_i8 + SRCS + test_fast.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=i8 + -DRUY_TEST_RHSSCALAR=u8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=i8 + DEPS + ruy_test_lib + gtest_main +) + +ruy_cc_test( + NAME + ruy_test_fast_u8_u8_i32_i16 + SRCS + test_fast.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=u8 + -DRUY_TEST_RHSSCALAR=u8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=i16 + DEPS + ruy_test_lib + gtest_main +) + +ruy_cc_test( + NAME + ruy_test_fast_i8_i8_i32_i32 + SRCS + test_fast.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=i8 + -DRUY_TEST_RHSSCALAR=i8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=i32 + DEPS + ruy_test_lib + gtest_main +) + +ruy_cc_test( + NAME + ruy_test_fast_i8_u8_i32_i32 + SRCS + test_fast.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=i8 + -DRUY_TEST_RHSSCALAR=u8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=i32 + DEPS + ruy_test_lib + gtest_main +) + +ruy_cc_test( + NAME + ruy_test_slow_f32_f32_f32_f32 + SRCS + test_slow.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=f32 + -DRUY_TEST_RHSSCALAR=f32 + -DRUY_TEST_ACCUMSCALAR=f32 + -DRUY_TEST_DSTSCALAR=f32 + DEPS + ruy_test_lib + gtest_main + TAGS + slow +) + +ruy_cc_test( + NAME + ruy_test_slow_u8_u8_i32_u8 + SRCS + test_slow.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=u8 + -DRUY_TEST_RHSSCALAR=u8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=u8 + DEPS + ruy_test_lib + gtest_main + TAGS + slow +) + +ruy_cc_test( + NAME + ruy_test_slow_i8_i8_i32_i8 + SRCS + test_slow.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=i8 + -DRUY_TEST_RHSSCALAR=i8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=i8 + DEPS + ruy_test_lib + gtest_main + TAGS + slow +) + +ruy_cc_test( + NAME + ruy_test_slow_u8_u8_i32_i16 + SRCS + test_slow.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=u8 + -DRUY_TEST_RHSSCALAR=u8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=i16 + DEPS + ruy_test_lib + gtest_main + TAGS + slow +) + +ruy_cc_test( + NAME + ruy_test_slow_i8_i8_i32_i32 + SRCS + test_slow.cc + COPTS + ${ruy_0_Wall_Wcxx14_compat_Wextra_Wundef} + ${ruy_1_mfpu_neon} + ${ruy_2_O3} + -DRUY_TEST_LHSSCALAR=i8 + -DRUY_TEST_RHSSCALAR=i8 + -DRUY_TEST_ACCUMSCALAR=i32 + -DRUY_TEST_DSTSCALAR=i32 + DEPS + ruy_test_lib + gtest_main + TAGS + slow +) + +ruy_add_all_subdirs() diff --git a/ruy/profiler/CMakeLists.txt b/ruy/profiler/CMakeLists.txt new file mode 100644 index 0000000..df4b30a --- /dev/null +++ b/ruy/profiler/CMakeLists.txt @@ -0,0 +1,72 @@ +# This file is generated (whence no license header). Do not edit! +# To regenerate, run: +# cmake/bazel_to_cmake.sh + +if(${RUY_PROFILER}) + set(ruy_profiler_0_RUY_PROFILER "RUY_PROFILER") +else() + set(ruy_profiler_0_RUY_PROFILER "") +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL Windows) + set(ruy_profiler_1_pthread "") +else() + set(ruy_profiler_1_pthread "-pthread") +endif() + +ruy_cc_library( + NAME + ruy_profiler_instrumentation + SRCS + instrumentation.cc + HDRS + instrumentation.h + DEFINES + ${ruy_profiler_0_RUY_PROFILER} + LINKOPTS + ${ruy_profiler_1_pthread} + PUBLIC +) + +ruy_cc_library( + NAME + ruy_profiler_profiler + SRCS + profiler.cc + treeview.cc + HDRS + profiler.h + treeview.h + LINKOPTS + ${ruy_profiler_1_pthread} + PUBLIC + DEPS + ruy_profiler_instrumentation +) + +ruy_cc_library( + NAME + ruy_profiler_test_instrumented_library + TESTONLY + SRCS + test_instrumented_library.cc + HDRS + test_instrumented_library.h + DEPS + ruy_profiler_instrumentation +) + +ruy_cc_test( + NAME + ruy_profiler_test + SRCS + test.cc + LINKOPTS + ${ruy_profiler_1_pthread} + DEPS + ruy_profiler_profiler + ruy_profiler_test_instrumented_library + ruy_gtest_wrapper +) + +ruy_add_all_subdirs() diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt new file mode 100644 index 0000000..4c82d83 --- /dev/null +++ b/third_party/CMakeLists.txt @@ -0,0 +1,5 @@ +# This file is generated (whence no license header). Do not edit! +# To regenerate, run: +# cmake/bazel_to_cmake.sh + +ruy_add_all_subdirs() |