[packages/llvm-libclc] - new, with patches from Mandriva (FHS support, ATI r600 support)

qboosh qboosh at pld-linux.org
Fri Jan 25 17:57:31 CET 2013


commit 6dac4cb261fd57eed4647d8199c45f2697df4502
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Fri Jan 25 17:57:43 2013 +0100

    - new, with patches from Mandriva (FHS support, ATI r600 support)

 libclc-better-FHS-compliance.patch  | 137 +++++++++++++++++++++++++++++++
 libclc-r600-support.patch           | 156 ++++++++++++++++++++++++++++++++++++
 libclc-support-for-overriding.patch |  47 +++++++++++
 llvm-libclc.spec                    |  95 ++++++++++++++++++++++
 4 files changed, 435 insertions(+)
---
diff --git a/llvm-libclc.spec b/llvm-libclc.spec
new file mode 100644
index 0000000..647b427
--- /dev/null
+++ b/llvm-libclc.spec
@@ -0,0 +1,95 @@
+#
+# Conditional build:
+%bcond_without	apidocs		# do not build and package API docs
+#
+Summary:	OpenCL C programming language library implementation
+Summary(pl.UTF-8):	Implementacja biblioteki języka programowania OpenCL C
+Name:		llvm-libclc
+Version:	0.0.1
+%define	snap	20130101
+Release:	0.%{snap}.1
+License:	BSD-like or MIT
+Group:		Libraries
+# git clone http://llvm.org/git/libclc.git
+Source0:	libclc.tar.xz
+# Source0-md5:	19eaa8751e6fcbf198ffdb07ebafe214
+Patch0:		libclc-better-FHS-compliance.patch
+Patch1:		libclc-support-for-overriding.patch
+Patch2:		libclc-r600-support.patch
+URL:		http://libclc.llvm.org/
+BuildRequires:	clang >= 3.2
+BuildRequires:	llvm-devel >= 3.2
+BuildRequires:	python
+BuildRequires:	rpmbuild(macros) >= 1.446
+Requires:	llvm >= 3.2
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+libclc is an open source, BSD licensed implementation of the library
+requirements of the OpenCL C programming language, as specified by the
+OpenCL 1.1 Specification. The following sections of the specification
+impose library requirements:
+
+ * 6.1: Supported Data Types
+ * 6.2.3: Explicit Conversions
+ * 6.2.4.2: Reinterpreting Types Using as_type() and as_typen()
+ * 6.9: Preprocessor Directives and Macros
+ * 6.11: Built-in Functions
+ * 9.3: Double Precision Floating-Point
+ * 9.4: 64-bit Atomics
+ * 9.5: Writing to 3D image memory objects
+ * 9.6: Half Precision Floating-Point
+
+libclc is intended to be used with the Clang compiler's OpenCL
+frontend.
+
+%description -l pl.UTF-8
+libclc to mająca otwarte źródła, wydana na licencji BSD implementacja
+wymagań bibliotecznych języka programowania OpenCL C zgodna ze
+specyfikacją OpenCL 1.1. Wymagania biblioteczne wynikają z
+następujących sekcji specyfikacji:
+
+ * 6.1: obsługiwane typy danych
+ * 6.2.3: jawne konwersje
+ * 6.2.4.2: reinterpretacja typów przy użyciu as_type() i as_typen()
+ * 6.9: dyrektywy i makra preprocesora
+ * 6.11: funkcje wbudowane
+ * 9.3: arytmetyka zmiennoprzecinkowa podwójnej precyzji
+ * 9.4: 64-bitowe operacje atomowe
+ * 9.5: zapis do biektów obrazów 3D w pamięci
+ * 9.6: arytmetyka zmiennoprzecinkowa połówkowej precyzji
+
+libclc jest przeznaczona do używania z frontendem OpenCL kompilatora
+Clang.
+
+%prep
+%setup -q -n libclc
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+
+%build
+./configure.py \
+	--prefix=%{_prefix} \
+	--libexecdir=%{_datadir}/clc \
+	--pkgconfigdir=%{_npkgconfigdir} \
+	--with-llvm-config=/usr/bin/llvm-config
+
+%{__make} \
+	VERBOSE=1
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+%{__make} install \
+	DESTDIR=$RPM_BUILD_ROOT
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(644,root,root,755)
+%doc CREDITS.TXT LICENSE.TXT README.TXT www/index.html
+%{_includedir}/clc
+%{_datadir}/clc
+%{_npkgconfigdir}/libclc.pc
diff --git a/libclc-better-FHS-compliance.patch b/libclc-better-FHS-compliance.patch
new file mode 100644
index 0000000..2b38889
--- /dev/null
+++ b/libclc-better-FHS-compliance.patch
@@ -0,0 +1,137 @@
+From 3db1ffbd2f14f8b110e9949b93525f527983b612 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=E4nzer?= <bero at lindev.ch>
+Date: Sat, 12 Jan 2013 03:51:06 +0100
+Subject: [PATCH 1/3] Better FHS compliance
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Based on:
+http://www.pcc.me.uk/pipermail/libclc-dev/2012-December/000053.html
+
+From: Johannes Obermayr <johannesobermayr at gmx.de>
+Signed-off-by: Tom Stellard <tom at stellard.net>
+Signed-off-by: Bernhard Rosenkr�nzer <bero at lindev.ch>
+---
+ configure.py | 52 ++++++++++++++++++++++++++++++++++++++--------------
+ 1 file changed, 38 insertions(+), 14 deletions(-)
+
+diff --git a/configure.py b/configure.py
+index 9ae49b7..8d1c2c5 100755
+--- a/configure.py
++++ b/configure.py
+@@ -4,6 +4,10 @@ def c_compiler_rule(b, name, description, compiler, flags):
+   command = "%s -MMD -MF $out.d %s -c -o $out $in" % (compiler, flags)
+   b.rule(name, command, description + " $out", depfile="$out.d")
+ 
++version_major = 0
++version_minor = 0
++version_patch = 1
++
+ from optparse import OptionParser
+ import os
+ from subprocess import *
+@@ -19,12 +23,34 @@ p.add_option('--with-llvm-config', metavar='PATH',
+              help='use given llvm-config script')
+ p.add_option('--prefix', metavar='PATH',
+              help='install to given prefix')
++p.add_option('--libexecdir', metavar='PATH',
++             help='install *.bc to given dir')
++p.add_option('--includedir', metavar='PATH',
++             help='install include files to given dir')
++p.add_option('--pkgconfigdir', metavar='PATH',
++             help='install libclc.pc to given dir')
+ p.add_option('-g', metavar='GENERATOR', default='make',
+              help='use given generator (default: make)')
+ (options, args) = p.parse_args()
+ 
+ llvm_config_exe = options.with_llvm_config or "llvm-config"
+ 
++prefix = options.prefix
++if not prefix:
++  prefix = '/usr/local'
++
++libexecdir = options.libexecdir
++if not libexecdir:
++  libexecdir = os.path.join(prefix, 'lib/clc')
++
++includedir = options.includedir
++if not includedir:
++  includedir = os.path.join(prefix, 'include')
++
++pkgconfigdir = options.pkgconfigdir
++if not pkgconfigdir:
++  pkgconfigdir = os.path.join(prefix, 'lib/pkgconfig')
++
+ def llvm_config(args):
+   try:
+     proc = Popen([llvm_config_exe] + args, stdout=PIPE)
+@@ -58,8 +84,8 @@ b.rule("LLVM_LINK", command = llvm_link + " -o $out $in",
+ b.rule("OPT", command = llvm_opt + " -O3 -o $out $in",
+        description = 'OPT $out')
+ 
+-c_compiler_rule(b, "LLVM_TOOL_CXX", 'CXX', 'c++', llvm_cxxflags)
+-b.rule("LLVM_TOOL_LINK", "c++ -o $out $in %s" % llvm_core_libs, 'LINK $out')
++c_compiler_rule(b, "LLVM_TOOL_CXX", 'LLVM-CXX', 'clang++', llvm_cxxflags)
++b.rule("LLVM_TOOL_LINK", "clang++ -o $out $in %s" % llvm_core_libs, 'LINK $out')
+ 
+ prepare_builtins = os.path.join('utils', 'prepare-builtins')
+ b.build(os.path.join('utils', 'prepare-builtins.o'), "LLVM_TOOL_CXX",
+@@ -73,9 +99,14 @@ b.rule("PREPARE_BUILTINS", "%s -o $out $in" % prepare_builtins,
+ manifest_deps = set([sys.argv[0], os.path.join(srcdir, 'build', 'metabuild.py'),
+                      os.path.join(srcdir, 'build', 'ninja_syntax.py')])
+ 
+-install_files = []
++install_files_bc = []
+ install_deps = []
+ 
++# Create libclc.pc
++clc = open('libclc.pc', 'w')
++clc.write('includedir=%(inc)s\nlibexecdir=%(lib)s\n\nName: libclc\nDescription: Library requirements of the OpenCL C programming language\nVersion: %(maj)s.%(min)s.%(pat)s\nCflags: -I${includedir}\nLibs: -L${libexecdir}' % {'inc': includedir, 'lib': libexecdir, 'maj': version_major, 'min': version_minor, 'pat': version_patch})
++clc.close()
++
+ for target in targets:
+   (t_arch, t_vendor, t_os) = target.split('-')
+   archs = [t_arch]
+@@ -95,7 +126,6 @@ for target in targets:
+                    [os.path.join(srcdir, subdir, 'lib') for subdir in subdirs])
+ 
+   clang_cl_includes = ' '.join(["-I%s" % incdir for incdir in incdirs])
+-  install_files += [(incdir, incdir[len(srcdir)+1:]) for incdir in incdirs]
+ 
+   # The rule for building a .bc file for the specified architecture using clang.
+   clang_bc_flags = "-target %s -I`dirname $in` %s " \
+@@ -126,22 +156,20 @@ for target in targets:
+ 
+   builtins_link_bc = os.path.join(target, 'lib', 'builtins.link.bc')
+   builtins_opt_bc = os.path.join(target, 'lib', 'builtins.opt.bc')
+-  builtins_bc = os.path.join(target, 'lib', 'builtins.bc')
++  builtins_bc = os.path.join('built_libs', target + '.bc')
+   b.build(builtins_link_bc, "LLVM_LINK", objects)
+   b.build(builtins_opt_bc, "OPT", builtins_link_bc)
+   b.build(builtins_bc, "PREPARE_BUILTINS", builtins_opt_bc, prepare_builtins)
+-  install_files.append((builtins_bc, builtins_bc))
++  install_files_bc.append((builtins_bc, builtins_bc))
+   install_deps.append(builtins_bc)
+   b.default(builtins_bc)
+ 
+-if options.prefix:
+-  install_cmd = ' && '.join(['mkdir -p %(dst)s && cp -r %(src)s %(dst)s' % 
+-                             {'src': file,
+-                              'dst': os.path.join(options.prefix,
+-                                                  os.path.dirname(dest))}
+-                             for (file, dest) in install_files])
+-  b.rule('install', command = install_cmd, description = 'INSTALL')
+-  b.build('install', 'install', install_deps)
++install_cmd = ' && '.join(['mkdir -p $(DESTDIR)/%(dst)s && cp -r %(src)s $(DESTDIR)/%(dst)s' % {'src': file, 'dst': libexecdir} for (file,dest) in install_files_bc])
++install_cmd = ' && '.join(['%(old)s && mkdir -p $(DESTDIR)/%(dst)s && cp -r generic/include/clc $(DESTDIR)/%(dst)s' % {'old': install_cmd, 'dst': includedir}])
++install_cmd = ' && '.join(['%(old)s && mkdir -p $(DESTDIR)/%(dst)s && cp -r libclc.pc $(DESTDIR)/%(dst)s' % { 'old': install_cmd, 'dst': pkgconfigdir}])
++
++b.rule('install', command = install_cmd, description = 'INSTALL')
++b.build('install', 'install', install_deps)
+ 
+ b.rule("configure", command = ' '.join(sys.argv), description = 'CONFIGURE',
+        generator = True)
+-- 
+1.7.11.3
+
diff --git a/libclc-r600-support.patch b/libclc-r600-support.patch
new file mode 100644
index 0000000..3de9b68
--- /dev/null
+++ b/libclc-r600-support.patch
@@ -0,0 +1,156 @@
+From dc10fa6aeb9b5bd3855a69d1ac40a973f9164fe9 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=E4nzer?= <bero at lindev.ch>
+Date: Sat, 12 Jan 2013 03:58:23 +0100
+Subject: [PATCH 3/3] Add r600 support
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Based on:
+http://www.pcc.me.uk/pipermail/libclc-dev/2012-December/000058.html
+
+From: Tom Stellard <thomas.stellard at amd.com>
+Signed-off-by: Bernhard Rosenkr�nzer <bero at lindev.ch>
+---
+ r600/lib/OVERRIDES                   |  2 ++
+ r600/lib/SOURCES                     |  4 ++++
+ r600/lib/workitem/get_global_size.ll | 18 ++++++++++++++++++
+ r600/lib/workitem/get_group_id.ll    | 18 ++++++++++++++++++
+ r600/lib/workitem/get_local_id.ll    | 18 ++++++++++++++++++
+ r600/lib/workitem/get_local_size.ll  | 18 ++++++++++++++++++
+ 6 files changed, 78 insertions(+)
+ create mode 100644 r600/lib/OVERRIDES
+ create mode 100644 r600/lib/SOURCES
+ create mode 100644 r600/lib/workitem/get_global_size.ll
+ create mode 100644 r600/lib/workitem/get_group_id.ll
+ create mode 100644 r600/lib/workitem/get_local_id.ll
+ create mode 100644 r600/lib/workitem/get_local_size.ll
+
+diff --git a/r600/lib/OVERRIDES b/r600/lib/OVERRIDES
+new file mode 100644
+index 0000000..3f941d8
+--- /dev/null
++++ b/r600/lib/OVERRIDES
+@@ -0,0 +1,2 @@
++workitem/get_group_id.cl
++workitem/get_global_size.cl
+diff --git a/r600/lib/SOURCES b/r600/lib/SOURCES
+new file mode 100644
+index 0000000..af8c8c8
+--- /dev/null
++++ b/r600/lib/SOURCES
+@@ -0,0 +1,4 @@
++workitem/get_group_id.ll
++workitem/get_local_size.ll
++workitem/get_local_id.ll
++workitem/get_global_size.ll
+diff --git a/r600/lib/workitem/get_global_size.ll b/r600/lib/workitem/get_global_size.ll
+new file mode 100644
+index 0000000..ac2d08d
+--- /dev/null
++++ b/r600/lib/workitem/get_global_size.ll
+@@ -0,0 +1,18 @@
++declare i32 @llvm.r600.read.global.size.x() nounwind readnone
++declare i32 @llvm.r600.read.global.size.y() nounwind readnone
++declare i32 @llvm.r600.read.global.size.z() nounwind readnone
++
++define i32 @get_global_size(i32 %dim) nounwind readnone alwaysinline {
++  switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim]
++x_dim:
++  %x = call i32 @llvm.r600.read.global.size.x() nounwind readnone
++  ret i32 %x
++y_dim:
++  %y = call i32 @llvm.r600.read.global.size.y() nounwind readnone
++  ret i32 %y
++z_dim:
++  %z = call i32 @llvm.r600.read.global.size.z() nounwind readnone
++  ret i32 %z
++default:
++  ret i32 0
++}
+diff --git a/r600/lib/workitem/get_group_id.ll b/r600/lib/workitem/get_group_id.ll
+new file mode 100644
+index 0000000..5131648
+--- /dev/null
++++ b/r600/lib/workitem/get_group_id.ll
+@@ -0,0 +1,18 @@
++declare i32 @llvm.r600.read.local.size.x() nounwind readnone
++declare i32 @llvm.r600.read.local.size.y() nounwind readnone
++declare i32 @llvm.r600.read.local.size.z() nounwind readnone
++
++define i32 @get_group_id(i32 %dim) nounwind readnone alwaysinline {
++  switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim]
++x_dim:
++  %x = call i32 @llvm.r600.read.local.size.x() nounwind readnone
++  ret i32 %x
++y_dim:
++  %y = call i32 @llvm.r600.read.local.size.y() nounwind readnone
++  ret i32 %y
++z_dim:
++  %z = call i32 @llvm.r600.read.local.size.z() nounwind readnone
++  ret i32 %z
++default:
++  ret i32 0
++}
+diff --git a/r600/lib/workitem/get_local_id.ll b/r600/lib/workitem/get_local_id.ll
+new file mode 100644
+index 0000000..ac5522a
+--- /dev/null
++++ b/r600/lib/workitem/get_local_id.ll
+@@ -0,0 +1,18 @@
++declare i32 @llvm.r600.read.tidig.x() nounwind readnone
++declare i32 @llvm.r600.read.tidig.y() nounwind readnone
++declare i32 @llvm.r600.read.tidig.z() nounwind readnone
++
++define i32 @get_local_id(i32 %dim) nounwind readnone alwaysinline {
++  switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim]
++x_dim:
++  %x = call i32 @llvm.r600.read.tidig.x() nounwind readnone
++  ret i32 %x
++y_dim:
++  %y = call i32 @llvm.r600.read.tidig.y() nounwind readnone
++  ret i32 %y
++z_dim:
++  %z = call i32 @llvm.r600.read.tidig.z() nounwind readnone
++  ret i32 %z
++default:
++  ret i32 0
++}
+diff --git a/r600/lib/workitem/get_local_size.ll b/r600/lib/workitem/get_local_size.ll
+new file mode 100644
+index 0000000..6a71f75
+--- /dev/null
++++ b/r600/lib/workitem/get_local_size.ll
+@@ -0,0 +1,18 @@
++declare i32 @llvm.r600.read.tgid.x() nounwind readnone
++declare i32 @llvm.r600.read.tgid.y() nounwind readnone
++declare i32 @llvm.r600.read.tgid.z() nounwind readnone
++
++define i32 @get_local_size(i32 %dim) nounwind readnone alwaysinline {
++  switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim]
++x_dim:
++  %x = call i32 @llvm.r600.read.tgid.x() nounwind readnone
++  ret i32 %x
++y_dim:
++  %y = call i32 @llvm.r600.read.tgid.y() nounwind readnone
++  ret i32 %y
++z_dim:
++  %z = call i32 @llvm.r600.read.tgid.z() nounwind readnone
++  ret i32 %z
++default:
++  ret i32 0
++}
+--- libclc/configure.py.bero	2013-01-12 04:11:48.775174177 +0100
++++ libclc/configure.py	2013-01-12 04:11:53.809113106 +0100
+@@ -69,7 +69,7 @@ llvm_clang = os.path.join(llvm_bindir, '
+ llvm_link = os.path.join(llvm_bindir, 'llvm-link')
+ llvm_opt = os.path.join(llvm_bindir, 'opt')
+ 
+-default_targets = ['nvptx--nvidiacl', 'nvptx64--nvidiacl']
++default_targets = ['nvptx--nvidiacl', 'nvptx64--nvidiacl', 'r600--']
+ 
+ targets = args
+ if not targets:
+-- 
+1.7.11.3
+
diff --git a/libclc-support-for-overriding.patch b/libclc-support-for-overriding.patch
new file mode 100644
index 0000000..a05e891
--- /dev/null
+++ b/libclc-support-for-overriding.patch
@@ -0,0 +1,47 @@
+From 2e363c062410d2f55d5b02df72c9f31c6d812c0e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=E4nzer?= <bero at lindev.ch>
+Date: Sat, 12 Jan 2013 03:54:14 +0100
+Subject: [PATCH 2/3] Support for overriding generic implementations.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Based on:
+http://www.pcc.me.uk/pipermail/libclc-dev/2012-December/000057.html
+
+Targets can override generic implementations by adding a file called
+OVERRIDES in $(TARGET_DIR)/lib and listing the generic implementations
+that it wants to override.  For example, to override get_group_id() and
+get_global_size() you would add these lines to the OVERRIDES file:
+
+workitem/get_group_id.cl
+workitem/get_global_size.cl
+
+From: Tom Stellard <thomas.stellard at amd.com>
+Signed-off-by: Bernhard Rosenkr�nzer <bero at lindev.ch>
+---
+ configure.py | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/configure.py b/configure.py
+index 8d1c2c5..b8a2bfe 100755
+--- a/configure.py
++++ b/configure.py
+@@ -137,6 +137,14 @@ for target in targets:
+   for libdir in libdirs:
+     subdir_list_file = os.path.join(libdir, 'SOURCES')
+     manifest_deps.add(subdir_list_file)
++    override_list_file = os.path.join(libdir, 'OVERRIDES')
++
++    # Add target overrides
++    if os.path.exists(override_list_file):
++        for override in open(override_list_file).readlines():
++            override = override.rstrip()
++            sources_seen.add(override)
++
+     for src in open(subdir_list_file).readlines():
+       src = src.rstrip()
+       if src not in sources_seen:
+-- 
+1.7.11.3
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/llvm-libclc.git/commitdiff/6dac4cb261fd57eed4647d8199c45f2697df4502



More information about the pld-cvs-commit mailing list