xmake.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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.2.0", "7e0be78b8318e8bdbf6fa545d2ecb4c90f947df03f7aadc42c1967f019e63343")
  8. add_versions("1.1.0", "354a8b4539b588e70b98ec70844273e3f2741302c4c377bcc4e81b3d1866f7c9")
  9. add_configs("contrib", {description = "Build SIMD-related utilities", default = false, type = "boolean"})
  10. add_deps("cmake")
  11. on_install(function (package)
  12. local configs = {"-DHWY_ENABLE_INSTALL=ON", "-DBUILD_TESTING=OFF"}
  13. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  14. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  15. table.insert(configs, "-DHWY_ENABLE_CONTRIB=" .. (package:config("contrib") and "ON" or "OFF"))
  16. import("package.tools.cmake").install(package, configs)
  17. os.tryrm(package:installdir("lib/*hwy_test*"))
  18. os.tryrm(package:installdir("bin/*hwy_test*"))
  19. end)
  20. on_test(function (package)
  21. assert(package:check_cxxsnippets({test = [[
  22. #include <hwy/highway.h>
  23. namespace hn = hwy::HWY_NAMESPACE;
  24. using T = float;
  25. void test(const T* HWY_RESTRICT mul_array,
  26. const T* HWY_RESTRICT add_array,
  27. const size_t size, T* HWY_RESTRICT x_array) {
  28. const hn::ScalableTag<T> d;
  29. for (size_t i = 0; i < size; i += hn::Lanes(d)) {
  30. const auto mul = hn::Load(d, mul_array + i);
  31. const auto add = hn::Load(d, add_array + i);
  32. auto x = hn::Load(d, x_array + i);
  33. x = hn::MulAdd(mul, x, add);
  34. hn::Store(x, d, x_array + i);
  35. }
  36. }
  37. ]]}, {configs = {languages = "c++11"}}))
  38. end)