Skip to content

Commit b5cd71f

Browse files
authored
Tag memcopy names with p2p if they qualify (#4)
* Tag memcopy names with p2p if they qualify Signed-off-by: Aswani, Mahesh <[email protected]> * clang-formatted --------- Signed-off-by: Aswani, Mahesh <[email protected]>
1 parent c7cc342 commit b5cd71f

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

sdk/src/levelzero/ze_collector.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,13 +2455,16 @@ overhead::Init();
24552455
PTI_ASSERT(!name.empty());
24562456

24572457
std::string direction;
2458+
ze_device_handle_t hSrcDevice = nullptr;
2459+
ze_device_handle_t hDstDevice = nullptr;
2460+
bool p2p = false;
24582461

24592462
if (src_context != nullptr && src != nullptr) {
24602463
ze_memory_allocation_properties_t props;
24612464
props.stype = ZE_STRUCTURE_TYPE_MEMORY_ALLOCATION_PROPERTIES;
24622465
props.pNext = nullptr;
24632466
overhead::Init();
2464-
ze_result_t status = zeMemGetAllocProperties(src_context, src, &props, nullptr);
2467+
ze_result_t status = zeMemGetAllocProperties(src_context, src, &props, &hSrcDevice);
24652468
{
24662469
std::string o_api_string = "zeMemGetAllocProperties";
24672470
overhead::FiniLevel0(overhead::OverheadRuntimeType::OVERHEAD_RUNTIME_TYPE_L0,
@@ -2472,17 +2475,22 @@ overhead::Init();
24722475
switch (props.type) {
24732476
case ZE_MEMORY_TYPE_UNKNOWN:
24742477
direction.push_back('M');
2478+
p2p = false;
24752479
break;
24762480
case ZE_MEMORY_TYPE_HOST:
24772481
direction.push_back('H');
2482+
p2p = false;
24782483
break;
24792484
case ZE_MEMORY_TYPE_DEVICE:
24802485
direction.push_back('D');
2486+
p2p = true;
24812487
break;
24822488
case ZE_MEMORY_TYPE_SHARED:
24832489
direction.push_back('S');
2490+
p2p = true;
24842491
break;
24852492
default:
2493+
p2p = false;
24862494
break;
24872495
}
24882496
}
@@ -2493,7 +2501,7 @@ overhead::Init();
24932501
props.pNext = nullptr;
24942502
props.pNext = nullptr;
24952503
overhead::Init();
2496-
ze_result_t status = zeMemGetAllocProperties(dst_context, dst, &props, nullptr);
2504+
ze_result_t status = zeMemGetAllocProperties(dst_context, dst, &props, &hDstDevice);
24972505
{
24982506
std::string o_api_string = "zeMemGetAllocProperties";
24992507
overhead::FiniLevel0(overhead::OverheadRuntimeType::OVERHEAD_RUNTIME_TYPE_L0,
@@ -2505,9 +2513,11 @@ overhead::Init();
25052513
switch (props.type) {
25062514
case ZE_MEMORY_TYPE_UNKNOWN:
25072515
direction.push_back('M');
2516+
p2p = false;
25082517
break;
25092518
case ZE_MEMORY_TYPE_HOST:
25102519
direction.push_back('H');
2520+
p2p = false;
25112521
break;
25122522
case ZE_MEMORY_TYPE_DEVICE:
25132523
direction.push_back('D');
@@ -2516,11 +2526,13 @@ overhead::Init();
25162526
direction.push_back('S');
25172527
break;
25182528
default:
2529+
p2p = false;
25192530
break;
25202531
}
25212532
}
25222533

25232534
if (!direction.empty()) {
2535+
if (p2p && hSrcDevice && hDstDevice && (hSrcDevice != hDstDevice)) direction.append(" - P2P");
25242536
name += "(" + direction + ")";
25252537
}
25262538

sdk/src/view_handler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,8 @@ inline void SetMemFillType(pti_view_record_memory_fill& mem_record,
496496
inline void SetMemCopyType(pti_view_record_memory_copy& mem_record,
497497
const ZeKernelCommandExecutionRecord& rec) {
498498
std::size_t found_pos = rec.name_.find_last_of("(");
499-
std::string tmp_str = rec.name_.substr(found_pos);
499+
std::string tmp_str = rec.name_.substr(found_pos, 4);
500+
tmp_str.push_back(')');
500501
if (tmp_str == "(M2M)") {
501502
mem_record._memcpy_type = pti_view_memcpy_type::PTI_VIEW_MEMCPY_TYPE_M2M;
502503
mem_record._mem_src = pti_view_memory_type::PTI_VIEW_MEMORY_TYPE_MEMORY;

0 commit comments

Comments
 (0)