Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions hta/common/trace_stack_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@
def get_matching_kernels(
df_ops: pd.DataFrame, df_both: pd.DataFrame, cat_column: str
) -> pd.DataFrame:
"""Get CUDA Kernels launched by operators in df_ops.
"""Get Kernels launched by operators in df_ops.

Args:
df_ops: a DataFrame that contains cpu operators.
df_both: a DataFrame that contains both cpu operators and CUDA kernels.
df_both: a DataFrame that contains both cpu operators and kernels.
cat_column: the column name for cat in string type, which can be either `cat` or `s_cat`
depending on how the DataFrame symbol columns are encoded/decoded.

Returns:
A DataFrame that contains the CUDA kernels launched by ops in df_ops.
A DataFrame that contains the kernels launched by ops in df_ops.
"""
df_runtimes = df_ops.loc[df_ops[cat_column].eq("cuda_runtime")]
df_runtimes = df_ops.loc[
df_ops[cat_column].isin(["cuda_runtime", "privateuse1_runtime"])
]
df_kernels = df_both.loc[df_both["index_correlation"].isin(df_runtimes["index"])]
return df_kernels

Expand Down
10 changes: 7 additions & 3 deletions hta/common/trace_symbol_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,18 @@ def add_symbols_to_trace_df(self, trace_df: pd.DataFrame, col: str) -> None:

def get_operator_or_cuda_runtime_mask(self, df: pd.DataFrame) -> pd.Series:
"""Returns a boolean mask you can use with pandas dataframes
to filter events that are CUDA runtime events or operators."""
to filter events that are runtime events or operators."""
cpu_op_id = self.sym_index.get("cpu_op")
cuda_runtime_id = self.sym_index.get("cuda_driver", self.NULL)
cuda_driver_id = self.sym_index.get("cuda_runtime", self.NULL)
cuda_runtime_id = self.sym_index.get("cuda_runtime", self.NULL)
cuda_driver_id = self.sym_index.get("cuda_driver", self.NULL)
privateuse1_runtime_id = self.sym_index.get("privateuse1_runtime", self.NULL)
privateuse1_driver_id = self.sym_index.get("privateuse1_driver", self.NULL)
return (
(df["cat"] == cpu_op_id)
| (df["cat"] == cuda_runtime_id)
| (df["cat"] == cuda_driver_id)
| (df["cat"] == privateuse1_runtime_id)
| (df["cat"] == privateuse1_driver_id)
)

def get_runtime_launch_events_mask(self, df: pd.DataFrame) -> pd.Series:
Expand Down
4 changes: 3 additions & 1 deletion hta/common/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def to_grouping_pattern(
)

DEVICE_RUNTIME_CATEGORY_PATTERN = GroupingPattern(
re.compile("(cuda_runtime)|(mtia_runtime)"), False, "Device Runtimes"
re.compile("(cuda_runtime)|(mtia_runtime)|(privateuse1_runtime)"),
False,
"Device Runtimes",
)

MEMORY_CATEGORY_PATTERN = GroupingPattern(
Expand Down