Skip to content

Commit

Permalink
highway: add package
Browse files Browse the repository at this point in the history
  • Loading branch information
star-hengxing committed Mar 18, 2024
1 parent aa218c8 commit df27d39
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions packages/h/highway/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package("highway")
set_homepage("https://github.com/google/highway")
set_description("Performance-portable, length-agnostic SIMD with runtime dispatch")
set_license("Apache-2.0")

add_urls("https://github.com/google/highway/archive/refs/tags/$(version).tar.gz",
"https://github.com/google/highway.git")

add_versions("1.1.0", "354a8b4539b588e70b98ec70844273e3f2741302c4c377bcc4e81b3d1866f7c9")

add_configs("contrib", {description = "Build SIMD-related utilities", default = false, type = "boolean"})

add_deps("cmake")

on_install(function (package)
local configs = {"-DHWY_ENABLE_INSTALL=ON", "-DBUILD_TESTING=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DHWY_ENABLE_CONTRIB=" .. (package:config("contrib") and "ON" or "OFF"))
import("package.tools.cmake").install(package, configs)
os.tryrm(package:installdir("lib/*hwy_test*"))
end)

on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <hwy/highway.h>
namespace hn = hwy::HWY_NAMESPACE;
using T = float;
void test(const T* HWY_RESTRICT mul_array,
const T* HWY_RESTRICT add_array,
const size_t size, T* HWY_RESTRICT x_array) {
const hn::ScalableTag<T> d;
for (size_t i = 0; i < size; i += hn::Lanes(d)) {
const auto mul = hn::Load(d, mul_array + i);
const auto add = hn::Load(d, add_array + i);
auto x = hn::Load(d, x_array + i);
x = hn::MulAdd(mul, x, add);
hn::Store(x, d, x_array + i);
}
}
]]}, {configs = {languages = "c++11"}}))
end)

0 comments on commit df27d39

Please sign in to comment.