[Mesa-dev] [PATCH] [libclc] configure: Enable building separate libraries for target variants
Tom Stellard
tom at stellard.net
Thu Mar 14 07:06:48 PDT 2013
On Wed, Mar 13, 2013 at 09:57:22PM -0500, Aaron Watry wrote:
> The python changes in this file look good to me. I haven't done a
> line-by-line review of the SI changes.
>
> I tested this patch and v2 of the related mesa series on r600g (radeon
> 6850) with a recent LLVM and fresh mesa master as of this evening. No real
> change in the piglit CL test success/failure rate.
>
> Do you have any interest in trying to merge your changes to date back into
> the upstream libclc codebase? If you think it's a good idea, but don't
> have time to do it yourself, let me know and I'll try to re-base the series
> of patches.
I have been submitting patches for upstream libclc, but it's been several months
since I've gotten a response. For now, I'll probably just push it to my
own libclc repo, and if I start getting responses for my other patches, I'll
submit it upstream.
>
> --Aaron
>
>
> On Tue, Mar 12, 2013 at 3:20 PM, Tom Stellard <tom at stellard.net> wrote:
>
> > From: Tom Stellard <thomas.stellard at amd.com>
> >
> > ---
> > configure.py | 119
> > ++++++++++++++++++++++++++++++++++++---------------------
> > 1 files changed, 75 insertions(+), 44 deletions(-)
> >
> > diff --git a/configure.py b/configure.py
> > index d861c24..dfd9a8f 100755
> > --- a/configure.py
> > +++ b/configure.py
> > @@ -68,6 +68,15 @@ llvm_clang = os.path.join(llvm_bindir, 'clang')
> > llvm_link = os.path.join(llvm_bindir, 'llvm-link')
> > llvm_opt = os.path.join(llvm_bindir, 'opt')
> >
> > +available_targets = {
> > + 'r600--' : { 'devices' :
> > + [{'gpu' : 'cedar', 'aliases' : ['palm', 'sumo', 'sumo2',
> > 'redwood', 'juniper']},
> > + {'gpu' : 'cypress', 'aliases' : ['hemlock']},
> > + {'gpu' : 'barts', 'aliases' : ['turks', 'caicos']},
> > + {'gpu' : 'cayman', 'aliases' : ['aruba']},
> > + {'gpu' : 'tahiti', 'aliases' : ['pitcairn', 'verde',
> > 'oland']}]}
> > +}
> > +
> > default_targets = ['r600--']
> >
> > targets = args
> > @@ -127,50 +136,72 @@ for target in targets:
> >
> > clang_cl_includes = ' '.join(["-I%s" % incdir 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 " \
> > - "-Dcl_clang_storage_class_specifiers " \
> > - "-Dcl_khr_fp64 " \
> > - "-emit-llvm" % (target, clang_cl_includes)
> > - clang_bc_rule = "CLANG_CL_BC_" + target
> > - c_compiler_rule(b, clang_bc_rule, "LLVM-CC", llvm_clang, clang_bc_flags)
> > -
> > - objects = []
> > - sources_seen = set()
> > -
> > - 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:
> > - sources_seen.add(src)
> > - obj = os.path.join(target, 'lib', src + '.bc')
> > - objects.append(obj)
> > - src_file = os.path.join(libdir, src)
> > - ext = os.path.splitext(src)[1]
> > - if ext == '.ll':
> > - b.build(obj, 'LLVM_AS', src_file)
> > - else:
> > - b.build(obj, clang_bc_rule, src_file)
> > -
> > - 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('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_bc.append((builtins_bc, builtins_bc))
> > - install_deps.append(builtins_bc)
> > - b.default(builtins_bc)
> > + for device in available_targets[target]['devices']:
> > + # The rule for building a .bc file for the specified architecture
> > using clang.
> > + clang_bc_flags = "-target %s -I`dirname $in` %s " \
> > + "-Dcl_clang_storage_class_specifiers " \
> > + "-Dcl_khr_fp64 " \
> > + "-emit-llvm" % (target, clang_cl_includes)
> > + if device['gpu'] != '':
> > + clang_bc_flags += ' -mcpu=' + device['gpu']
> > + clang_bc_rule = "CLANG_CL_BC_" + target
> > + c_compiler_rule(b, clang_bc_rule, "LLVM-CC", llvm_clang,
> > clang_bc_flags)
> > +
> > + objects = []
> > + sources_seen = set()
> > +
> > + if device['gpu'] == '':
> > + full_target_name = target
> > + obj_suffix = ''
> > + else:
> > + full_target_name = device['gpu'] + '-' + target
> > + obj_suffix = '.' + device['gpu']
> > +
> > + 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()
> > + # Only add the base filename (e.g. Add get_global_id instead of
> > + # get_global_id.cl) to sources_seen.
> > + # This allows targets to overide generic .cl sources with .ll
> > sources.
> > + src_base = os.path.splitext(src)[0]
> > + if src_base not in sources_seen:
> > + sources_seen.add(src_base)
> > + obj = os.path.join(target, 'lib', src + obj_suffix + '.bc')
> > + objects.append(obj)
> > + src_file = os.path.join(libdir, src)
> > + ext = os.path.splitext(src)[1]
> > + if ext == '.ll':
> > + b.build(obj, 'LLVM_AS', src_file)
> > + else:
> > + b.build(obj, clang_bc_rule, src_file)
> > +
> > + builtins_link_bc = os.path.join(target, 'lib', 'builtins.link' +
> > obj_suffix + '.bc')
> > + builtins_opt_bc = os.path.join(target, 'lib', 'builtins.opt' +
> > obj_suffix + '.bc')
> > + builtins_bc = os.path.join('built_libs', full_target_name + '.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_bc.append((builtins_bc, builtins_bc))
> > + install_deps.append(builtins_bc)
> > + for alias in device['aliases']:
> > + b.rule("CREATE_ALIAS", "ln -fs %s $out" %
> > os.path.basename(builtins_bc)
> > + ,"CREATE-ALIAS $out")
> > +
> > + alias_file = os.path.join('built_libs', alias + '-' + target +
> > '.bc')
> > + b.build(alias_file, "CREATE_ALIAS", builtins_bc)
> > + install_files_bc.append((alias_file, alias_file))
> > + install_deps.append(alias_file)
> > + b.default(builtins_bc)
> >
> >
> > install_cmd = ' && '.join(['mkdir -p $(DESTDIR)/%(dst)s && cp -r %(src)s
> > $(DESTDIR)/%(dst)s' %
> > --
> > 1.7.3.4
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >
More information about the mesa-dev
mailing list