xmake.lua 2.5 KB

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