onedpl add fetch.lua (#4324)

* Update onedpl xmake.lua

* Create fetch.lua

* Update xmake.lua

rc1

* Update xmake.lua

/* MACROS DUE TO 3b9a1bb1af (diff-4c6821476cefc699b801f5fdbeda3341e3c64626dcf39a79621ea02031bdd50eL113) */
            /* ALSO C.F. https://github.com/oneapi-src/oneDPL/issues/1602 */
            /* AND THE USING OF _PSTL_... MACROS IS REMOVED FROM ONEDPL NOWADAYS*/

* Update xmake.lua

typo

* Update xmake.lua

* bad ci ; try again

ci on arch linux failed due to network error

* Update xmake.lua

* Refine config

* refine fetch.lua

remove unnecessary add_deps

* Update xmake.lua

* minor formatting refinement
pull/4334/head
Altina Orion 6 months ago committed by GitHub
parent e9e06e9159
commit b8fe8398a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 44
      packages/o/onedpl/fetch.lua
  2. 24
      packages/o/onedpl/xmake.lua

@ -0,0 +1,44 @@
import("lib.detect.find_path")
import("lib.detect.find_library")
function _find_package(package, opt)
local paths = {
"$(env DPL_ROOT)",
"$(env ONEAPI_ROOT)/dpl/latest"
}
-- find library
local result = {links = {}, linkdirs = {}, includedirs = {}}
-- find include
local includepath = find_path(path.join("oneapi", "dpl", "algorithm"), paths, {suffixes = "include"})
if includepath then
table.insert(result.includedirs, includepath)
end
if #result.includedirs > 0 then
local version_file = path.join(includepath, "oneapi", "dpl", "pstl", "onedpl_config.h")
if os.isfile(version_file) then
local content = io.readfile(version_file)
local major = content:match("ONEDPL_VERSION_MAJOR +(%d+)\n")
local minor = content:match("ONEDPL_VERSION_MINOR +(%d+)\n")
local patch = content:match("ONEDPL_VERSION_PATCH +(%d+)\n")
if patch then
result.version = format("%s.%s.%s", major, minor, patch)
else
result.version = format("%s.%s", major, minor)
end
end
return result
end
end
function main(package, opt)
if opt.system and package.find_package then
local result = _find_package(package, opt)
if not result then
result = package:find_package("onedpl", opt)
end
return result or false
end
end

@ -4,18 +4,37 @@ package("onedpl")
set_homepage("https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-library.html")
set_description("oneAPI DPC++ Library")
add_urls("https://github.com/oneapi-src/oneDPL/archive/refs/tags/oneDPL-$(version).tar.gz")
add_urls("https://github.com/oneapi-src/oneDPL/archive/refs/tags/oneDPL-$(version)-release.tar.gz")
add_versions("2021.6.1", "4995fe2ed2724b89cdb52c4b6c9af22e146b48d2561abdafdaaa06262dbd67c4")
add_versions("2022.5.0-rc1", "9180c60331ec5b307dd89a5d8bfcd096667985c6761c52322405d4b69193ed88")
add_configs("backend", {description = "Choose threading backend.", default = "tbb", type = "string", values = {"tbb", "dpcpp", "dpcpp_only", "omp", "serial"}})
add_deps("cmake")
on_fetch("fetch")
on_load("windows", "linux", function (package)
local backend = package:config("backend")
if backend == "tbb" or backend == "dpcpp" then
if backend == "tbb" then
package:add("deps", "tbb")
package:add("defines", "ONEDPL_USE_TBB_BACKEND=1")
package:add("ldflags", "-ltbb")
elseif backend == "omp" then
package:add("deps", "openmp")
package:add("defines", "ONEDPL_USE_OPENMP_BACKEND=1")
elseif backend == "dpcpp" then
package:add("deps", "tbb")
package:add("ldflags", "-ltbb")
package:add("defines", "ONEDPL_USE_TBB_BACKEND=1")
package:add("defines", "ONEDPL_USE_DPCPP_BACKEND=1")
elseif backend == "dpcpp_only" then
package:add("defines", "ONEDPL_USE_TBB_BACKEND=0")
package:add("defines", "ONEDPL_USE_DPCPP_BACKEND=1")
elseif backend == "serial" then
package:add("defines", "ONEDPL_USE_OPENMP_BACKEND=0")
package:add("defines", "ONEDPL_USE_TBB_BACKEND=0")
package:add("defines", "ONEDPL_USE_DPCPP_BACKEND=0")
end
if package:is_plat("windows") then
package:add("cxxflags", "/Zc:__cplusplus")
@ -24,6 +43,9 @@ package("onedpl")
on_install("windows", "linux", function (package)
io.replace("CMakeLists.txt", "add_subdirectory(test)", "", {plain = true})
-- c.f. https://github.com/oneapi-src/oneDPL/issues/1602 and https://github.com/oneapi-src/oneDPL/commit/e25afef957b50536c5091ed23150fff10921b18f
io.replace("include/oneapi/dpl/pstl/algorithm_impl.h", "(_PSTL_UDR_PRESENT || _ONEDPL_UDR_PRESENT)", "_ONEDPL_UDR_PRESENT // _PSTL_UDR_PRESENT", {plain = true})
io.replace("include/oneapi/dpl/pstl/numeric_impl.h", "(_PSTL_UDS_PRESENT || _ONEDPL_UDS_PRESENT)", "_ONEDPL_UDS_PRESENT // PSTL_UDS_PRESENT", {plain = true})
local configs = {}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DONEDPL_BACKEND=" .. package:config("backend"))

Loading…
Cancel
Save