xmake.lua 3.4 KB

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