File indexing completed on 2026-07-26 08:22:17
0001
0002
0003
0004
0005 import subprocess
0006 import pathlib
0007 import logging
0008 import os
0009
0010 from . import git
0011
0012 log = logging.getLogger("traccc_benchmark")
0013
0014
0015 DETERMINISTIC_ORDER_COMMIT = "7e7f17ccd2e2b0db8971655773b351a365ee1cfc"
0016 DETERMINISTIC_DEFAULT_COMMIT = "80e34dc2195fc3897f1d7d97a71c0701edaa6aa1"
0017 BOOLEAN_FLAG_COMMIT = "380fc78ba63a79ed5c8f19d01d57636aa31cf4fd"
0018 INHOMOGENEOUS_BFIELD_COMMIT = "3654a64d5fe06509e6bf8be332f5aae7b8ff2da9"
0019
0020
0021 def run_profile(
0022 build_dir: pathlib.Path, data_dir: str, commit, events=1, ncu_wrapper=None
0023 ):
0024 profile_args = [
0025 "ncu",
0026 "--import-source",
0027 "no",
0028 "--section LaunchStats",
0029 "--section Occupancy",
0030 "--metrics gpu__time_duration.sum",
0031 "-f",
0032 "-o",
0033 build_dir / "profile",
0034 build_dir / "bin" / "traccc_throughput_st_cuda",
0035 "--input-directory=%s" % data_dir,
0036 "--digitization-file=geometries/odd/odd-digi-geometric-config.json",
0037 "--conditions-file=geometries/odd/odd-digi-geometric-config.json",
0038 "--detector-file=geometries/odd/odd-detray_geometry_detray.json",
0039 "--grid-file=geometries/odd/odd-detray_surface_grids_detray.json",
0040 "--input-events=%d" % events,
0041 "--cold-run-events=0",
0042 "--processed-events=%d" % events,
0043 ]
0044
0045 if ncu_wrapper is not None:
0046 profile_args = ncu_wrapper.split() + profile_args
0047
0048 if git.is_parent_of(commit, DETERMINISTIC_DEFAULT_COMMIT):
0049 log.info(
0050 "Commit is a child of (or is) %s; deterministic processing is default",
0051 DETERMINISTIC_DEFAULT_COMMIT[:8],
0052 )
0053 elif git.is_parent_of(commit, DETERMINISTIC_ORDER_COMMIT):
0054 log.info(
0055 "Commit is a child of (or is) %s; enabling deterministic processing",
0056 DETERMINISTIC_ORDER_COMMIT[:8],
0057 )
0058 profile_args.append("--deterministic")
0059 else:
0060 log.info(
0061 "Commit is not a child of %s; event order is random",
0062 DETERMINISTIC_ORDER_COMMIT[:8],
0063 )
0064
0065 if git.is_parent_of(commit, BOOLEAN_FLAG_COMMIT):
0066 log.info(
0067 "Commit is a child of (or is) %s; using explicit boolean flags",
0068 BOOLEAN_FLAG_COMMIT[:8],
0069 )
0070 profile_args.append("--use-acts-geom-source=1")
0071 profile_args.append("--use-detray-detector=1")
0072 else:
0073 log.info(
0074 "Commit is not a child of %s; using implicit boolean flags",
0075 BOOLEAN_FLAG_COMMIT[:8],
0076 )
0077 profile_args.append("--use-acts-geom-source")
0078 profile_args.append("--use-detray-detector")
0079
0080 if git.is_parent_of(commit, INHOMOGENEOUS_BFIELD_COMMIT):
0081 log.info(
0082 "Commit is a child of (or is) %s; enabling inhomogeneous magnetic field",
0083 INHOMOGENEOUS_BFIELD_COMMIT[:8],
0084 )
0085 profile_args.append("--read-bfield-from-file")
0086 profile_args.append("--bfield-file=geometries/odd/odd-bfield.cvf")
0087 else:
0088 log.info(
0089 "Commit is not a child of %s; disabling inhomogeneous magnetic field",
0090 INHOMOGENEOUS_BFIELD_COMMIT[:8],
0091 )
0092
0093 subprocess.run(
0094 profile_args,
0095 stdout=subprocess.DEVNULL,
0096 check=True,
0097 )