xmake.lua 3.5 KB

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