Skip to content

pocl 3.0 (new formula) #103141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions Formula/pocl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
class Pocl < Formula
desc "Portable Computing Language"
homepage "http://portablecl.org"
url "http://portablecl.org/downloads/pocl-3.0.tar.gz"
sha256 "a3fd3889ef7854b90b8e4c7899c5de48b7494bf770e39fba5ad268a5cbcc719d"
license "MIT"
head "https://github.com/pocl/pocl.git", branch: "master"

depends_on "cmake" => :build
depends_on "opencl-headers" => :build
depends_on "pkg-config" => :build
depends_on "hwloc"
depends_on "llvm"
depends_on "ocl-icd"

on_linux do
depends_on "gcc"
end

fails_with gcc: "5" # LLVM is built with GCC

def install
# Install the ICD into #{prefix}/etc rather than #{etc} as it contains the realpath
# to the shared library and needs to be kept up-to-date to work with an ICD loader.
# This relies on `brew link` automatically creating and updating #{etc} symlinks.
args = %W[
-DPOCL_INSTALL_ICD_VENDORDIR=#{prefix}/etc/OpenCL/vendors
-DCMAKE_INSTALL_RPATH=#{lib};#{lib}/pocl
-DENABLE_EXAMPLES=OFF
-DENABLE_TESTS=OFF
-DLLVM_BINDIR=#{Formula["llvm"].opt_bin}
]
# Avoid installing another copy of OpenCL headers on macOS
args << "-DOPENCL_H=#{Formula["opencl-headers"].opt_include}/CL/opencl.h" if OS.mac?
# Only x86_64 supports "distro" which allows runtime detection of SSE/AVX
args << "-DKERNELLIB_HOST_CPU_VARIANTS=distro" if Hardware::CPU.intel?

system "cmake", "-S", ".", "-B", "build", *std_cmake_args, *args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
(pkgshare/"examples").install "examples/poclcc"
end

test do
ENV["OCL_ICD_VENDORS"] = "pocl.icd" # Ignore any other ICD that may be installed
cp pkgshare/"examples/poclcc/poclcc.cl", testpath
system bin/"poclcc", "-o", "poclcc.cl.pocl", "poclcc.cl"
assert_predicate testpath/"poclcc.cl.pocl", :exist?
# Make sure that CMake found our OpenCL headers and didn't install a copy
refute_predicate include/"OpenCL", :exist?
end
end