diff --git a/lang/pocl/Makefile b/lang/pocl/Makefile index a13e9e87c3ca..42a411b8e653 100644 --- a/lang/pocl/Makefile +++ b/lang/pocl/Makefile @@ -1,70 +1,142 @@ PORTNAME= pocl DISTVERSIONPREFIX= v -DISTVERSION= 4.0 +DISTVERSION= 7.0 CATEGORIES= lang MAINTAINER= ohartmann@walstatt.org COMMENT= POrtable Computing Language (POCL) -WWW= http://portablecl.org/ +WWW= https://portablecl.org/docs/html LICENSE= MIT LICENSE_FILE= ${WRKSRC}/LICENSE -ONLY_FOR_ARCHS= aarch64 amd64 i386 powerpc64 powerpc64le +ONLY_FOR_ARCHS= aarch64 amd64 powerpc64 powerpc64le ONLY_FOR_ARCHS_REASON= only tested on ${ONLY_FOR_ARCHS:tW:S/ /, /g} -BROKEN_i386= Unable to access file /wrkdirs/usr/ports/lang/pocl/work/stage/usr/local/share/pocl/kernel-i386-portbld-freebsd13.0-avx.bc:No such file or directory -BUILD_DEPENDS= llvm${LLVM_VERSION}>=14:devel/llvm${LLVM_VERSION} \ - opencl>=3:devel/opencl -LIB_DEPENDS= libhwloc.so:devel/hwloc2 libOpenCL.so:devel/ocl-icd +BUILD_DEPENDS= clang${LLVM_VER}:devel/llvm${LLVM_VER} \ + opencl>=3:devel/opencl \ + spirv-llvm-translator-llvm${LLVM_VER}>=${LLVM_VER}:devel/spirv-llvm-translator@llvm${LLVM_VER} \ + spirv-tools>0:graphics/spirv-tools -USES= cmake localbase:ldflags ncurses pkgconfig +LIB_DEPENDS= libhwloc.so:devel/hwloc2 \ + libLLVM-${LLVM_VER}.so:devel/llvm${LLVM_VER} \ + libOpenCL.so:devel/ocl-icd +RUN_DEPENDS= ${BUILD_DEPENDS} + +USES= cmake:noninja gmake localbase:ldflags ncurses pkgconfig python USE_GITHUB= yes USE_LDCONFIG= yes -LLVM_VERSION= ${MESA_LLVM_VER:U16} -CMAKE_ARGS= -DWITH_LLVM_CONFIG="${LOCALBASE}/llvm${LLVM_VERSION}/bin/llvm-config" \ +LLVM_VER= 20 +CMAKE_ARGS= ${CMAKE_ARGS_${ARCH}} \ + -DENABLE_HOST_CPU_DEVICES=ON \ + -DENABLE_HOST_CPU_DEVICES_OPENMP=ON \ + -DENABLE_ICD=ON \ + -DENABLE_LATEST_CXX_STD=YES \ + -DENABLE_POCL_BUILDING=OFF \ + -DENABLE_SPIRV=ON \ + -DHAVE_OCL_ICD_30_COMPATIBLE=ON \ + -DHOST_COMPILER_SUPPORTS_FLOAT16:BOOL=OFF \ + -DKERNELLIB_HOST_CPU_VARIANTS=distro \ + -DLLVM_CONFIG_LOCATION=${LOCALBASE}/bin/llvm-config${LLVM_VER}/ \ + -DPOCL_ICD_ABSOLUTE_PATH=ON \ -DPOCL_INSTALL_PKGCONFIG_DIR="${PREFIX}/libdata/pkgconfig" \ - -DSINGLE_LLVM_LIB=ON \ - ${CMAKE_ARGS_${ARCH}} + -DWITH_LLVM_CONFIG="${LOCALBASE}/llvm${LLVM_VER}/bin/llvm-config" CMAKE_ARGS_aarch64= -DLLC_HOST_CPU=cortex-a53 -CMAKE_ARGS_powerpc64= -DLLC_HOST_CPU=ppc64 -CMAKE_ARGS_powerpc64le= -DLLC_HOST_CPU=ppc64le -CMAKE_ARGS_amd64= -DKERNELLIB_HOST_CPU_VARIANTS="distro" +CMAKE_ARGS_powerpc64= -DLLC_HOST_CPU=ppc64 \ + -DKERNELLIB_HOST_CPU_VARIANTS=distro +CMAKE_ARGS_powerpc64le= -DLLC_HOST_CPU=ppc64le \ + -DKERNELLIB_HOST_CPU_VARIANTS=distro +CMAKE_ARGS_amd64= -DKERNELLIB_HOST_CPU_VARIANTS=distro PLIST_SUB= CONFIGURE_TARGET=${CONFIGURE_TARGET:S/amd64/x86_64/} -OPTIONS_DEFINE= DOCS +OPTIONS_DEFINE= CONFORMANCE DEBUG DOCS DOCS_PDF LTTNG OMP REMOTE \ + SHARED_LIBS STATIC_LLVM TESTS +OPTIONS_DEFAULT= OMP SHARED_LIBS TESTS +OPTIONS_SUB= yes + +CONFORMANCE_DESC= Conformant pocl build (defaults to OFF) +DEBUG_DESC= Build POCL with DEBUG messages +DOCS_DESC= Build documentation (needs textproc/py-sphinx) +DOCS_PDF_DESC= Build PDF alongside with standard HTML docs +LTTNG_DESC= Trace both server and client lib with lttng +OMP_DESC= Enable OpenMP on CPU driver +REMOTE_DESC= Enable pocld, a remote server +SHARED_LIBS_DESC= Build shared libs +STATIC_LLVM_DESC= Have static libLLVM +TESTS_DESC= Enable compilation of internal tests + +CONFORMANCE_CMAKE_ON= -DENABLE_CONFORMANCE=ON +CONFORMANCE_CMAKE_OFF= -DENABLE_CONFORMANCE=OFF + +DEBUG_CMAKE_ON= -DPOCL_DEBUG_MESSAGES=ON +DEBUG_CMAKE_OFF= -DPOCL_DEBUG_MESSAGES=OFF -DOCS_DESC= Build documentation (needs textproc/py-sphinx) -DOCS_CMAKE_ON= -DENABLE_DOCS=ON -DOCS_CMAKE_OFF= -DENABLE_DOCS=OFF -DOCS_USES= python DOCS_BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}sphinx>=0:textproc/py-sphinx@${PY_FLAVOR} +DOCS_CMAKE_ON= -DENABLE_DOCS=ON +DOCS_CMAKE_OFF= -DENABLE_DOCS=OFF + +DOCS_PDF_IMPLIES= DOCS +DOCS_PDF_BROKEN= TeX error: Unicode character ≈ (U+2248) not set up for use with LaTeX. + +LTTNG_LIB_DEPENDS= liblttng-ust.so:sysutils/lttng-ust +LTTNG_CMAKE_ON= -DENABLE_LTTNG=YES +LTTNG_CMAKE_OFF= -DENABLE_LTTNG=NO + +OMP_CMAKE_ON= -DENABLE_HOST_CPU_DEVICES_OPENMP=YES +OMP_CMAKE_OFF= -DENABLE_HOST_CPU_DEVICES_OPENMP=NO + +REMOTE_BROKEN= Not compiling. FreeBSD lacks sockettype AF_VSOCK +REMOTE_CMAKE_ON= -DENABLE_REMOTE_SERVER=ON +REMOTE_CMAKE_OFF= -DENABLE_REMOTE_SERVER=OFF + +SHARED_LIBS_CMAKE_ON= -DBUILD_SHARED_LIBS=ON +SHARED_LIBS_CMAKE_OFF= -DBUILD_SHARED_LIBS=OFF + +STATIC_LLVM_CMAKE_ON= -DSTATIC_LLVM_LLVM=ON +STATIC_LLVM_CMAKE_OFF= -DSTATIC_LLVM_LLVM=OFF + +TESTS_CMAKE_ON= -DENABLE_TESTS=ON +TESTS_CMAKE_OFF= -DENABLE_TESTS=OFF + +do-build-DOCS-on: + ${SETENVI} ${WRK_ENV} ${MAKE_ENV} ${MAKE_CMD} -C ${WRKSRC}/doc/sphinx html dirhtml +do-build-DOCS_PDF-on: + ${SETENVI} ${WRK_ENV} ${MAKE_ENV} ${MAKE_CMD} -C ${WRKSRC}/doc/sphinx latex + ${SETENVI} ${WRK_ENV} ${MAKE_ENV} ${MAKE_CMD} -C ${WRKSRC}/doc/sphinx/build/latex all-pdf +post-install-DOCS-on: + ${MKDIR} ${STAGEDIR}${DOCSDIR} + ${MKDIR} ${STAGEDIR}${DOCSDIR}/html + ${INSTALL_DATA} ${WRKSRC}/doc/sphinx/build/html/*.html ${STAGEDIR}${DOCSDIR}/html/ +post-install-DOCS_PDF-on: + ${MKDIR} ${STAGEDIR}${DOCSDIR} + ${MKDIR} ${STAGEDIR}${DOCSDIR}/html + ${INSTALL_DATA} ${WRKSRC}/doc/sphinx/build/latex/*.pdf ${STAGEDIR}${DOCSDIR} .include .if ${ARCH} == aarch64 -PLIST_SUB+= AARCH64="" -PLIST_SUB+= PPC64="@comment " -PLIST_SUB+= PPC64LE="@comment " -PLIST_SUB+= X86="@comment " +PLIST_SUB+= AARCH64="" \ + PPC64="@comment " \ + PPC64LE="@comment " \ + X86="@comment " .elif ${ARCH} == amd64 || ${ARCH} == i386 -PLIST_SUB+= AARCH64="@comment " -PLIST_SUB+= PPC64="@comment " -PLIST_SUB+= PPC64LE="@comment " -PLIST_SUB+= X86="" +PLIST_SUB+= AARCH64="@comment " \ + PPC64="@comment " \ + PPC64LE="@comment " \ + X86="" .elif ${ARCH} == powerpc64 -PLIST_SUB+= AARCH64="@comment " -PLIST_SUB+= PPC64="" -PLIST_SUB+= PPC64LE="@comment " -PLIST_SUB+= X86="@comment " +PLIST_SUB+= AARCH64="@comment " \ + PPC64="" \ + PPC64LE="@comment " \ + X86="@comment " .else -PLIST_SUB+= AARCH64="@comment " -PLIST_SUB+= PPC64="@comment " -PLIST_SUB+= PPC64LE="" -PLIST_SUB+= X86="@comment " +PLIST_SUB+= AARCH64="@comment " \ + PPC64="@comment " \ + PPC64LE="" \ + X86="@comment " .endif .include diff --git a/lang/pocl/distinfo b/lang/pocl/distinfo index aaa5e1c12075..8860b0ec290e 100644 --- a/lang/pocl/distinfo +++ b/lang/pocl/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1687856826 -SHA256 (pocl-pocl-v4.0_GH0.tar.gz) = 7f4e8ab608b3191c2b21e3f13c193f1344b40aba7738f78762f7b88f45e8ce03 -SIZE (pocl-pocl-v4.0_GH0.tar.gz) = 2140919 +TIMESTAMP = 1748010431 +SHA256 (pocl-pocl-v7.0_GH0.tar.gz) = f55caba8c3ce12bec7b683ce55104c7555e19457fc2ac72c6f035201e362be08 +SIZE (pocl-pocl-v7.0_GH0.tar.gz) = 3766036 diff --git a/lang/pocl/files/patch-CMakeLists.txt b/lang/pocl/files/patch-CMakeLists.txt index ac4253d87ac6..1b1987ab6288 100644 --- a/lang/pocl/files/patch-CMakeLists.txt +++ b/lang/pocl/files/patch-CMakeLists.txt @@ -1,12 +1,12 @@ ---- CMakeLists.txt.orig 2022-06-10 10:09:05 UTC +--- CMakeLists.txt.orig 2025-05-21 11:53:16 UTC +++ CMakeLists.txt -@@ -394,6 +394,9 @@ find_package(Hwloc) - set(ENABLE_HWLOC ON CACHE BOOL "Hwloc" FORCE) +@@ -466,6 +466,9 @@ endfunction() endif() + endfunction() +include(CheckIncludeFiles) -+check_include_files("sys/types.h;sys/sysctl.h" HAVE_SYSCTL_H) ++check_include_files("sys/sysctl.h" HAVE_SYSCTL_H) + - include(sanitizers) - + function(rename_if_different SRC DST EXEC) + if(EXISTS "${DST}") diff --git a/lang/pocl/files/patch-config.h.in.cmake b/lang/pocl/files/patch-config.h.in.cmake index 6f507f989de8..d6b0d26ce2a7 100644 --- a/lang/pocl/files/patch-config.h.in.cmake +++ b/lang/pocl/files/patch-config.h.in.cmake @@ -1,11 +1,11 @@ ---- config.h.in.cmake.orig 2022-06-10 10:09:05 UTC +--- config.h.in.cmake.orig 2025-05-21 11:53:16 UTC +++ config.h.in.cmake -@@ -57,6 +57,8 @@ +@@ -88,6 +88,8 @@ - #cmakedefine HAVE_VFORK + #cmakedefine HAVE_LINUX_VSOCK_H +#cmakedefine HAVE_SYSCTL_H + #cmakedefine HAVE_CLOCK_GETTIME - #cmakedefine HAVE_FDATASYNC + #cmakedefine HOST_COMPILER_SUPPORTS_FLOAT16 diff --git a/lang/pocl/files/patch-lib_CL_devices_cpuinfo.c b/lang/pocl/files/patch-lib_CL_devices_cpuinfo.c index ce0187187300..7702df8abd81 100644 --- a/lang/pocl/files/patch-lib_CL_devices_cpuinfo.c +++ b/lang/pocl/files/patch-lib_CL_devices_cpuinfo.c @@ -1,157 +1,157 @@ ---- lib/CL/devices/cpuinfo.c.orig 2022-06-10 10:09:05 UTC +--- lib/CL/devices/cpuinfo.c.orig 2025-05-21 11:53:16 UTC +++ lib/CL/devices/cpuinfo.c @@ -34,6 +34,12 @@ #include "config.h" #include "cpuinfo.h" -+#ifdef HAVE_SYSCTL_H ++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +# include +# include +#endif + +#ifdef __linux__ static const char* cpuinfo = "/proc/cpuinfo"; #define MAX_CPUINFO_SIZE 64*1024 //#define DEBUG_POCL_CPUINFO @@ -41,9 +47,6 @@ static const char* cpufreq_file="/sys/devices/system/c //Linux' cpufrec interface static const char* cpufreq_file="/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"; -// Vendor of PCI root bus -static const char *pci_bus_root_vendor_file = "/sys/bus/pci/devices/0000:00:00.0/vendor"; - /* Strings to parse in /proc/cpuinfo. Else branch is for x86, x86_64 */ #if defined __powerpc__ #define FREQSTRING "clock" @@ -156,8 +159,51 @@ pocl_cpuinfo_detect_max_clock_frequency() } return -1; } +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +/** + * Detects the maximum clock frequency of the CPU. + * + * Assumes all cores have the same max clock freq. + * + * @return The clock frequency in MHz. + */ +int +pocl_cpuinfo_detect_max_clock_frequency() +{ + const char mib1[] = "dev.cpu.0.freq_levels"; + const char mib2[] = "hw.clockrate"; + int clockrate = 0; + size_t size = 0; + char *value = NULL; + if (!sysctlbyname(mib1, NULL, &size, NULL, 0) && + (value = (char*)malloc(++size)) && + !sysctlbyname(mib1, (void*)value, &size, NULL, 0)) + { + value[size] = '\0'; + sscanf(value, "%d/%*d", &clockrate); + } + else + { + size = sizeof(clockrate); + sysctlbyname(mib2, (void*)&clockrate, &size, NULL, 0); + } + if (value) + free(value); + return clockrate; +} +#else +/** + * Unimplemented for other platforms. + */ +int +pocl_cpuinfo_detect_max_clock_frequency() +{ + return 0; +} +#endif +#ifdef __linux__ /** * Detects the number of parallel hardware threads supported by * the CPU by parsing the cpuinfo. @@ -235,6 +281,19 @@ pocl_cpuinfo_detect_compute_unit_count() - } - return -1; + } + return -1; } +#else +/** + * Detects the number of parallel hardware threads supported by + * the CPU. + * + * @return The number of hardware threads. + */ + int +pocl_cpuinfo_detect_compute_unit_count() +{ + return sysconf(_SC_NPROCESSORS_ONLN); +} +#endif #if __arm__ || __aarch64__ enum @@ -302,6 +361,7 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi * short_name is in the .data anyways.*/ device->long_name = device->short_name; +#ifdef __linux__ /* default vendor and vendor_id, in case it cannot be found by other means */ device->vendor = cpuvendor_default; if (device->vendor_id == 0) -@@ -404,7 +464,26 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi - char *new_name = (char*)malloc (len); - snprintf (new_name, len, "%s-%s", device->short_name, start); +@@ -408,7 +468,26 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi + snprintf (new_name, len, "%s-%s-%s", device->short_name, + (device->llvm_cpu ? device->llvm_cpu : ""), start); device->long_name = new_name; +#elif defined(HAVE_SYSCTL_H) + int mib[2]; + size_t len = 0; + char *model; + mib[0] = CTL_HW; + mib[1] = HW_MODEL; + if (sysctl(mib, 2, NULL, &len, NULL, 0)) + return; + if (!(model = (char*)malloc(++len))) + return; + if (sysctl(mib, 2, (void*)model, &len, NULL, 0)) + free(model); + else + { + model[len] = '\0'; + device->long_name = model; + } +#endif + /* If the vendor_id field is still empty, we should get the PCI ID associated * with the CPU vendor (if there is one), to be ready for the (currently * provisional) OpenCL 3.0 specification that has finally clarified the -@@ -415,13 +494,23 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi +@@ -419,13 +498,23 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi */ if (!device->vendor_id) { - f = fopen (pci_bus_root_vendor_file, "r"); +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + /* + * Future work: try to extract vendor ID from PCI root bus from MIB + */ +#elif defined(__linux__) + FILE *f = fopen (pci_bus_root_vendor_file, "r"); if (f) { /* no error checking, if it failed we just won't have the info */ num_read = fscanf (f, "%x", &device->vendor_id); fclose (f); } +#else + /* + * Other aliens ... + */ +#endif } } diff --git a/lang/pocl/files/patch-lib_CL_pocl__timing.c b/lang/pocl/files/patch-lib_CL_pocl__timing.c index 5450f1b75652..2c307fffca44 100644 --- a/lang/pocl/files/patch-lib_CL_pocl__timing.c +++ b/lang/pocl/files/patch-lib_CL_pocl__timing.c @@ -1,13 +1,13 @@ ---- lib/CL/pocl_timing.c.orig 2022-06-10 10:09:05 UTC +--- lib/CL/pocl_timing.c.orig 2025-05-21 11:53:16 UTC +++ lib/CL/pocl_timing.c -@@ -69,8 +69,8 @@ uint64_t pocl_gettimemono_ns() { +@@ -74,8 +74,8 @@ uint64_t pocl_gettimemono_ns() { struct timespec timespec; # ifdef CLOCK_MONOTONIC_RAW /* Linux */ clock_gettime(CLOCK_MONOTONIC_RAW, ×pec); -# elif defined(CLOCK_UPTIME_FAST) /* FreeBSD, DragonFlyBSD, etc */ - clock_gettime(CLOCK_UPTIME_FAST, ×pec); +# elif defined(CLOCK_MONOTONIC_FAST) /* FreeBSD, DragonFlyBSD, etc */ + clock_gettime(CLOCK_MONOTONIC_FAST, ×pec); # elif defined(CLOCK_MONOTONIC) /* POSIX 2008, NetBSD, etc */ clock_gettime(CLOCK_MONOTONIC, ×pec); # else /* older POSIX didn't define CLOCK_MONOTONIC */ diff --git a/lang/pocl/files/patch-pocld_common.cc b/lang/pocl/files/patch-pocld_common.cc new file mode 100644 index 000000000000..2a6c2b17aee0 --- /dev/null +++ b/lang/pocl/files/patch-pocld_common.cc @@ -0,0 +1,13 @@ +--- pocld/common.cc.orig 2025-06-02 18:01:19 UTC ++++ pocld/common.cc +@@ -35,6 +35,10 @@ + #include + #include + ++#ifdef __FreeBSD__ ++#include ++#endif ++ + void replyID(Reply *rep, ReplyMessageType t, uint32_t id) { + rep->rep.message_type = t; + rep->rep.failed = 0; diff --git a/lang/pocl/files/patch-pocld_daemon.cc b/lang/pocl/files/patch-pocld_daemon.cc new file mode 100644 index 000000000000..a7699b30d32d --- /dev/null +++ b/lang/pocl/files/patch-pocld_daemon.cc @@ -0,0 +1,12 @@ +--- pocld/daemon.cc.orig 2025-06-02 18:16:16 UTC ++++ pocld/daemon.cc +@@ -28,6 +28,9 @@ + #include + #include + #include ++#ifdef __FreeBSD__ ++#include ++#endif + #include + #include + #include diff --git a/lang/pocl/files/patch-pocld_pocld.cc b/lang/pocl/files/patch-pocld_pocld.cc new file mode 100644 index 000000000000..6e1a3c78dcdf --- /dev/null +++ b/lang/pocl/files/patch-pocld_pocld.cc @@ -0,0 +1,11 @@ +--- pocld/pocld.cc.orig 2025-05-21 11:53:16 UTC ++++ pocld/pocld.cc +@@ -27,7 +27,7 @@ + #include + #include + +-#ifdef __linux__ ++#if defined(__linux__) || defined(__FreeBSD__) + #include + #endif + diff --git a/lang/pocl/files/pocld.in b/lang/pocl/files/pocld.in new file mode 100644 index 000000000000..20f97cf3a892 --- /dev/null +++ b/lang/pocl/files/pocld.in @@ -0,0 +1,28 @@ +#!/bin/sh +# +# + +# PROVIDE: pocld +# REQUIRE: NETWORKING sysctl +# KEYWORD: shutdown +# +# To enable this service, place +# pocld_enable="YES" +# in /etc/rc.conf[.local] + +. /etc/rc.subr + +name="pocld" +rcvar=pocld_enable + +# read settings, set defaults +load_rc_config ${name} + +: ${pocld_enable:="NO"} +#: ${pocld_args:="-a localhost -p 6060"} + +command="/usr/local/bin/${name}" +pidfile="/var/run/${name}.pid" +extra_commands="reload" + +run_rc_command "$1" diff --git a/lang/pocl/pkg-descr b/lang/pocl/pkg-descr index 8c09ff01267d..bbb8b1c2a56c 100644 --- a/lang/pocl/pkg-descr +++ b/lang/pocl/pkg-descr @@ -1,28 +1,6 @@ -[ -{ type: install - message: <= 3.0) aims to be an efficient open source (MIT-licensed) implementation of the OpenCL 2.X standard with adaptions of OpenCL 3.0. - -In addition to producing an easily portable open source OpenCL -implementation, another major goal of the project is improving -performance portability of OpenCL programs with compiler -optimizations, reducing the need for target-dependent manual -optimizations. At the core of pocl is a set of LLVM passes -used to statically parallelize multiple work-items with the kernel -compiler, even in the presence of work-group barriers. This enables -parallelization of the fine-grained static concurrency in the work -groups in multiple ways (SIMD, VLIW, superscalar,...). - -The code base is modularized to allow easy adding of new "device drivers" -in the host-device layer. A generic multithreaded "target driver" is -included. It allows running OpenCL applications on a host that supports -the pthread library with multithreading at the work group granularity. - -EOM -} -] diff --git a/lang/pocl/pkg-message b/lang/pocl/pkg-message deleted file mode 100644 index 802c2dee25b1..000000000000 --- a/lang/pocl/pkg-message +++ /dev/null @@ -1,18 +0,0 @@ -[ -{ type: install - message: <