Skip to content

Commit

Permalink
--pc-sampling-beta-enable in ROCProfV3 (#56)
Browse files Browse the repository at this point in the history
PC sampling must be explicitly enabled. 
Emit fatal error otherwise.

Co-authored-by: Madsen, Jonathan <[email protected]>

---------

Co-authored-by: Indic, Vladimir <[email protected]>
Co-authored-by: Madsen, Jonathan <[email protected]>
  • Loading branch information
3 people authored Dec 6, 2024
1 parent 6880dd1 commit 17fdc33
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions source/bin/rocprofv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ def add_parser_bool_argument(gparser, *args, **kwargs):

pc_sampling_options = parser.add_argument_group("PC sampling options")

add_parser_bool_argument(
pc_sampling_options,
"--pc-sampling-beta-enabled",
help="enable pc sampling support; beta version",
)

pc_sampling_options.add_argument(
"--pc-sampling-unit",
help="",
Expand Down Expand Up @@ -981,17 +987,32 @@ def log_config(_env):
if args.log_level in ("info", "trace", "env"):
log_config(app_env)

if args.pc_sampling_unit or args.pc_sampling_method or args.pc_sampling_method:
if args.pc_sampling_unit or args.pc_sampling_method or args.pc_sampling_interval:

if (
not args.pc_sampling_beta_enabled
and os.environ.get("ROCPROFILER_PC_SAMPLING_BETA_ENABLED", None) is None
):
fatal_error(
"PC sampling unavailable. The feature is implicitly disabled. To enable it, use --pc-sampling-beta-enable option or set ROCPROFILER_PC_SAMPLING_BETA_ENABLED=ON in the environment"
)

update_env(
"ROCPROFILER_PC_SAMPLING_BETA_ENABLED",
args.pc_sampling_beta_enabled,
overwrite_if_true=True,
)

if not (
args.pc_sampling_unit and args.pc_sampling_method and args.pc_sampling_method
args.pc_sampling_unit
and args.pc_sampling_method
and args.pc_sampling_interval
):
fatal_error("All three PC sampling configurations need to be set")

update_env("ROCPROFILER_PC_SAMPLING_BETA_ENABLED", "ON")
update_env("ROCPROF_PC_SAMPLING_UNIT", args.pc_sampling_unit)
update_env("ROCPROF_PC_SAMPLING_METHOD", args.pc_sampling_method)
update_env("ROCPROF_PC_SAMPLING_INTERVAL", args.pc_sampling_interval)
update_env("ROCPROF_ENABLE_PC_SAMPLING", args.pc_sampling)

if use_execv:
# does not return
Expand Down

0 comments on commit 17fdc33

Please sign in to comment.