diff --git a/lang/pocl/Makefile b/lang/pocl/Makefile index 4b7f2dc2a34f..682871ce64be 100644 --- a/lang/pocl/Makefile +++ b/lang/pocl/Makefile @@ -1,72 +1,70 @@ PORTNAME= pocl -PORTVERSION= 1.8 -DISTVERSIONPREFIX=v +DISTVERSIONPREFIX= v +DISTVERSION= 3.1 CATEGORIES= lang -MAINTAINER= ohartmann@freebsd-de.org +MAINTAINER= ohartmann@walstatt.org COMMENT= POrtable Computing Language (POCL) -WWW= http://portablecl.org/ +WWW= http://portablecl.org/ LICENSE= MIT LICENSE_FILE= ${WRKSRC}/LICENSE ONLY_FOR_ARCHS= aarch64 amd64 i386 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}>=10:devel/llvm${LLVM_VERSION} \ - opencl>=2.2:devel/opencl +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 -RUN_DEPENDS= ${BUILD_DEPENDS} USES= cmake localbase:ldflags ncurses pkgconfig USE_GITHUB= yes USE_LDCONFIG= yes -LLVM_VERSION= ${MESA_LLVM_VER:U13} +LLVM_VERSION= ${MESA_LLVM_VER:U15} CMAKE_ARGS= -DWITH_LLVM_CONFIG="${LOCALBASE}/llvm${LLVM_VERSION}/bin/llvm-config" \ -DPOCL_INSTALL_PKGCONFIG_DIR="${PREFIX}/libdata/pkgconfig" \ -DSINGLE_LLVM_LIB=ON \ ${CMAKE_ARGS_${ARCH}} 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" PLIST_SUB= CONFIGURE_TARGET=${CONFIGURE_TARGET:S/amd64/x86_64/} OPTIONS_DEFINE= DOCS -DOCS_DESC= Build documentation (needs sphinx) -DOCS_CMAKE_OFF= -DENABLE_DOCS=OFF +DOCS_DESC= Build documentation (needs textproc/py-sphinx) DOCS_CMAKE_ON= -DENABLE_DOCS=ON +DOCS_CMAKE_OFF= -DENABLE_DOCS=OFF DOCS_USES= python:3.6+ -DOCS_BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}sphinx>=0,1:textproc/py-sphinx@${PY_FLAVOR} +DOCS_BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}sphinx>=0:textproc/py-sphinx@${PY_FLAVOR} .include .if ${ARCH} == aarch64 -PLIST_SUB+= AARCH64="" +PLIST_SUB+= AARCH64="" PLIST_SUB+= PPC64="@comment " PLIST_SUB+= PPC64LE="@comment " PLIST_SUB+= X86="@comment " .elif ${ARCH} == amd64 || ${ARCH} == i386 -PLIST_SUB+= AARCH64="@comment " +PLIST_SUB+= AARCH64="@comment " PLIST_SUB+= PPC64="@comment " PLIST_SUB+= PPC64LE="@comment " PLIST_SUB+= X86="" .elif ${ARCH} == powerpc64 PLIST_SUB+= AARCH64="@comment " PLIST_SUB+= PPC64="" PLIST_SUB+= PPC64LE="@comment " PLIST_SUB+= X86="@comment " .else PLIST_SUB+= AARCH64="@comment " PLIST_SUB+= PPC64="@comment " PLIST_SUB+= PPC64LE="" PLIST_SUB+= X86="@comment " .endif -PLIST_SUB+= CONFIGURE_TARGET=${CONFIGURE_TARGET:S/amd64/x86_64/} .include diff --git a/lang/pocl/distinfo b/lang/pocl/distinfo index 5b95d2ff1d4f..a60086168896 100644 --- a/lang/pocl/distinfo +++ b/lang/pocl/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1634367852 -SHA256 (pocl-pocl-v1.8_GH0.tar.gz) = 0f63377ae1826e16e90038fc8e7f65029be4ff6f9b059f6907174b5c0d1f8ab2 -SIZE (pocl-pocl-v1.8_GH0.tar.gz) = 1614545 +TIMESTAMP = 1670346593 +SHA256 (pocl-pocl-v3.1_GH0.tar.gz) = 82314362552e050aff417318dd623b18cf0f1d0f84f92d10a7e3750dd12d3a9a +SIZE (pocl-pocl-v3.1_GH0.tar.gz) = 1928607 diff --git a/lang/pocl/files/patch-CMakeLists.txt b/lang/pocl/files/patch-CMakeLists.txt index f5e41ee6b99e..ac4253d87ac6 100644 --- a/lang/pocl/files/patch-CMakeLists.txt +++ b/lang/pocl/files/patch-CMakeLists.txt @@ -1,12 +1,12 @@ ---- CMakeLists.txt.orig 2020-12-16 13:02:13 UTC +--- CMakeLists.txt.orig 2022-06-10 10:09:05 UTC +++ CMakeLists.txt -@@ -398,6 +398,9 @@ endif() - - +@@ -394,6 +394,9 @@ find_package(Hwloc) + set(ENABLE_HWLOC ON CACHE BOOL "Hwloc" FORCE) + endif() +include(CheckIncludeFiles) +check_include_files("sys/types.h;sys/sysctl.h" HAVE_SYSCTL_H) + - ###################################################################################### + include(sanitizers) diff --git a/lang/pocl/files/patch-config.h.in.cmake b/lang/pocl/files/patch-config.h.in.cmake index d252edbc8c5f..6f507f989de8 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 2020-12-16 13:02:13 UTC +--- config.h.in.cmake.orig 2022-06-10 10:09:05 UTC +++ config.h.in.cmake -@@ -39,6 +39,8 @@ +@@ -57,6 +57,8 @@ #cmakedefine HAVE_VFORK +#cmakedefine HAVE_SYSCTL_H + #cmakedefine HAVE_CLOCK_GETTIME #cmakedefine HAVE_FDATASYNC diff --git a/lang/pocl/files/patch-lib_CL_devices_cpuinfo.c b/lang/pocl/files/patch-lib_CL_devices_cpuinfo.c index ddc39b56f3a0..ce0187187300 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 2021-10-12 16:33:15.000000000 +0200 -+++ lib/CL/devices/cpuinfo.c 2021-10-16 09:29:13.414668000 +0200 +--- lib/CL/devices/cpuinfo.c.orig 2022-06-10 10:09:05 UTC ++++ lib/CL/devices/cpuinfo.c @@ -34,6 +34,12 @@ #include "config.h" #include "cpuinfo.h" +#ifdef HAVE_SYSCTL_H +# 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 @@ +@@ -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 @@ +@@ -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 @@ +@@ -235,6 +281,19 @@ pocl_cpuinfo_detect_compute_unit_count() } 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 @@ +@@ -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 @@ +@@ -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); 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 @@ +@@ -415,13 +494,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 new file mode 100644 index 000000000000..5450f1b75652 --- /dev/null +++ b/lang/pocl/files/patch-lib_CL_pocl__timing.c @@ -0,0 +1,13 @@ +--- lib/CL/pocl_timing.c.orig 2022-06-10 10:09:05 UTC ++++ lib/CL/pocl_timing.c +@@ -69,8 +69,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/pkg-descr b/lang/pocl/pkg-descr index df8597fc68dc..8c09ff01267d 100644 --- a/lang/pocl/pkg-descr +++ b/lang/pocl/pkg-descr @@ -1,17 +1,28 @@ -Portable OpenCL aims to be an efficient open source (MIT-licensed) -implementation of the OpenCL 1.2 standard. +[ +{ 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 +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, ...). +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 new file mode 100644 index 000000000000..802c2dee25b1 --- /dev/null +++ b/lang/pocl/pkg-message @@ -0,0 +1,18 @@ +[ +{ type: install + message: <