Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ComputeLibrary] Add new package for ARM-software/ComputeLibrary #19958

Merged
merged 12 commits into from
Aug 22, 2024

Conversation

uilianries
Copy link
Member

@uilianries uilianries commented Sep 19, 2023

Specify library name and version: compute_library/23.08

That's a requirement for #19681 (OpenVino)

The ComputeLibrary has experimental CMake support, but it's restricted to a single linux profile, so it does not work with Mac. The official documentation uses SCons: https://github.com/ARM-software/ComputeLibrary

  • The fPIC options is missing because is hardcoded in Scons script, so it would require a patch.
  • It's not possible to avoid building all tests, but we don't install them at least
  • The steps build and install are executed together, because install is a sub-step of build major step. We can not change without a patch, so we copy/clean during package() method
  • It builds both static and shared at same build, there is no option to control it.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@conan-center-bot

This comment has been minimized.

@github-actions
Copy link
Contributor

Hooks produced the following warnings for commit 7d86026
compute_library/23.08@#557d1db9635cd53cff3ff429a550ed93
post_source(): WARN: [SHORT_PATHS USAGE (KB-H066)] The file './src/core/NEON/kernels/arm_conv/depthwise/kernels/a64_u8s8u8q_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst/generic.cpp' has a very long path and may exceed Windows max path length. Add 'short_paths = True' in your recipe.

yes_no = lambda v: "1" if v else "0"
debug = yes_no(self.settings.build_type == "Debug")
build_os = str(self.settings.os).lower()
arch = {"armv8": "armv8a", "x86": "x86_32", "armv7": "armv7a", "armv7hf": "armv7a-hf"}.get(str(self.settings.arch), str(self.settings.arch))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ARM compute allows to build code with armv8.2a (fp16 support), SVE and SME.
How to use it via this recipe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for example Apple M1, M2 support fp16, so we need to enable it by default.

minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.")
supported_os = ["Android", "Linux", "OpenBSD", "Macos", "Tizen"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# INFO: Using scons to build the library we don't have control over shared/static and install step, it is done all together always
# INFO: https://arm-software.github.io/ComputeLibrary/latest/how_to_build.xhtml
yes_no = lambda v: "1" if v else "0"
debug = yes_no(self.settings.build_type == "Debug")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can also add these options for debug debug=1 asserts=1 logging=1

if str(self.settings.os) not in supported_os:
raise ConanInvalidConfiguration(f"{self.ref} does not support {self.settings.os}. It is only supported on {supported_os}.")
if "arm" not in str(self.settings.arch) and "x86" not in str(self.settings.arch):
raise ConanInvalidConfiguration(f"{self.ref} does not support {self.settings.arch}. It is only supported on arm and x86.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arm and x86 usually imply 32bits
should we write arm / arm64 and x86_64 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a good clarification.

minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.")
supported_os = ["Android", "Linux", "OpenBSD", "Macos", "Tizen"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@conan-center-bot

This comment has been minimized.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@conan-center-bot

This comment has been minimized.

@github-actions
Copy link
Contributor

Hooks produced the following warnings for commit 158d0c7
compute_library/23.08@#bbfb9834bb59b8d05cadb58204eb4f74
post_source(): WARN: [SHORT_PATHS USAGE (KB-H066)] The file './src/core/NEON/kernels/arm_conv/depthwise/kernels/a64_u8s8u8q_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst/generic.cpp' has a very long path and may exceed Windows max path length. Add 'short_paths = True' in your recipe.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@conan-center-bot

This comment has been minimized.

@github-actions
Copy link
Contributor

Hooks produced the following warnings for commit e3e2f36
compute_library/23.08@#77aaf6972aa3a2e9d1856df00349d77e
post_source(): WARN: [SHORT_PATHS USAGE (KB-H066)] The file './src/core/NEON/kernels/arm_conv/depthwise/kernels/a64_u8s8u8q_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst/generic.cpp' has a very long path and may exceed Windows max path length. Add 'short_paths = True' in your recipe.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
if "armv8" not in str(self.settings.arch) and self.options.enable_multi_isa:
raise ConanInvalidConfiguration(f"{self.ref} does not support multi_isa option for {self.settings.arch}. It is only supported on armv8.")
if self.settings.arch == "armv8" and self.build_settings.arch == "x86_64" and self.settings.os == "Macos":
raise ConanInvalidConfiguration(f"Mac Intel is not supported for armv8-a. Please, use Mac M1 as native build.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, cross compilation from macOS arm64 to x86_64 (as vice versa) works well. You need to use -arch <arm64 | x86_64> option.

See https://github.com/openvinotoolkit/openvino/blob/master/src/plugins/intel_cpu/thirdparty/ACLConfig.cmake#L285-L288 as example

Copy link
Member Author

@uilianries uilianries Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is: I'm using scons and it changes to armv8-a that's not identified by apple clang and passing as -march.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also use scons, but it is just run from cmake.

@conan-center-bot

This comment has been minimized.

@github-actions
Copy link
Contributor

Hooks produced the following warnings for commit ff185c2
compute_library/23.02.1@#47dafd2c82db97de0174fe779d93eb19
post_source(): WARN: [SHORT_PATHS USAGE (KB-H066)] The file './src/core/NEON/kernels/arm_conv/depthwise/kernels/a64_u8s8u8q_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst/generic.cpp' has a very long path and may exceed Windows max path length. Add 'short_paths = True' in your recipe.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute_graph.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute_core.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [APPLE RELOCATABLE SHARED LIBS (KB-H077)] install_name dir of these shared libs is not @rpath: libarm_compute.dylib, libarm_compute_core.dylib, libarm_compute_graph.dylib
compute_library/23.08@#418fdff5101d761b59739ceaf986b2c5
post_source(): WARN: [SHORT_PATHS USAGE (KB-H066)] The file './src/core/NEON/kernels/arm_conv/depthwise/kernels/a64_u8s8u8q_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst/generic.cpp' has a very long path and may exceed Windows max path length. Add 'short_paths = True' in your recipe.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute_graph.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute_core.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [APPLE RELOCATABLE SHARED LIBS (KB-H077)] install_name dir of these shared libs is not @rpath: libarm_compute.dylib, libarm_compute_core.dylib, libarm_compute_graph.dylib

multi_isa = yes_no(self.options.enable_multi_isa)
build = "cross_compile" if cross_building(self) else "native"
with chdir(self, self.source_folder):
self.run(f"scons Werror=0 validation_tests=0 examples=0 gemm_tuner=0 multi_isa={multi_isa} openmp={openmp} debug={debug} neon={neon} opencl={opencl} os={build_os} arch={arch} build={build} build_dir={self.build_folder} install_dir={self.package_folder} -j{build_jobs(self)} toolchain_prefix=''", env="conanbuild")
Copy link
Contributor

@ilya-lavrenov ilya-lavrenov Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conan's arch and compute library archs are different. Compute Library allows to specify exact optimizations which are required. Without it, it does not give proper performance.
So, bypassing conan's arch to compute library is not enough. Conan's arch can be used as initial guess, while users still need to have an ability to provide an option for arch to enable specific optimizations like SVE, SME

As I wrote - Apple M1 must set armv8.2-a to enable FP16 optimization. Currently, it's not set and performance is poor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, you can customize your settings.yml, providing not only new archs, but also new subsettings: https://docs.conan.io/2/reference/config_files/settings.html#customizing-settings

Conan covers most generic and known archs, but when talking about optimization, is better having a specific profile adapted, so you can be sure about what's in your package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with such approach.

If we put it on x64 arch, what I am asking is to provide a way to select between SSE, AVX, AMX optimizations, while you want me to customize whole settings file and add SSE, AVX and so on to be able to properly compile the library. Don't mix different platforms (settings) against different library optimizations capabilities (the arm option of ARM Compute Library).

Any reason why on Apple ARM64 people would not have FP16 support (which is available out of box) and have to change settings to get suitable performance?

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@conan-center-bot
Copy link
Collaborator

Conan v1 pipeline ✔️

All green in build 8 (8064b14d181f682f6398af943ba6467271bf5670):

  • compute_library/23.02.1:
    All packages built successfully! (All logs)

  • compute_library/23.08:
    All packages built successfully! (All logs)


Conan v2 pipeline ✔️

Note: Conan v2 builds are now mandatory. Please read our discussion about it.

All green in build 8 (8064b14d181f682f6398af943ba6467271bf5670):

  • compute_library/23.08:
    All packages built successfully! (All logs)

  • compute_library/23.02.1:
    All packages built successfully! (All logs)

@github-actions
Copy link
Contributor

Hooks produced the following warnings for commit 8064b14
compute_library/23.02.1@#f6f4e87eeace0a9e27d5728842898b34
post_source(): WARN: [SHORT_PATHS USAGE (KB-H066)] The file './src/core/NEON/kernels/arm_conv/depthwise/kernels/a64_u8s8u8q_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst/generic.cpp' has a very long path and may exceed Windows max path length. Add 'short_paths = True' in your recipe.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute_graph.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute_core.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [APPLE RELOCATABLE SHARED LIBS (KB-H077)] install_name dir of these shared libs is not @rpath: libarm_compute.dylib, libarm_compute_core.dylib, libarm_compute_graph.dylib
compute_library/23.08@#552c581b77110a37876484b05ed29789
post_source(): WARN: [SHORT_PATHS USAGE (KB-H066)] The file './src/core/NEON/kernels/arm_conv/depthwise/kernels/a64_u8s8u8q_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst/generic.cpp' has a very long path and may exceed Windows max path length. Add 'short_paths = True' in your recipe.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute_graph.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library './lib/libarm_compute_core.so' links to system library 'dl' but it is not in cpp_info.system_libs.
post_package(): WARN: [APPLE RELOCATABLE SHARED LIBS (KB-H077)] install_name dir of these shared libs is not @rpath: libarm_compute.dylib, libarm_compute_core.dylib, libarm_compute_graph.dylib

if str(self.settings.os) not in supported_os:
raise ConanInvalidConfiguration(f"{self.ref} does not support {self.settings.os}. It is only supported on {supported_os}.")
if "arm" not in str(self.settings.arch) and "x86" not in str(self.settings.arch):
raise ConanInvalidConfiguration(f"{self.ref} does not support {self.settings.arch}. It is only supported on arm and x86.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a good clarification.

@danimtb danimtb self-assigned this Aug 19, 2024
@conan-center-bot conan-center-bot merged commit 5fb1c3b into conan-io:master Aug 22, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants