xmake.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package("highway")
  2. set_homepage("https://github.com/google/highway")
  3. set_description("Performance-portable, length-agnostic SIMD with runtime dispatch")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/google/highway/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/google/highway.git")
  7. add_versions("1.3.0", "07b3c1ba2c1096878a85a31a5b9b3757427af963b1141ca904db2f9f4afe0bc2")
  8. add_versions("1.2.0", "7e0be78b8318e8bdbf6fa545d2ecb4c90f947df03f7aadc42c1967f019e63343")
  9. add_versions("1.1.0", "354a8b4539b588e70b98ec70844273e3f2741302c4c377bcc4e81b3d1866f7c9")
  10. add_configs("contrib", {description = "Build SIMD-related utilities", default = false, type = "boolean"})
  11. add_deps("cmake")
  12. on_install(function (package)
  13. local configs = {"-DHWY_ENABLE_INSTALL=ON", "-DBUILD_TESTING=OFF"}
  14. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  15. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  16. table.insert(configs, "-DHWY_ENABLE_CONTRIB=" .. (package:config("contrib") and "ON" or "OFF"))
  17. import("package.tools.cmake").install(package, configs)
  18. os.tryrm(package:installdir("lib/*hwy_test*"))
  19. os.tryrm(package:installdir("bin/*hwy_test*"))
  20. end)
  21. on_test(function (package)
  22. assert(package:check_cxxsnippets({test = [[
  23. #include <hwy/highway.h>
  24. namespace hn = hwy::HWY_NAMESPACE;
  25. using T = float;
  26. void test(const T* HWY_RESTRICT mul_array,
  27. const T* HWY_RESTRICT add_array,
  28. const size_t size, T* HWY_RESTRICT x_array) {
  29. const hn::ScalableTag<T> d;
  30. for (size_t i = 0; i < size; i += hn::Lanes(d)) {
  31. const auto mul = hn::Load(d, mul_array + i);
  32. const auto add = hn::Load(d, add_array + i);
  33. auto x = hn::Load(d, x_array + i);
  34. x = hn::MulAdd(mul, x, add);
  35. hn::Store(x, d, x_array + i);
  36. }
  37. }
  38. ]]}, {configs = {languages = "c++14"}}))
  39. end)