Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
19df4be
Add top-level SConstruct work-in-progress.
jaredhoberock Mar 14, 2012
1c5fd1f
Generate help text
jaredhoberock Mar 14, 2012
c1b1864
Only add -DTHRUST_DEBUG to the list of macros in debug mode.
jaredhoberock Mar 15, 2012
8d510cc
Add a top-level SConscript for building zipfiles.
jaredhoberock Mar 16, 2012
07dc2f9
Automatically add the version number to the zipfile distributions.
jaredhoberock Mar 16, 2012
702520c
Add build support for Darwin
jaredhoberock Mar 16, 2012
4ce68b3
The top-level SConscript needn't import an environment.
jaredhoberock Mar 16, 2012
e5afbe2
Add RecursiveGlob to top-level SConstruct.
jaredhoberock Mar 16, 2012
9b311af
Merge github.com:thrust/thrust
jaredhoberock Mar 19, 2012
0c4a9c7
Allow RecursiveGlob to exclude directory names which match a regex
jaredhoberock Mar 19, 2012
bc4b1d6
Refactor trivial_tests build
jaredhoberock Mar 19, 2012
545be1a
Integrate performance/SConscript into the new build.
jaredhoberock Mar 20, 2012
58bf268
Build all targets in a directory specific to the build configuration.
jaredhoberock Mar 23, 2012
25cf5b0
Make the host_backend and device_backend command line variables
jaredhoberock Mar 23, 2012
87f6565
Eliminate some old build-related code we don't use/need anymore.
jaredhoberock Mar 23, 2012
979e1df
Eliminate some absolute pathnames from SConscripts
jaredhoberock Mar 23, 2012
05f941c
Teach the build how to generate documentation.
jaredhoberock Mar 23, 2012
666793a
Move nvcc.py to live under site_scons
jaredhoberock Mar 23, 2012
a8745e8
Rename README.txt to README
jaredhoberock Mar 27, 2012
f01b4b5
Make the zipfile distributions build within a variant directory and
jaredhoberock Mar 27, 2012
8f67322
Fix typo in SConstruct which produced the wrong list of libs for the TBB
jaredhoberock Mar 27, 2012
39c24c9
Convince SCons and Doxygen to output doc under the targets directory.
jaredhoberock Mar 27, 2012
0f09f55
Simply the examples SConscript a bit.
jaredhoberock Mar 27, 2012
9b92f35
Add a 'dist' target that builds thrust-{major}.{minor}.{subminor}.zip
jaredhoberock Mar 27, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make the host_backend and device_backend command line variables
ListVariables and iterate over their cross product.
  • Loading branch information
jaredhoberock committed Mar 23, 2012
commit 25cf5b016fb22c4e4411ad3967afd74b7f31de64
82 changes: 46 additions & 36 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ EnsureSConsVersion(1,2)
import os
import platform
import glob
import itertools


def RecursiveGlob(env, pattern, directory = Dir('.'), exclude = '\B'):
Expand Down Expand Up @@ -276,13 +277,13 @@ def command_line_variables():
if os.name == 'nt':
vars.Add(EnumVariable('MSVC_VERSION', 'MS Visual C++ version', None, allowed_values=('8.0', '9.0', '10.0')))

# add a variable to handle the device backend
vars.Add(EnumVariable('device_backend', 'The parallel device backend to target', 'cuda',
allowed_values = ('cuda', 'omp', 'tbb')))

# add a variable to handle the host backend
vars.Add(EnumVariable('host_backend', 'The host backend to target', 'cpp',
allowed_values = ('cpp', 'omp', 'tbb')))
vars.Add(ListVariable('host_backend', 'The host backend to target', 'cpp',
['cpp', 'omp', 'tbb']))

# add a variable to handle the device backend
vars.Add(ListVariable('device_backend', 'The parallel device backend to target', 'cuda',
['cuda', 'omp', 'tbb']))

# add a variable to handle release/debug mode
vars.Add(EnumVariable('mode', 'Release versus debug mode', 'release',
Expand All @@ -302,49 +303,58 @@ def command_line_variables():
return vars


# create an Environment
# create a master Environment
vars = command_line_variables()
env = Environment(variables = vars, tools = ['default', 'packaging'])
Help(vars.GenerateHelpText(env))
master_env = Environment(variables = vars, tools = ['default', 'packaging'])
Help(vars.GenerateHelpText(master_env))

# enable nvcc
env.Tool('nvcc', toolpath = ['build'])
master_env.Tool('nvcc', toolpath = ['build'])

# enable RecursiveGlob
env.AddMethod(RecursiveGlob)
master_env.AddMethod(RecursiveGlob)

# import the LD_LIBRARY_PATH so we can run commands which
# depend on shared libraries (e.g., cudart)
# we don't need to do this on windows
if env['PLATFORM'] == 'posix':
env['ENV']['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
elif env['PLATFORM'] == 'darwin':
env['ENV']['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH']

# populate the environment
env.Append(CPPPATH = inc_paths())

env.Append(CCFLAGS = cc_compiler_flags(env.subst('$CXX'), env['mode'], env['host_backend'], env['device_backend'], env['Wall'], env['Werror']))

env.Append(NVCCFLAGS = nv_compiler_flags(env['mode'], env['device_backend'], env['arch']))

env.Append(LINKFLAGS = linker_flags(env.subst('$LINK'), env['mode'], env['PLATFORM'], env['device_backend']))
if master_env['PLATFORM'] == 'posix':
master_env['ENV']['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
elif master_env['PLATFORM'] == 'darwin':
master_env['ENV']['DYLD_LIBRARY_PATH'] = os.envriron['DYLD_LIBRARY_PATH']

env.Append(LIBPATH = lib_paths())
# get the list of requested backends
host_backends = master_env.subst('$host_backend').split()
device_backends = master_env.subst('$device_backend').split()

env.Append(LIBS = libs(env.subst('$CXX'), env['host_backend'], env['device_backend']))
for (host,device) in itertools.product(host_backends, device_backends):
# clone the master environment for this config
env = master_env.Clone()

# make the build environment available to all subsidiary SConscripts
env.Export('env')

# assemble the name of this configuration's targets directory
targets_dir = 'targets/{0}_host_{1}_device_{2}'.format(env['host_backend'], env['device_backend'], env['mode'])
# populate the environment
env.Append(CPPPATH = inc_paths())

env.Append(CCFLAGS = cc_compiler_flags(env.subst('$CXX'), env['mode'], host, device, env['Wall'], env['Werror']))

env.Append(NVCCFLAGS = nv_compiler_flags(env['mode'], device, env['arch']))

env.Append(LINKFLAGS = linker_flags(env.subst('$LINK'), env['mode'], env['PLATFORM'], device))

env.Append(LIBPATH = lib_paths())

env.Append(LIBS = libs(env.subst('$CXX'), host, device))

# assemble the name of this configuration's targets directory
targets_dir = 'targets/{0}_host_{1}_device_{2}'.format(host, device, env['mode'])

# invoke each SConscript with a variant directory
env.SConscript('examples/SConscript', variant_dir = 'examples/' + targets_dir, duplicate = 0)
env.SConscript('testing/SConscript', variant_dir = 'testing/' + targets_dir, duplicate = 0)
env.SConscript('performance/SConscript', variant_dir = 'performance/' + targets_dir, duplicate = 0)
# allow subsidiary SConscripts to peek at the backends
env['host_backend'] = host
env['device_backend'] = device

# invoke each SConscript with a variant directory
env.SConscript('examples/SConscript', exports='env', variant_dir = 'examples/' + targets_dir, duplicate = 0)
env.SConscript('testing/SConscript', exports='env', variant_dir = 'testing/' + targets_dir, duplicate = 0)
env.SConscript('performance/SConscript', exports='env', variant_dir = 'performance/' + targets_dir, duplicate = 0)

# the top-level SConscript doesn't need a variant directory as it just builds zipfiles
env.SConscript('SConscript')
master_env.SConscript('SConscript')

4 changes: 2 additions & 2 deletions testing/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ for ext in extensions:
sources.extend(my_env.Glob(ext))

# gather sources from directories
sources.extend(SConscript('backend/SConscript', 'my_env'))
sources.extend(SConscript('backend/SConscript', exports='env'))

# filter sources
import re
Expand All @@ -50,5 +50,5 @@ tester_alias = my_env.Alias('run_tests', [tester], tester[0].abspath)
my_env.AlwaysBuild(tester_alias)

# build children
SConscript('trivial_tests/SConscript', 'my_env')
SConscript('trivial_tests/SConscript', exports='env')