Skip to content

Commit 4c29bcb

Browse files
cho-mBrewTestBot
authored andcommitted
pocl 3.0 (new formula)
Closes #103141. Signed-off-by: Daniel Nachun <[email protected]> Signed-off-by: BrewTestBot <[email protected]>
1 parent 2fb88a1 commit 4c29bcb

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

Formula/pocl.rb

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
class Pocl < Formula
2+
desc "Portable Computing Language"
3+
homepage "http://portablecl.org"
4+
url "http://portablecl.org/downloads/pocl-3.0.tar.gz"
5+
sha256 "a3fd3889ef7854b90b8e4c7899c5de48b7494bf770e39fba5ad268a5cbcc719d"
6+
license "MIT"
7+
head "https://github.com/pocl/pocl.git", branch: "master"
8+
9+
depends_on "cmake" => :build
10+
depends_on "opencl-headers" => :build
11+
depends_on "pkg-config" => :build
12+
depends_on "hwloc"
13+
depends_on "llvm"
14+
depends_on "ocl-icd"
15+
16+
on_linux do
17+
depends_on "gcc"
18+
end
19+
20+
fails_with gcc: "5" # LLVM is built with GCC
21+
22+
def install
23+
# Install the ICD into #{prefix}/etc rather than #{etc} as it contains the realpath
24+
# to the shared library and needs to be kept up-to-date to work with an ICD loader.
25+
# This relies on `brew link` automatically creating and updating #{etc} symlinks.
26+
args = %W[
27+
-DPOCL_INSTALL_ICD_VENDORDIR=#{prefix}/etc/OpenCL/vendors
28+
-DCMAKE_INSTALL_RPATH=#{lib};#{lib}/pocl
29+
-DENABLE_EXAMPLES=OFF
30+
-DENABLE_TESTS=OFF
31+
-DLLVM_BINDIR=#{Formula["llvm"].opt_bin}
32+
]
33+
# Avoid installing another copy of OpenCL headers on macOS
34+
args << "-DOPENCL_H=#{Formula["opencl-headers"].opt_include}/CL/opencl.h" if OS.mac?
35+
# Only x86_64 supports "distro" which allows runtime detection of SSE/AVX
36+
args << "-DKERNELLIB_HOST_CPU_VARIANTS=distro" if Hardware::CPU.intel?
37+
38+
system "cmake", "-S", ".", "-B", "build", *std_cmake_args, *args
39+
system "cmake", "--build", "build"
40+
system "cmake", "--install", "build"
41+
(pkgshare/"examples").install "examples/poclcc"
42+
end
43+
44+
test do
45+
ENV["OCL_ICD_VENDORS"] = "pocl.icd" # Ignore any other ICD that may be installed
46+
cp pkgshare/"examples/poclcc/poclcc.cl", testpath
47+
system bin/"poclcc", "-o", "poclcc.cl.pocl", "poclcc.cl"
48+
assert_predicate testpath/"poclcc.cl.pocl", :exist?
49+
# Make sure that CMake found our OpenCL headers and didn't install a copy
50+
refute_predicate include/"OpenCL", :exist?
51+
end
52+
end

0 commit comments

Comments
 (0)