per_target.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2022 Google LLC
  2. // SPDX-License-Identifier: Apache-2.0
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #ifndef HIGHWAY_HWY_PER_TARGET_H_
  16. #define HIGHWAY_HWY_PER_TARGET_H_
  17. #include <stddef.h>
  18. #include <stdint.h>
  19. #include "hwy/highway_export.h"
  20. // Functions to query the capabilities of the target that will be called by
  21. // HWY_DYNAMIC_DISPATCH, which is not necessarily the current target.
  22. namespace hwy {
  23. // Returns the HWY_TARGET which HWY_DYNAMIC_DISPATCH selected.
  24. HWY_DLLEXPORT int64_t DispatchedTarget();
  25. // Returns size in bytes of a vector, i.e. `Lanes(ScalableTag<uint8_t>())`.
  26. //
  27. // Do not cache the result, which may change after calling DisableTargets, or
  28. // if software requests a different vector size (e.g. when entering/exiting SME
  29. // streaming mode). Instead call this right before the code that depends on the
  30. // result, without any DisableTargets or SME transition in-between. Note that
  31. // this involves an indirect call, so prefer not to call this frequently nor
  32. // unnecessarily.
  33. HWY_DLLEXPORT size_t VectorBytes();
  34. // Returns whether 16/64-bit floats are a supported lane type.
  35. HWY_DLLEXPORT bool HaveFloat16();
  36. HWY_DLLEXPORT bool HaveFloat64();
  37. } // namespace hwy
  38. #endif // HIGHWAY_HWY_PER_TARGET_H_