Add ruy (#2048)
* Add ruy * Set language version * Remove on_load * Disable shared on windows * Set warnings and vectorexts * add_vectorextspull/2051/head
parent
34fd43d966
commit
b69b9581ba
2 changed files with 86 additions and 0 deletions
@ -0,0 +1,38 @@ |
||||
add_rules("mode.debug", "mode.releasedbg", "mode.release") |
||||
add_requires("cpuinfo") |
||||
|
||||
option("profiler", { default = false, description = "Enable ruy's built-in profiler (harms performance)" }) |
||||
|
||||
set_languages("cxx14") |
||||
|
||||
target("ruy") |
||||
set_kind("$(kind)") |
||||
|
||||
add_files("ruy/**.cc") |
||||
remove_files("ruy/test*.cc", "ruy/*test.cc") |
||||
remove_files("ruy/profiler/test*.cc") |
||||
remove_files("ruy/benchmark.cc") |
||||
|
||||
remove_files("ruy/profiler/test*.cc") |
||||
remove_files("ruy/profiler/test.cc") |
||||
|
||||
add_headerfiles("(ruy/**.h)") |
||||
remove_headerfiles("ruy/gtest_wrapper.h") |
||||
remove_headerfiles("ruy/profiler/test*.h") |
||||
|
||||
add_includedirs(".") |
||||
set_optimize("fastest") |
||||
|
||||
add_packages("cpuinfo") |
||||
|
||||
if is_arch("arm.*") then |
||||
add_vectorexts("neon") |
||||
end |
||||
|
||||
if not is_plat("windows") then |
||||
set_warnings("all", "extra") |
||||
end |
||||
|
||||
if has_config("profiler") then |
||||
add_defines("RUY_PROFILE") |
||||
end |
@ -0,0 +1,48 @@ |
||||
package("ruy") |
||||
set_homepage("https://github.com/google/ruy") |
||||
set_description("Matrix multiplication library") |
||||
set_license("Apache-2.0") |
||||
|
||||
set_urls("https://github.com/google/ruy.git") |
||||
add_versions("2022.09.16", "3168a5c8f4c447fd8cea94078121ee2e2cd87df0") |
||||
|
||||
add_deps("cpuinfo") |
||||
|
||||
add_configs("profiler", { description = "Enable ruy's built-in profiler (harms performance)", default = false, type = "boolean" }) |
||||
if is_plat("windows") then |
||||
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) |
||||
add_configs("vs_runtime", {description = "Set vs compiler runtime.", default = "MT", readonly = true}) |
||||
end |
||||
|
||||
on_install("windows", "linux", "macosx", "android", function (package) |
||||
os.cp(path.join(os.scriptdir(), "port", "xmake.lua"), "xmake.lua") |
||||
os.rm("BUILD") |
||||
local configs = {} |
||||
configs.profiler = package:config("profiler") |
||||
|
||||
import("package.tools.xmake").install(package, configs) |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:check_cxxsnippets({test = [[ |
||||
void test(int args, char** argv) { |
||||
ruy::Context context; |
||||
const float lhs_data[] = {1, 2, 3, 4}; |
||||
const float rhs_data[] = {1, 2, 3, 4}; |
||||
float dst_data[4]; |
||||
|
||||
ruy::Matrix<float> lhs; |
||||
ruy::MakeSimpleLayout(2, 2, ruy::Order::kRowMajor, lhs.mutable_layout()); |
||||
lhs.set_data(lhs_data); |
||||
ruy::Matrix<float> rhs; |
||||
ruy::MakeSimpleLayout(2, 2, ruy::Order::kColMajor, rhs.mutable_layout()); |
||||
rhs.set_data(rhs_data); |
||||
ruy::Matrix<float> dst; |
||||
ruy::MakeSimpleLayout(2, 2, ruy::Order::kColMajor, dst.mutable_layout()); |
||||
dst.set_data(dst_data); |
||||
|
||||
ruy::MulParams<float, float> mul_params; |
||||
ruy::Mul(lhs, rhs, mul_params, &context, &dst); |
||||
} |
||||
]]}, {configs = {languages = "c++14"}, includes = "ruy/ruy.h"})) |
||||
end) |
Loading…
Reference in new issue