Forráskód Böngészése

add superlu (#412)

* fix tbb and mkl

* improve openvdb

* add superlu

* fix superlu

* export all symbols to enable dll build
Hoildkv 4 éve
szülő
commit
dd89da5d76

+ 6 - 16
packages/m/mkl/fetch.lua

@@ -24,22 +24,12 @@ function _find_package(package, opt)
     end
 
     local threading = package:config("threading")
-    if threading then
-        if threading == "tbb" then
-            table.join2(result.links, {"mkl_tbb_thread", "mkl_core"})
-            package:add("deps", "tbb")
-        elseif threading == "seq" then
-            table.join2(result.links, {"mkl_sequential", "mkl_core"})
-        elseif threading == "openmp" then
-            table.join2(result.links, {"mkl_intel_thread", "mkl_core"})
-        end
-    else
-        if find_package("tbb") then
-            table.join2(result.links, {"mkl_tbb_thread", "mkl_core"})
-            package:add("deps", "tbb")
-        else
-            table.join2(result.links, {"mkl_sequential", "mkl_core"})
-        end
+    if threading == "tbb" then
+        table.join2(result.links, {"mkl_tbb_thread", "mkl_core"})
+    elseif threading == "seq" then
+        table.join2(result.links, {"mkl_sequential", "mkl_core"})
+    elseif threading == "openmp" then
+        table.join2(result.links, {"mkl_intel_thread", "mkl_core"})
     end
 
     -- find include

+ 8 - 18
packages/m/mkl/xmake.lua

@@ -29,7 +29,7 @@ package("mkl")
         end
     end
 
-    add_configs("threading", {description = "Choose threading modal for mkl.", default = nil, type = "string", values = {"tbb", "openmp", "seq"}})
+    add_configs("threading", {description = "Choose threading modal for mkl.", default = "tbb", type = "string", values = {"tbb", "openmp", "seq"}})
 
     on_fetch("fetch")
 
@@ -44,24 +44,14 @@ package("mkl")
         end
 
         local threading = package:config("threading")
-        if threading then
-            if threading == "tbb" then
-                package:add("links", "mkl_tbb_thread")
-                package:add("deps", "tbb")
-            elseif threading == "seq" then
-                package:add("links", "mkl_sequential")
-            elseif threading == "openmp" then
-                package:add("links", "mkl_intel_thread")
-            end
-        else
-            if find_package("tbb") then
-                package:add("links", "mkl_tbb_thread")
-                package:add("deps", "tbb")
-            else
-                package:add("links", "mkl_sequential")
-            end
+        if threading == "tbb" then
+            package:add("links", "mkl_tbb_thread")
+            package:add("deps", "tbb")
+        elseif threading == "seq" then
+            package:add("links", "mkl_sequential")
+        elseif threading == "openmp" then
+            package:add("links", "mkl_intel_thread")
         end
-
         package:add("links", "mkl_core")
     end)
 

+ 1 - 0
packages/o/openvdb/xmake.lua

@@ -72,6 +72,7 @@ package("openvdb")
             table.insert(configs, "-DUSE_EXR=ON")
         end
         import("package.tools.cmake").install(package, configs)
+        package:addenv("PATH", "bin")
     end)
 
     on_test(function (package)

+ 39 - 0
packages/s/superlu/xmake.lua

@@ -0,0 +1,39 @@
+package("superlu")
+
+    set_homepage("https://portal.nersc.gov/project/sparse/superlu/")
+    set_description("SuperLU is a general purpose library for the direct solution of large, sparse, nonsymmetric systems of linear equations.")
+    set_license("BSD-3-Clause")
+
+    add_urls("https://github.com/xiaoyeli/superlu/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/xiaoyeli/superlu.git")
+    add_versions("v5.2.2", "470334a72ba637578e34057f46948495e601a5988a602604f5576367e606a28c")
+
+    add_configs("blas_vendor", {description = "Set BLAS vendor.", default = "mkl", type = "string", values = {"mkl", "openblas"}})
+
+    on_load("windows", "linux", "macosx", function (package)
+        package:add("deps", package:config("blas_vendor"))
+    end)
+
+    on_install("windows", "linux", "macosx", function (package)
+        os.cd("SRC")
+        io.writefile("xmake.lua", format([[
+            add_rules("mode.debug", "mode.release")
+            add_requires("%s")
+            target("superlu")
+                set_kind("$(kind)")
+                add_defines("USE_VENDOR_BLAS")
+                if is_plat("windows") and is_kind("shared") then
+                    add_rules("utils.symbols.export_all")
+                end
+                add_files("*.c")
+                add_includedirs(".")
+                add_headerfiles("*.h")
+                add_packages("%s")
+        ]], package:config("blas_vendor"), package:config("blas_vendor")))
+        local configs = {kind = package:config("shared") and "shared" or "static"}
+        import("package.tools.xmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("dCreate_Dense_Matrix", {includes = "slu_ddefs.h"}))
+    end)

+ 7 - 7
packages/t/tbb/fetch.lua

@@ -18,16 +18,15 @@ function _find_package_on_windows(package, opt)
         end
     end
     result.linkdirs = table.unique(result.linkdirs)
-    local path = find_path(path.join("tbb", "tbb.h"), paths, {suffixes = "include"})
-    if path then
-        table.insert(result.includedirs, path)
+    local incpath = find_path(path.join("tbb", "tbb.h"), paths, {suffixes = "include"})
+    if incpath then
+        table.insert(result.includedirs, incpath)
     end
 
     if #result.includedirs > 0 and #result.linkdirs > 0 then
-        local root = result.includedirs[1]
-        local version_file = path.join(root, "oneapi", "tbb", "version.h")
+        local version_file = path.join(incpath, "oneapi", "tbb", "version.h")
         if not os.isfile(version_file) then
-            version_file = path.join(root, "tbb", "tbb_stddef.h")
+            version_file = path.join(incpath, "tbb", "tbb_stddef.h")
         end
         if os.isfile(version_file) then
             local content = io.readfile(version_file)
@@ -50,7 +49,8 @@ function main(package, opt)
         local result
         if package:is_plat("windows") then
             result = _find_package_on_windows(package, opt)
-        else
+        end
+        if not result then
             result = package:find_package("tbb", opt)
         end
         return result or false

+ 14 - 0
packages/t/tbb/patches/2021.2.0/gcc11.patch

@@ -0,0 +1,14 @@
+diff --git a/src/tbb/scheduler_common.h b/src/tbb/scheduler_common.h
+index ee13dbf9..49052001 100644
+--- a/src/tbb/scheduler_common.h
++++ b/src/tbb/scheduler_common.h
+@@ -219,7 +219,7 @@ inline void prolonged_pause_impl() {
+ #endif
+ 
+ inline void prolonged_pause() {
+-#if __TBB_WAITPKG_INTRINSICS_PRESENT && (_WIN32 || _WIN64 || __linux__) && (__TBB_x86_32 || __TBB_x86_64)
++#if 0
+     if (governor::wait_package_enabled()) {
+         std::uint64_t time_stamp = machine_time_stamp();
+         // _tpause function directs the processor to enter an implementation-dependent optimized state
+ 

+ 2 - 0
packages/t/tbb/xmake.lua

@@ -13,6 +13,8 @@ package("tbb")
         add_versions("2020.3", "ebc4f6aa47972daed1f7bf71d100ae5bf6931c2e3144cf299c8cc7d041dca2f3")
         add_versions("2021.2.0", "cee20b0a71d977416f3e3b4ec643ee4f38cedeb2a9ff015303431dd9d8d79854")
 
+        add_patches("2021.2.0", path.join(os.scriptdir(), "patches", "2021.2.0", "gcc11.patch"), "181511cf4878460cb48ac0531d3ce8d1c57626d698e9001a0951c728fab176fb")
+
         if is_plat("macosx") then
             add_configs("compiler", {description = "Compiler used to compile tbb." , default = "clang", type = "string", values = {"clang", "gcc", "icc", "cl", "icl", "[others]"}})
         else