Commit 4bdccdbc authored by one's avatar one
Browse files

Refactor RCCL log parser to enhance transfer reporting

- Rename transfer fields for clarity and introduce separate methods for reporting non-P2P and P2P transfers.
- Add new P2P fields extraction and sorting logic to improve data presentation.
- Update method names and comments for better understanding of functionality.
parent e417e7f5
......@@ -23,7 +23,7 @@ class RcclLogParser:
r"Disabled GDRCopy": "GDRCopy: disabled",
}
# Pattern -> replacement
# Pattern -> column
self.graph_info_fields = {
r"Pattern": "Pattern",
r"crossNic": "crossNic",
......@@ -33,8 +33,8 @@ class RcclLogParser:
r"sameChannels": "sameChannels",
}
# Pattern -> replacement
self.transfer_fields = {
# Pattern -> column
self.cl_transfer_fields = {
r"protocol": "protocol",
r"nbytes": "nbytes",
r"algorithm": "algorithm",
......@@ -45,6 +45,17 @@ class RcclLogParser:
r"chunksize": "chunksize",
}
# Pattern -> column
self.p2p_fields = {
r"p2p : rank": "local",
r"send rank": "send",
r"recv rank": "recv",
r"p2pnChannelsPerPeer": "p2pnChannelsPerPeer",
r"p2pnChannels": "p2pnChannels",
r"nChannelsMax": "nChannelsMax",
r"protocol": "protocol",
}
def collect(self, line):
self.raw_lines.add(line)
......@@ -58,7 +69,8 @@ class RcclLogParser:
self._report_sys()
self._report_user_envs()
self._report_graph_info()
self._report_transfers()
self._report_cl_transfers()
self._report_p2p_transfers()
print(" End of Report ".center(80, "="))
......@@ -127,9 +139,9 @@ class RcclLogParser:
print(extracted_df.fillna("-").to_string(index=False))
print()
def _report_transfers(self):
"""Extract transfer arguments"""
print("===> Unique Transfers:\n")
def _report_cl_transfers(self):
"""Extract non-P2P transfer arguments"""
print("===> Unique Ring/Tree Transfers:\n")
# Filter lines by looking for 'protocol' and 'nbytes'
raw_lines = [
......@@ -143,7 +155,7 @@ class RcclLogParser:
df = pd.DataFrame(raw_lines, columns=["raw_log"])
# Extract all fields using a single loop
for pattern, col_name in self.transfer_fields.items():
for pattern, col_name in self.cl_transfer_fields.items():
df[col_name] = df["raw_log"].str.extract(
rf"\b{pattern}\s+(\S+)", expand=False
)
......@@ -161,12 +173,65 @@ class RcclLogParser:
df.drop(columns=["raw_log"], inplace=True)
df.drop_duplicates(inplace=True)
desired_order = ["nbytes", "protocol", "nchannels"]
sort_cols = [col for col in desired_order if col in df.columns]
sort_cols = ["nbytes", "protocol", "nchannels"]
sort_cols = [col for col in sort_cols if col in df.columns]
if sort_cols:
df.sort_values(by=sort_cols, inplace=True)
# Fill NaNs with "-" and print
print(df.fillna("-").to_string(index=False))
print()
def _report_p2p_transfers(self):
"""Extract P2P transfer details"""
print("===> Unique P2P Transfers:\n")
# Filter lines by looking for 'p2p :' and 'send rank'
raw_lines = [
line for line in self.output if "p2p :" in line and "send rank" in line
]
if not raw_lines:
print(" (No P2P transfers found)\n")
return
# Extract all fields using a single loop
df = pd.DataFrame(raw_lines, columns=["raw_log"])
for pattern, col_name in self.p2p_fields.items():
df[col_name] = df["raw_log"].str.extract(
rf"{pattern}\s+(\S+)", expand=False
)
# Type conversion for correct sorting
numeric_cols = [
"local",
"send",
"recv",
"p2pnChannelsPerPeer",
"p2pnChannels",
"nChannelsMax",
]
for col in numeric_cols:
if col in df.columns:
df[col] = pd.to_numeric(df[col], errors="coerce")
# Clean up
df.drop(columns=["raw_log"], inplace=True)
df.drop_duplicates(inplace=True)
sort_cols = ["protocol", "local", "send", "recv"]
sort_cols = [c for c in sort_cols if c in df.columns]
if sort_cols:
df.sort_values(by=sort_cols, inplace=True)
# Move 'protocol' to the first column
cols = df.columns.tolist()
if "protocol" in cols:
cols.remove("protocol")
cols.insert(0, "protocol")
df = df[cols]
# Fill NaNs with "-" and print
print(df.fillna("-").to_string(index=False))
print()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment