Index: zorg/buildbot/builders/CUDATestsuiteBuilder.py =================================================================== --- /dev/null +++ zorg/buildbot/builders/CUDATestsuiteBuilder.py @@ -0,0 +1,157 @@ +from buildbot.process.properties import WithProperties +from buildbot.steps.source.svn import SVN +from buildbot.steps.shell import WarningCountingShellCommand +from buildbot.steps.shell import Configure, ShellCommand, SetProperty +from buildbot.plugins import steps +from zorg.buildbot.builders import ClangBuilder +from zorg.buildbot.commands.LitTestCommand import LitTestCommand + + +def getCUDATestsuiteBuildFactory( + externals, # Directory with CUDA, thrust and gcc versions for testing. + always_clean=True, + test=False, + useTwoStage=False, + cmake='cmake', + extra_cmake_args=[], # Extra CMake args for all stages. + extra_ts_cmake_args=[], # extra cmake args for testsuite. + jobs=None, + cuda_jobs=1, # number of simultaneous CUDA apps to run + env={}, # Environmental variables for all steps. + enable_thrust_tests=False, + split_thrust_tests=False, # Each thrust test is a separate executable. + run_thrust_tests=False, + enable_libcxx=True, # checkout/build libcxx to test with. + gpu_arch_list=[], + gpu_devices=None, # List of devices to make visible to CUDA + stage1_config='Release', + stage2_config='Release'): + + # Prepare environmental variables. Set here all env we want for all steps. + merged_env = { + 'TERM': 'dumb' # Make sure Clang doesn't use color escape sequences. + } + if env is not None: + # Overwrite pre-set items with the given ones, so user can set + # anything. + merged_env.update(env) + + jobs_cmd = [] if jobs is None else ["-j" + str(jobs)] + + source_dir = 'llvm' # Should match the one used in getClangCMakeBuildFactory. + stage1_build_dir = 'stage1' # Should match the one defined in getClangCMakeBuildFactory. + stage2_build_dir = 'stage2' # Should match the one defined in getClangCMakeBuildFactory. + + if useTwoStage: + clang_build_dir = stage2_build_dir + else: + clang_build_dir = stage1_build_dir + + # Build clang. + f = ClangBuilder.getClangCMakeBuildFactory( + clean=always_clean, + test=test, + cmake=cmake, + extra_cmake_args=extra_cmake_args, + jobs=jobs, + env=merged_env, + useTwoStage=useTwoStage, + stage1_config=stage1_config, + stage2_config=stage2_config, + checkout_libcxx=enable_libcxx, + checkout_test_suite=True) + + cuda_test_env = { + 'PYTHONPATH': WithProperties("%(workdir)s/" + source_dir + + "/utils/lit:${PYTHONPATH}"), + 'PATH': WithProperties("%(workdir)s/" + clang_build_dir + + "/bin:${PATH}"), + } + # Limit GPUs visible to CUDA. + if gpu_devices: + cuda_test_env["CUDA_VISIBLE_DEVICES"] = ",".join( + str(x) for x in gpu_devices) + merged_env.update(cuda_test_env) + + ts_build_dir = 'test-suite-build' + cmake_ts_cmd = ['env', + WithProperties('CC=%(workdir)s/' + clang_build_dir + + '/bin/clang'), + WithProperties('CXX=%(workdir)s/' + clang_build_dir + + '/bin/clang++'), + cmake, "-G", "Ninja", "../test/test-suite", + '-DCMAKE_BUILD_TYPE=Release', + # Limit to External tests only. + '-DTEST_SUITE_SUBDIRS=External', + ] + extra_ts_cmake_args + + if externals: + cmake_ts_cmd.append('-DTEST_SUITE_EXTERNALS_DIR=' + externals) + if split_thrust_tests: + cmake_ts_cmd.append('-DTHRUST_SPLIT_TESTS=1') + if gpu_arch_list: + cmake_ts_cmd.append('-DCUDA_GPU_ARCH=' + ';'.join(gpu_arch_list)) + if cuda_jobs: + cmake_ts_cmd.append('-DCUDA_JOBS=%s' % cuda_jobs) + + # Completely remove test suite build dir. + f.addStep( + steps.RemoveDirectory(name="Remove old test-suite build directory", + dir=ts_build_dir)) + + # Then do fresh cmake configuration. + f.addStep(ShellCommand(name='cmake test-suite', + command=cmake_ts_cmd, + haltOnFailure=True, + description='cmake test-suite', + workdir=ts_build_dir, + env=merged_env)) + + ninja_build_cmd = ['ninja'] + jobs_cmd + + # Always build simple CUDA tests. They serve as compilation + # smoketests and will fail quickly if compiler has obvious issues + # compiling CUDA files. + f.addStep(WarningCountingShellCommand( + name='ninja build simple CUDA tests', + command=ninja_build_cmd + ["cuda-tests-simple"], + haltOnFailure=True, + description=["building simple CUDA tests"], + descriptionDone=["simple CUDA tests built."], + workdir=ts_build_dir, + env=merged_env)) + + f.addStep(WarningCountingShellCommand( + name='run simple CUDA tests', + command=ninja_build_cmd + ["check-cuda-simple"], + haltOnFailure=True, + description=["Running simple CUDA tests"], + descriptionDone=["simple CUDA tests done."], + workdir=ts_build_dir, + env=merged_env)) + + # If we've enabled thrust tests, build them now. + # WARNING: This takes a lot of time to build. + if (enable_thrust_tests): + f.addStep(WarningCountingShellCommand( + name='ninja build thrust', + command=ninja_build_cmd + ["cuda-tests-thrust"], + haltOnFailure=True, + description=["building thrust tests"], + descriptionDone=["thrust tests built."], + workdir=ts_build_dir, + env=merged_env)) + # Run them. That also takes a while. + # TODO(tra) we may want to run more than one instance so one + # can be compiling tests while another is running them on GPU. + if run_thrust_tests: + f.addStep(WarningCountingShellCommand( + name='run all CUDA tests', + command=ninja_build_cmd + ["check"], + haltOnFailure=True, + description=["running all CUDA tests."], + descriptionDone=["all cuda tests done."], + workdir=ts_build_dir, + env=merged_env)) + + return f Index: zorg/buildbot/builders/ClangBuilder.py =================================================================== --- zorg/buildbot/builders/ClangBuilder.py +++ zorg/buildbot/builders/ClangBuilder.py @@ -340,7 +340,8 @@ checkout_clang_tools_extra, checkout_compiler_rt, checkout_test_suite, - checkout_lld): + checkout_lld, + checkout_libcxx): # We *must* checkout at least Clang+LLVM f.addStep(SVN(name='svn-llvm', mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/', @@ -376,6 +377,22 @@ mode='update', baseURL='http://llvm.org/svn/llvm-project/lld/', defaultBranch='trunk', workdir='llvm/tools/lld')) + if checkout_libcxx: + f.addStep(SVN(name='svn-libcxx', + mode='update', + baseURL='http://llvm.org/svn/llvm-project/libcxx/', + defaultBranch='trunk', + workdir='llvm/projects/libcxx')) + f.addStep(SVN(name='svn-libcxxabi', + mode='update', + baseURL='http://llvm.org/svn/llvm-project/libcxxabi/', + defaultBranch='trunk', + workdir='llvm/projects/libcxxabi')) + f.addStep(SVN(name='svn-libunwind', + mode='update', + baseURL='http://llvm.org/svn/llvm-project/libunwind/', + defaultBranch='trunk', + workdir='llvm/projects/libunwind')) def addGCSUploadSteps(f, package_name, install_prefix, gcs_directory, env, gcs_url_property=None): @@ -503,7 +520,9 @@ # Extra repositories checkout_clang_tools_extra=True, checkout_compiler_rt=True, - checkout_lld=True): + checkout_lld=True, + checkout_libcxx=False, + checkout_test_suite=False): return _getClangCMakeBuildFactory( clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs, vs_target_arch=vs_target_arch, useTwoStage=useTwoStage, @@ -513,7 +532,9 @@ env=env, extra_cmake_args=extra_cmake_args, checkout_clang_tools_extra=checkout_clang_tools_extra, checkout_lld=checkout_lld, - checkout_compiler_rt=checkout_compiler_rt) + checkout_compiler_rt=checkout_compiler_rt, + checkout_libcxx=checkout_libcxx, + checkout_test_suite=checkout_test_suite) def _getClangCMakeBuildFactory( clean=True, @@ -546,6 +567,8 @@ checkout_clang_tools_extra=True, checkout_compiler_rt=True, checkout_lld=True, + checkout_libcxx=False, + checkout_test_suite=False, # Upload artifacts to Google Cloud Storage (for the llvmbisect tool) stage1_upload_directory=None, @@ -560,7 +583,8 @@ checkout_clang_tools_extra=checkout_clang_tools_extra, checkout_compiler_rt=checkout_compiler_rt, checkout_lld=checkout_lld, - checkout_test_suite=runTestSuite) + checkout_test_suite=runTestSuite or checkout_test_suite, + checkout_libcxx=checkout_libcxx) # If jobs not defined, Ninja will choose a suitable value jobs_cmd = [] @@ -966,4 +990,3 @@ ignores['gdb-1472-testsuite' ] = gdb_dg_ignores return ignores -