Skip to content

Commit

Permalink
Merge Pull Request #11616 from sebrowne/Trilinos/sebrown/ccache
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: Framework: Enable ccache for PR builds
PR Author: sebrowne
  • Loading branch information
trilinos-autotester committed Mar 6, 2023
2 parents af4fd8e + b48d1b8 commit b30c097
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 55 deletions.
39 changes: 11 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,17 @@ PROJECT(${PROJECT_NAME} NONE)

# Set up to use ccache
if($ENV{CCACHE_NODISABLE})
# ccache must be requested explicitly by setting env-var CCACHE_NODISABLE
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
# Set up wrapper scripts
set(C_LAUNCHER "${CCACHE_PROGRAM}")
set(CXX_LAUNCHER "${CCACHE_PROGRAM}")
configure_file(launch-c.in launch-c)
configure_file(launch-cxx.in launch-cxx)
execute_process(COMMAND chmod a+rx
"${CMAKE_BINARY_DIR}/launch-c"
"${CMAKE_BINARY_DIR}/launch-cxx"
)

if(CMAKE_GENERATOR STREQUAL "Xcode")
# Set Xcode project attributes to route compilation and linking
# through our scripts
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx")
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx")
else()
# Support Unix Makefiles and Ninja
set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-cxx")
endif()
else()
message(WARNING "ccache requested but not found")
endif()
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
if(CMAKE_GENERATOR STREQUAL "Xcode")
message(FATAL_ERROR "ccache not supported with Xcode in Trilinos")
else()
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
else()
message(FATAL_ERROR "ccache requested but not found")
endif()
endif()

# Set an env so we know we are in configure
Expand Down
10 changes: 0 additions & 10 deletions launch-c.in

This file was deleted.

10 changes: 0 additions & 10 deletions launch-cxx.in

This file was deleted.

3 changes: 1 addition & 2 deletions packages/framework/ini-files/config-specs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@
opt-set-cmake-var CMAKE_GENERATOR STRING : Ninja
#opt-set-cmake-var Trilinos_ENABLE_BUILD_STATS BOOL : ON

# LINK_JOBS_LIMIT only has an affect when CMAKE_GENERATOR=Ninja, default to 2
opt-set-cmake-var Trilinos_PARALLEL_LINK_JOBS_LIMIT STRING : 2
opt-set-cmake-var Trilinos_PARALLEL_LINK_JOBS_LIMIT STRING : 8

# Misc options typically added by CI testing mode in TriBITS
opt-set-cmake-var Trilinos_ENABLE_ALL_OPTIONAL_PACKAGES BOOL : ON
Expand Down
15 changes: 15 additions & 0 deletions packages/framework/pr_tools/PullRequestLinuxDriver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ source ${SCRIPTPATH:?}/common.bash
on_weaver=$(echo "$@" | grep '\-\-on_weaver' &> /dev/null && echo "1")
on_ats2=$(echo "$@" | grep '\-\-on_ats2' &> /dev/null && echo "1")

# Configure ccache via environment variables
function configure_ccache() {
print_banner "Configuring ccache"

envvar_set_or_create CCACHE_NODISABLE true
envvar_set_or_create CCACHE_DIR '/fgs/trilinos/ccache/cache'
envvar_set_or_create CCACHE_BASEDIR "${WORKSPACE:?}"
envvar_set_or_create CCACHE_NOHARDLINK true
envvar_set_or_create CCACHE_UMASK 077
envvar_set_or_create CCACHE_MAXSIZE 100G

message_std "PRDriver> " "$(ccache --show-stats --verbose)"
}

# Load the right version of Git / Python based on a regex
# match to the Jenkins job name.
Expand Down Expand Up @@ -35,6 +48,8 @@ function bootstrap_modules() {
execute_command_checked "module unload sems-archive-git"
execute_command_checked "module unload sems-archive-python"
execute_command_checked "module load sems-archive-git/2.10.1"
execute_command_checked "module load sems-ccache"
configure_ccache

envvar_set_or_create PYTHON_EXE $(which python3)
fi
Expand Down
7 changes: 7 additions & 0 deletions packages/framework/pr_tools/PullRequestLinuxDriverTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ def parse_args():
"based on number_of_available_cores / max_test_parallelism" + \
" Default = %(default)s")

optional.add_argument("--enable-ccache",
dest="ccache_enable",
action="store_true",
default=False,
help="Enable ccache object caching to improve build times. Default = %(default)s")

optional.add_argument("--dry-run",
dest="dry_run",
action="store_true",
Expand Down Expand Up @@ -257,6 +263,7 @@ def parse_args():
print("| - [R] ctest-drop-site : {ctest_drop_site}".format(**vars(arguments)))
print("|")
print("| - [O] dry-run : {dry_run}".format(**vars(arguments)))
print("| - [O] enable-ccache : {ccache_enable}".format(**vars(arguments)))
print("| - [O] filename-packageenables : {filename_packageenables}".format(**vars(arguments)))
print("| - [O] max-cores-allowed : {max_cores_allowed}".format(**vars(arguments)))
print("| - [O] num-concurrent-tests : {num_concurrent_tests}".format(**vars(arguments)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

sys.dont_write_bytecode = True

from . import sysinfo
from .sysinfo import SysInfo
from LoadEnv.load_env import LoadEnv
import setenvironment

Expand All @@ -24,7 +24,7 @@
class TrilinosPRConfigurationBase(object):
"""
Trilinos Pull Request configuration driver. This should be
treated as an Abstract Base Class because the `execute()`
treated as an Abstract Base Class because the `execute_test()`
method is implemented as a stub.
Note: Attributes / Properties prefixed with `arg_` come from the
Expand All @@ -45,6 +45,7 @@ class TrilinosPRConfigurationBase(object):
variable set by Jenkins.)
arg_pr_config_file: The config.ini file that specifies the configuration to load.
arg_pr_jenkins_job_name: The Jenkins Job Name.
arg_ccache_enable: Enable ccache.
filename_subprojects: The subprojects file.
working_directory_ctest: Gen. working dir where TFW_testing_single_configure_prototype
is executed from.
Expand All @@ -63,6 +64,7 @@ class TrilinosPRConfigurationBase(object):
"""
def __init__(self, args):
self.args = args
self.load_env_ini_file = None
self._config_data = None
self._mem_per_core = None
self._max_cores_allowed = None
Expand Down Expand Up @@ -276,6 +278,10 @@ def arg_filename_subprojects(self):
"""
return self.args.filename_subprojects

@property
def arg_ccache_enable(self):
"""Is ccache enabled?"""
return self.args.ccache_enable

# --------------------
# P R O P E R T I E S
Expand Down Expand Up @@ -399,7 +405,7 @@ def concurrency_build(self):
This is equvalent to running `make -j <concurrency_build>` from the command line.
"""
if self._concurrency_build is None:
si = sysinfo.SysInfo()
si = SysInfo()

self._concurrency_build = si.compute_num_usable_cores(req_mem_gb_per_core = self.arg_req_mem_per_core,
max_cores_allowed = self.max_cores_allowed)
Expand Down Expand Up @@ -445,6 +451,9 @@ def pullrequest_build_name(self):
# M E T H O D S
# --------------------

def get_formatted_msg(self, msg):
pass

def message(self, text, debug_level_override=None):
"""
A simple wrapper to print out a message to the console output that
Expand Down Expand Up @@ -686,6 +695,7 @@ def prepare_test(self):
self.message("--- arg_build_dir = {}".format(self.arg_build_dir))
self.message("--- arg_ctest_driver = {}".format(self.arg_ctest_driver))
self.message("--- arg_ctest_drop_site = {}".format(self.arg_ctest_drop_site))
self.message("--- arg_ccache_enable = {}".format(self.arg_ccache_enable))
self.message("")
self.message("--- concurrency_build = {}".format(self.concurrency_build))
self.message("--- concurrency_test = {}".format(self.concurrency_test))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def dummy_args(self):
req_mem_per_core=3.0,
max_cores_allowed=12,
num_concurrent_tests=-1,
ccache_enable=False,
dry_run=False
)
return output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def dummy_args(self):
req_mem_per_core=3.0,
max_cores_allowed=12,
num_concurrent_tests=-1,
ccache_enable=False,
dry_run = False
)
return output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def dummy_args(self):
req_mem_per_core=3.0,
max_cores_allowed=12,
num_concurrent_tests=-1,
ccache_enable=False,
dry_run = False
)
return output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def setUp(self):
req_mem_per_core=3.0,
max_cores_allowed=12,
num_concurrent_tests=-1,
ccache_enable=False,
dry_run=False)

self.default_stdout = dedent('''\
Expand All @@ -101,6 +102,7 @@ def setUp(self):
| - [R] ctest-drop-site : testing.sandia.gov
|
| - [O] dry-run : False
| - [O] enable-ccache : False
| - [O] filename-packageenables : ../packageEnables.cmake
| - [O] max-cores-allowed : 12
| - [O] num-concurrent-tests : -1
Expand Down Expand Up @@ -132,7 +134,8 @@ def setUp(self):
[--test-mode TEST_MODE]
[--req-mem-per-core REQ_MEM_PER_CORE]
[--max-cores-allowed MAX_CORES_ALLOWED]
[--num-concurrent-tests NUM_CONCURRENT_TESTS] [--dry-run]
[--num-concurrent-tests NUM_CONCURRENT_TESTS]
[--enable-ccache] [--dry-run]
Parse the repo and build information
Expand Down Expand Up @@ -208,6 +211,8 @@ def setUp(self):
tests>`. If > 0 then this value is used, otherwise the
value is calculated based on number_of_available_cores
/ max_test_parallelism Default = -1
--enable-ccache Enable ccache object caching to improve build times.
Default = False
--dry-run Enable dry-run mode. Script will run but not execute
the build steps. Default = False
''')
Expand All @@ -232,7 +237,8 @@ def setUp(self):
[--test-mode TEST_MODE]
[--req-mem-per-core REQ_MEM_PER_CORE]
[--max-cores-allowed MAX_CORES_ALLOWED]
[--num-concurrent-tests NUM_CONCURRENT_TESTS] [--dry-run]
[--num-concurrent-tests NUM_CONCURRENT_TESTS]
[--enable-ccache] [--dry-run]
programName: error: the following arguments are required: --source-repo-url, --source-branch-name, --target-repo-url, --target-branch-name, --pullrequest-build-name, --genconfig-build-name, --pullrequest-number, --jenkins-job-number
''')

Expand Down

0 comments on commit b30c097

Please sign in to comment.