-
| I discovered this OpenCL SDK and I'm wonder if this could integrated in the opencl package as a fallback if a GPU vendor SDK is not found. I modified the opencl package as follows: package("opencl") set_homepage("https://opencl.org/") set_description("OpenCL is an open, royalty-free industry standard that makes much faster computations possible through parallel computing.") set_urls("https://github.com/KhronosGroup/OpenCL-SDK.git") add_versions("v2023.04.17", "ae7fcae82fe0b7bcc272e43fc324181b2d544eea") add_configs("vendor", {description = "Set OpenCL Vendor.", default = nil, type = "string", values = {"nvidia", "intel", "amd"}}) set_policy("platform.longpaths", true) on_fetch(function (package, opt) if opt.system then import("lib.detect.find_path") import("lib.detect.find_library") import("detect.sdks.find_cuda") local result = {includedirs = {}, linkdirs = {}, links = {"OpenCL"}} local vendor = package:config("vendor") local archsuffixes = {"lib"} if package:is_arch("x64") then table.insert(archsuffixes, "lib64") table.insert(archsuffixes, path.join("lib", "x64")) elseif package:is_arch("x86", "i386") then table.insert(archsuffixes, path.join("lib", "x86")) elseif package:is_arch("x86_64") then table.insert(archsuffixes, "lib64") table.insert(archsuffixes, path.join("lib", "x86_64")) end if not vendor or vendor == "nvidia" then local cuda = find_cuda() if cuda then result.includedirs = cuda.includedirs result.linkdirs = cuda.linkdirs return result elseif vendor == "nvidia" then return nil end elseif not vendor or vendor == "intel" then local intelsdkpaths = {"$(env INTELOCLSDKROOT)"} local linkinfo = find_library("OpenCL", intelsdkpaths, {suffixes = archsuffixes}) if linkinfo then table.insert(result.linkdirs, linkinfo.linkdir) local incpath = find_path(path.join("CL", "cl.h"), intelsdkpaths, {suffixes = {"include"}}) if incpath then table.insert(result.includedirs, incpath) return result end end if vendor == "intel" then return nil end elseif not vendor or vendor == "amd" then local amdsdkpaths = {"$(env AMDAPPSDKROOT)"} local linkinfo = find_library("OpenCL", amdsdkpaths, {suffixes = archsuffixes}) if linkinfo then table.insert(result.linkdirs, linkinfo.linkdir) local incpath = find_path(path.join("CL", "cl.h"), amdsdkpaths, {suffixes = {"include"}}) if incpath then table.insert(result.includedirs, incpath) return result end end if vendor == "amd" then return nil end end end end) on_install("windows", "linux", "macosx", function (package,opt) local configs = {} table.insert(configs, "-DOPENCL_SDK_BUILD_SAMPLES=OFF") import("package.tools.cmake").install(package, configs) end)But how to download and install if an GPU vendor is not found ? |
Beta Was this translation helpful? Give feedback.
Answered by waruqi Jun 29, 2023
Replies: 1 comment
-
| on_install will install it |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by A2va
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
on_install will install it