Skip to content

Commit 2e97726

Browse files
tarun292facebook-github-bot
authored andcommitted
Remove profiler time hooks deps
Summary: This diff gets rid of the need for separate time hooks in the profiler code base. We switch over the profiler to use the time hook available in PAL. For Jarvis added an implementation for `et_pal_current_ticks` that is only brought in when compiling for Xtensa. If compiling for devserver in Jarvis, it'll fall back to the default POSIX implementation. Reviewed By: larryliu0820, cccclai Differential Revision: D47637865 fbshipit-source-id: 86c61c7f00bfa9be18c8257c115ecb1d0bb754a3
1 parent 9189e09 commit 2e97726

File tree

10 files changed

+23
-70
lines changed

10 files changed

+23
-70
lines changed

profiler/TARGETS

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary")
55
load("@fbcode_macros//build_defs:python_library.bzl", "python_library")
6-
load(":targets.bzl", "define_common_targets")
7-
8-
define_common_targets()
96

107
python_library(
118
name = "parse_profiler_library",

profiler/profiler.bzl

Lines changed: 0 additions & 22 deletions
This file was deleted.

profiler/targets.bzl

Lines changed: 0 additions & 31 deletions
This file was deleted.

runtime/backend/targets.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ def define_common_targets():
2626
"//executorch/runtime/core:core",
2727
"//executorch/runtime/core:evalue" + aten_suffix,
2828
"//executorch/runtime/core:memory_allocator",
29-
"//executorch/profiler:profiler",
3029
],
3130
)

runtime/core/targets.bzl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ def define_common_targets():
2222
"//executorch/...",
2323
"@EXECUTORCH_CLIENTS",
2424
],
25-
deps = [
26-
"//executorch/profiler:profiler",
27-
],
2825
exported_deps = [
2926
"//executorch/runtime/platform:platform",
3027
],
@@ -47,9 +44,6 @@ def define_common_targets():
4744
"hierarchical_allocator.h",
4845
"memory_allocator.h",
4946
],
50-
deps = [
51-
"//executorch/profiler:profiler",
52-
],
5347
exported_deps = [
5448
":core",
5549
],

runtime/executor/targets.bzl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def define_common_targets():
5050
"//executorch/runtime/platform:platform",
5151
"//executorch/schema:extended_header",
5252
"//executorch/schema:schema",
53-
"//executorch/profiler:profiler",
5453
],
5554
preprocessor_flags = _program_preprocessor_flags(),
5655
exported_deps = ["//executorch/runtime/core:core"],
@@ -71,7 +70,6 @@ def define_common_targets():
7170
"//executorch/runtime/backend:backend_registry",
7271
"//executorch/kernels/prim_ops:prim_ops_registry" + aten_suffix,
7372
"//executorch/runtime/kernel:kernel_runtime_context" + aten_suffix,
74-
"//executorch/profiler:profiler",
7573
"//executorch/schema:schema",
7674
],
7775
exported_deps = [

runtime/platform/profiler.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <executorch/runtime/platform/assert.h>
44
#include <executorch/runtime/platform/hooks.h>
5+
#include <executorch/runtime/platform/platform.h>
56
#include <executorch/runtime/platform/profiler.h>
67
#include <inttypes.h>
78

@@ -59,13 +60,13 @@ uint32_t begin_profiling(const char* name) {
5960
prof_arr[curr_counter].instruction_idx = state.instruction_idx;
6061
// Set start time at the last to ensure that we're not capturing
6162
// any of the overhead in this function.
62-
prof_arr[curr_counter].start_time = get_curr_time();
63+
prof_arr[curr_counter].start_time = et_pal_current_ticks();
6364
return curr_counter;
6465
}
6566

6667
void end_profiling(uint32_t token_id) {
6768
ET_CHECK_MSG(token_id < MAX_PROFILE_EVENTS, "Invalid token id.");
68-
prof_arr[token_id].end_time = get_curr_time();
69+
prof_arr[token_id].end_time = et_pal_current_ticks();
6970
}
7071

7172
void dump_profile_stats(prof_result_t* prof_result) {

runtime/platform/targets.bzl

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ def _select_pal(dict_):
1010
fail("Missing key for executorch.pal_default value '{}' in dict '{}'".format(pal_default, dict_))
1111
return dict_[pal_default]
1212

13+
def profiling_enabled():
14+
return native.read_config("executorch", "prof_enabled", "false") == "true"
15+
16+
def get_profiling_flags():
17+
profiling_flags = []
18+
if profiling_enabled():
19+
profiling_flags += ["-DPROFILING_ENABLED"]
20+
prof_buf_size = native.read_config("executorch", "prof_buf_size", None)
21+
if prof_buf_size != None:
22+
if not profiling_enabled():
23+
fail("Cannot set profiling buffer size without enabling profiling first.")
24+
profiling_flags += ["-DMAX_PROFILE_EVENTS={}".format(prof_buf_size), "-DMAX_MEM_PROFILE_EVENTS={}".format(prof_buf_size)]
25+
num_prof_blocks = native.read_config("executorch", "num_prof_blocks", None)
26+
if num_prof_blocks != None:
27+
if not profiling_enabled():
28+
fail("Cannot configure number of profiling blocks without enabling profiling first.")
29+
profiling_flags += ["-DMAX_PROFILE_BLOCKS={}".format(num_prof_blocks)]
30+
return profiling_flags
31+
1332
def define_common_targets():
1433
"""Defines targets that should be shared between fbcode and xplat.
1534
@@ -49,11 +68,11 @@ def define_common_targets():
4968
"profiler.cpp",
5069
"runtime.cpp",
5170
],
71+
exported_preprocessor_flags = get_profiling_flags(),
5272
exported_deps = [
5373
"//executorch/runtime/platform:pal_interface",
5474
":compiler",
5575
":platform_private",
56-
"//executorch/profiler:profiler",
5776
],
5877
visibility = [
5978
"//executorch/...",

sdk/etdump/tests/targets.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def define_common_targets():
1414
],
1515
deps = [
1616
"//executorch/runtime/core:memory_allocator",
17-
"//executorch/profiler:profiler",
1817
"//executorch/sdk/etdump:etdump_gen",
1918
],
2019
preprocessor_flags = ["-DPROFILING_ENABLED"],

shim/xplat/executorch/codegen/codegen.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ def executorch_generated_lib(
366366
"//executorch/runtime/kernel:operator_registry",
367367
"//executorch/kernels/prim_ops:prim_ops_registry" + aten_suffix,
368368
"//executorch/runtime/core:evalue" + aten_suffix,
369-
"//executorch/profiler:profiler",
370369
"//executorch/codegen:macros",
371370
] + deps,
372371
exported_deps = [

0 commit comments

Comments
 (0)