add parallel/pocl

OpenCL (Open Computing Language) is an open, royalty-free standard for
cross-platform, parallel programming of diverse accelerators found in
supercomputers, cloud servers, personal computers, mobile devices and embedded
platforms.

PoCL is a portable open source (MIT-licensed) implementation of the OpenCL
standard (1.2 with some 2.0 features supported). In addition to being an easily
portable multi-device (truely heterogeneous) open-source OpenCL implementation,
a major goal of this project is improving interoperability of diversity of
OpenCL-capable devices by integrating them to a single centrally orchestrated
platform.
This commit is contained in:
nia 2021-06-10 09:57:39 +00:00
parent 91a63c05af
commit b6baf86b71
12 changed files with 286 additions and 1 deletions

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.33 2021/06/09 20:49:58 nia Exp $
# $NetBSD: Makefile,v 1.34 2021/06/10 09:57:39 nia Exp $
#
COMMENT= Applications dealing with parallelism in computing
@ -14,6 +14,7 @@ SUBDIR+= hwloc
SUBDIR+= linda
SUBDIR+= lua-lanes
SUBDIR+= mpi-ch
SUBDIR+= ocl-icd
SUBDIR+= opencl-clang
SUBDIR+= opencl-clhpp
SUBDIR+= opencl-headers
@ -24,6 +25,7 @@ SUBDIR+= p5-Parallel-Pvm
SUBDIR+= paexec
SUBDIR+= parallel
SUBDIR+= pdsh
SUBDIR+= pocl
SUBDIR+= pvm3
SUBDIR+= py-billiard
SUBDIR+= sge

11
parallel/pocl/DESCR Normal file
View file

@ -0,0 +1,11 @@
OpenCL (Open Computing Language) is an open, royalty-free standard for
cross-platform, parallel programming of diverse accelerators found in
supercomputers, cloud servers, personal computers, mobile devices and embedded
platforms.
PoCL is a portable open source (MIT-licensed) implementation of the OpenCL
standard (1.2 with some 2.0 features supported). In addition to being an easily
portable multi-device (truly heterogeneous) open-source OpenCL implementation,
a major goal of this project is improving interoperability of diversity of
OpenCL-capable devices by integrating them to a single centrally orchestrated
platform.

55
parallel/pocl/Makefile Normal file
View file

@ -0,0 +1,55 @@
# $NetBSD: Makefile,v 1.1 2021/06/10 09:57:40 nia Exp $
DISTNAME= pocl-1.7
CATEGORIES= parallel
MASTER_SITES= http://portablecl.org/downloads/
MAINTAINER= pkgsrc-users@NetBSD.org
HOMEPAGE= http://portablecl.org/
COMMENT= Portable implementation of the OpenCL standard
LICENSE= mit
USE_CMAKE= yes
USE_TOOLS+= pkg-config
USE_LANGUAGES= c c++
# C++11
GCC_REQD+= 4.7
CMAKE_ARGS+= -DCMAKE_BUILD_TYPE="Release"
CMAKE_ARGS+= -DCMAKE_INSTALL_LIBDIR="lib"
CMAKE_ARGS+= -DPOCL_INSTALL_ICD_VENDORDIR="${PREFIX}/share/examples/OpenCL/vendor"
CMAKE_ARGS+= -DKERNELLIB_HOST_CPU_VARIANTS="distro"
CMAKE_ARGS+= -DLLVM_CONFIG=${LLVM_CONFIG_PATH:Q}
LDFLAGS+= ${COMPILER_RPATH_FLAG}${PREFIX}/lib/pocl
# The PLIST includes target-specific files so needs to be generated.
GENERATE_PLIST+= find ${DESTDIR}${PREFIX} \( -type f -o -type l \) -print | \
sed 's,${DESTDIR}${PREFIX}/,,' | ${SORT} ;
.include "../../mk/bsd.prefs.mk"
pre-configure:
.if empty(PKGSRC_COMPILER:M*clang*)
# XXX: When using GCC, pkgsrc provides 'clang' wrappers that are actually gcc.
# XXX: This is copied from Firefox, which also needs this hack...
${LN} -sf ${PREFIX}/bin/clang ${WRKDIR}/.cwrapper/bin/clang
${LN} -sf ${PREFIX}/bin/clang++ ${WRKDIR}/.cwrapper/bin/clang++
${LN} -sf ${PREFIX}/bin/clang-cpp ${WRKDIR}/.cwrapper/bin/clang-cpp
.endif
OWN_DIRS+= ${PKG_SYSCONFDIR}/OpenCL/vendor
CONF_FILES+= ${PREFIX}/share/examples/OpenCL/vendor/pocl.icd \
${PKG_SYSCONFDIR}/OpenCL/vendor/pocl.icd
PKGCONFIG_OVERRIDE+= pocl.pc.in.cmake
.include "../../lang/clang/buildlink3.mk"
.include "../../lang/llvm/buildlink3.mk"
.include "../../parallel/hwloc/buildlink3.mk"
.include "../../parallel/ocl-icd/buildlink3.mk"
.include "../../parallel/opencl-headers/buildlink3.mk"
.include "../../mk/dlopen.buildlink3.mk"
.include "../../mk/bsd.pkg.mk"

14
parallel/pocl/distinfo Normal file
View file

@ -0,0 +1,14 @@
$NetBSD: distinfo,v 1.1 2021/06/10 09:57:40 nia Exp $
SHA1 (pocl-1.7.tar.gz) = 7f28546ac51d89ba699cc5adce1ddf2e91bdf230
RMD160 (pocl-1.7.tar.gz) = 75555c802bf133298d615f5c146174dc0f959a72
SHA512 (pocl-1.7.tar.gz) = 23bb82b25a222186c001b2ed413f26253e1e0e16518e98c95173f51491e15d107e6ab1b334ffd490b41199743267d9ad64882a22fea327e17ec9604f9847fc38
Size (pocl-1.7.tar.gz) = 1577676 bytes
SHA1 (patch-CMakeLists.txt) = 314c492b03d66ab373cc59c926fe3d27aeb3a5a3
SHA1 (patch-config.h.in.cmake) = 974fad1f19516ef0b73f7db5b3948e677f4aaf98
SHA1 (patch-lib_CL_devices_basic_basic.c) = 9110d868a305cefc2e19fd7d7482f6ce2b8a6164
SHA1 (patch-lib_CL_devices_common.c) = c276aa967a1cc79b2bd6029b287b887bdb2b0010
SHA1 (patch-lib_CL_devices_devices.c) = 17a5bb001086befdf88452b7e1126d2f5f4b1fc1
SHA1 (patch-lib_CL_devices_hsa_pocl-hsa.c) = b7b4798b6f47f4d60a914f45ba64fe8448accdb9
SHA1 (patch-lib_CL_devices_pthread_pthread.c) = afc0ab5544300d141d1fbfe5b7fe18af281365fa
SHA1 (patch-lib_CL_pocl__timing.c) = 93b83613973d8128cd5b93375cadd2f6702de7ba

View file

@ -0,0 +1,32 @@
$NetBSD: patch-CMakeLists.txt,v 1.1 2021/06/10 09:57:40 nia Exp $
Most Unix-like OSes don't need libdl...
--- CMakeLists.txt.orig 2021-05-19 08:12:19.000000000 +0000
+++ CMakeLists.txt
@@ -787,9 +787,7 @@ elseif(UNIX)
find_library(DL_LIB "dl")
find_file(DL_H "dlfcn.h")
- if(DL_LIB AND DL_H)
- message(STATUS "libdl found")
-
+ if(DL_H)
get_filename_component(DL_H_INCLUDE_DIR "${DL_H}" DIRECTORY)
string(FIND "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}" "${DL_H_INCLUDE_DIR}" LTPOSITION)
# include the directory of dlfcn.h, if its not in the default system include dirs
@@ -797,9 +795,11 @@ elseif(UNIX)
if((LTPOSITION LESS "0") AND (NOT CMAKE_CROSSCOMPILING))
include_directories("${DL_H_INCLUDE_DIR}")
endif()
- set(HAVE_LIBDL ON CACHE BOOL "dlopen" FORCE)
- else()
- message(FATAL_ERROR "Could not find DL library!")
+ set(HAVE_DLFCN_H ON)
+ endif()
+
+ if(NOT DL_LIB)
+ set(DL_LIB "")
endif()
else()

View file

@ -0,0 +1,24 @@
$NetBSD: patch-config.h.in.cmake,v 1.1 2021/06/10 09:57:40 nia Exp $
dlfcn.h is a separate thing to libdl and should be detected separately.
--- config.h.in.cmake.orig 2021-05-19 08:12:19.000000000 +0000
+++ config.h.in.cmake
@@ -35,6 +35,8 @@
#cmakedefine ENABLE_SPIRV
+#cmakedefine HAVE_DLFCN_H
+
#cmakedefine HAVE_FORK
#cmakedefine HAVE_VFORK
@@ -57,8 +59,6 @@
#cmakedefine HAVE_LTTNG_UST
-#cmakedefine HAVE_LIBDL
-
#cmakedefine HAVE_OCL_ICD
#cmakedefine HAVE_POSIX_MEMALIGN

View file

@ -0,0 +1,17 @@
$NetBSD: patch-lib_CL_devices_basic_basic.c,v 1.1 2021/06/10 09:57:40 nia Exp $
Detect dlfcn.h (portable) instead of libdl (not portable).
--- lib/CL/devices/basic/basic.c.orig 2021-05-19 08:12:19.000000000 +0000
+++ lib/CL/devices/basic/basic.c
@@ -50,8 +50,8 @@
#include "pocl_llvm.h"
#endif
-#ifndef HAVE_LIBDL
-#error Basic driver requires DL library
+#ifndef HAVE_DLFCN_H
+#error Basic driver requires dlopen
#endif
struct data {

View file

@ -0,0 +1,15 @@
$NetBSD: patch-lib_CL_devices_common.c,v 1.1 2021/06/10 09:57:40 nia Exp $
Test for dlfcn.h instead of libdl.
--- lib/CL/devices/common.c.orig 2021-05-19 08:12:19.000000000 +0000
+++ lib/CL/devices/common.c
@@ -61,7 +61,7 @@
#include <unistd.h>
#endif
-#ifdef HAVE_LIBDL
+#ifdef HAVE_DLFCN_H
#if defined(__APPLE__)
#define _DARWIN_C_SOURCE
#endif

View file

@ -0,0 +1,66 @@
$NetBSD: patch-lib_CL_devices_devices.c,v 1.1 2021/06/10 09:57:40 nia Exp $
Add support for non-Linux unixes.
--- lib/CL/devices/devices.c.orig 2021-05-19 08:12:19.000000000 +0000
+++ lib/CL/devices/devices.c
@@ -27,7 +27,7 @@
#include <string.h>
#include <ctype.h>
-#ifdef __linux__
+#if !defined(_WIN32) && !defined(__APPLE__)
#include <limits.h>
#include <signal.h>
#include <stdio.h>
@@ -70,7 +70,7 @@
#define PATH_MAX 4096
#endif
-#ifdef HAVE_LIBDL
+#ifdef HAVE_DLFCN_H
#if defined(__APPLE__)
#define _DARWIN_C_SOURCE
#endif
@@ -303,7 +303,7 @@ str_toupper(char *out, const char *in)
*/
#ifdef ENABLE_HOST_CPU_DEVICES
-#ifdef __linux__
+#if !defined(_WIN32) && !defined(__APPLE__)
#ifdef __x86_64__
#define DIV_OPCODE_SIZE 1
@@ -335,7 +335,11 @@ sigfpe_signal_handler (int signo, siginf
{
ucontext_t *uc;
uc = (ucontext_t *)data;
+#ifdef __NetBSD__
+ unsigned char *eip = (unsigned char *)(uc->uc_mcontext.__gregs[_REG_RIP]);
+#else
unsigned char *eip = (unsigned char *)(uc->uc_mcontext.gregs[REG_RIP]);
+#endif
if ((signo == SIGFPE)
&& ((si->si_code == FPE_INTDIV) || (si->si_code == FPE_INTOVF)))
@@ -384,7 +388,11 @@ sigfpe_signal_handler (int signo, siginf
n += IP_RELATIVE_INDEXING;
}
+#ifdef __NetBSD__
+ uc->uc_mcontext.__gregs[_REG_RIP] += n;
+#else
uc->uc_mcontext.gregs[REG_RIP] += n;
+#endif
return;
}
else
@@ -546,7 +554,7 @@ pocl_init_devices ()
#ifdef ENABLE_HOST_CPU_DEVICES
-#ifdef __linux__
+#if !defined(_WIN32) && !defined(__APPLE__)
#ifdef __x86_64__
if (pocl_get_bool_option ("POCL_SIGFPE_HANDLER", 1))

View file

@ -0,0 +1,17 @@
$NetBSD: patch-lib_CL_devices_hsa_pocl-hsa.c,v 1.1 2021/06/10 09:57:40 nia Exp $
Detect dlfcn.h (portable) instead of libdl (not portable).
--- lib/CL/devices/hsa/pocl-hsa.c.orig 2021-05-19 08:12:19.000000000 +0000
+++ lib/CL/devices/hsa/pocl-hsa.c
@@ -73,8 +73,8 @@
#endif
-#ifndef HAVE_LIBDL
-#error HSA driver requires DL library
+#ifndef HAVE_DLFCN_H
+#error HSA driver requires dlopen
#endif
#include "pocl-hsa.h"

View file

@ -0,0 +1,17 @@
$NetBSD: patch-lib_CL_devices_pthread_pthread.c,v 1.1 2021/06/10 09:57:40 nia Exp $
Detect dlfcn.h (portable) instead of libdl (not portable).
--- lib/CL/devices/pthread/pthread.c.orig 2021-05-19 08:12:19.000000000 +0000
+++ lib/CL/devices/pthread/pthread.c
@@ -51,8 +51,8 @@
#include "pocl_util.h"
#include "pocl_mem_management.h"
-#ifndef HAVE_LIBDL
-#error Pthread driver requires DL library
+#ifndef HAVE_DLFCN_H
+#error Pthread driver requires dlopen
#endif
#ifdef OCS_AVAILABLE

View file

@ -0,0 +1,15 @@
$NetBSD: patch-lib_CL_pocl__timing.c,v 1.1 2021/06/10 09:57:40 nia Exp $
NetBSD does not have CLOCK_UPTIME_FAST.
--- lib/CL/pocl_timing.c.orig 2021-05-19 08:12:19.000000000 +0000
+++ lib/CL/pocl_timing.c
@@ -74,7 +74,7 @@ uint64_t pocl_gettimemono_ns() {
# warning Using clock_gettime with CLOCK_MONOTONIC for monotonic clocks
clock_gettime(CLOCK_MONOTONIC, &timespec);
# endif
-# elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD_kernel__)
+# elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
clock_gettime(CLOCK_UPTIME_FAST, &timespec);
# else
# warning Using clock_gettime with CLOCK_REALTIME for monotonic clocks