xmake.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("kokkos-kernels")
  2. set_homepage("https://github.com/kokkos/kokkos-kernels")
  3. set_description("Kokkos C++ Performance Portability Programming EcoSystem: Math Kernels")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/kokkos/kokkos-kernels/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/kokkos/kokkos-kernels.git")
  7. add_versions("4.0.01", "3f493fcb0244b26858ceb911be64092fbf7785616ad62c81abde0ea1ce86688a")
  8. if is_plat("windows") then
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. end
  11. add_configs("cuda", {description = "Enable CUDA support.", default = false, type = "boolean"})
  12. add_deps("cmake")
  13. on_load("windows|x64", "macosx", "linux", function (package)
  14. if package:config("cuda") then
  15. package:add("deps", "cuda")
  16. package:add("deps", "kokkos", {configs = {cuda = true}})
  17. else
  18. package:add("deps", "kokkos")
  19. end
  20. end)
  21. on_install("windows|x64", "macosx", "linux", function (package)
  22. if package:is_plat("windows") then
  23. local vs = import("core.tool.toolchain").load("msvc"):config("vs")
  24. if tonumber(vs) < 2022 then
  25. raise("Your compiler is too old to use this library.")
  26. end
  27. end
  28. local configs = {}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. if package:config("cuda") then
  32. table.insert(configs, "-DKokkosKernels_REQUIRE_DEVICES=CUDA")
  33. end
  34. import("package.tools.cmake").install(package, configs, {buildir = path.join(os.tmpdir(), "kk-build")})
  35. end)
  36. on_test(function (package)
  37. assert(package:check_cxxsnippets({test = [[
  38. #include <Kokkos_Core.hpp>
  39. #include <KokkosSparse_MatrixPrec.hpp>
  40. #include <KokkosSparse_IOUtils.hpp>
  41. void test() {
  42. using EXSP = Kokkos::DefaultExecutionSpace;
  43. using MESP = typename EXSP::memory_space;
  44. using CRS = KokkosSparse::CrsMatrix<double, int, Kokkos::Device<EXSP, MESP>, void, int>;
  45. Kokkos::initialize();
  46. CRS A = KokkosSparse::Impl::kk_generate_diag_matrix<CRS>(1000);
  47. }
  48. ]]}, {configs = {languages = "c++17"}}))
  49. end)