Skip to content

Commit db58e50

Browse files
Jaime ArteagaCompute-Runtime-Automation
Jaime Arteaga
authored andcommitted
Improve PrintUmdSharedMigration
Add size and timing data. Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
1 parent 2942a48 commit db58e50

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

level_zero/core/source/memory/cpu_page_fault_memory_manager.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,17 @@ void handleGpuDomainTransferForHwWithHints(NEO::PageFaultManager *pageFaultHandl
5656
}
5757
}
5858
if (migration) {
59+
std::chrono::steady_clock::time_point start;
60+
std::chrono::steady_clock::time_point end;
61+
62+
start = std::chrono::steady_clock::now();
63+
pageFaultHandler->transferToCpu(allocPtr, pageFaultData.size, pageFaultData.cmdQ);
64+
end = std::chrono::steady_clock::now();
65+
long long elapsedTime = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
66+
5967
if (NEO::DebugManager.flags.PrintUmdSharedMigration.get()) {
60-
printf("UMD transferring shared allocation %llx from GPU to CPU\n", reinterpret_cast<unsigned long long int>(allocPtr));
68+
printf("UMD transferred shared allocation %llx (%zu B) from GPU to CPU (%f us)\n", reinterpret_cast<unsigned long long int>(allocPtr), pageFaultData.size, elapsedTime / 1e3);
6169
}
62-
pageFaultHandler->transferToCpu(allocPtr, pageFaultData.size, pageFaultData.cmdQ);
6370
}
6471
}
6572
if (migration) {

level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ TEST_F(CommandListMemAdvisePageFault, givenValidPtrAndPageFaultHandlerAndGpuDoma
578578

579579
std::string output = testing::internal::GetCapturedStdout(); // stop capturing
580580

581-
std::string expectedString = "UMD transferring shared allocation";
581+
std::string expectedString = "UMD transferred shared allocation";
582582
uint32_t occurrences = 0u;
583583
uint32_t expectedOccurrences = 1u;
584584
size_t idx = output.find(expectedString);

shared/source/page_fault_manager/cpu_page_fault_manager.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,18 @@ void PageFaultManager::moveAllocationsWithinUMAllocsManagerToGpuDomain(SVMAllocs
7171

7272
inline void PageFaultManager::migrateStorageToGpuDomain(void *ptr, PageFaultData &pageFaultData) {
7373
if (pageFaultData.domain == AllocationDomain::Cpu) {
74+
std::chrono::steady_clock::time_point start;
75+
std::chrono::steady_clock::time_point end;
76+
77+
start = std::chrono::steady_clock::now();
78+
this->transferToGpu(ptr, pageFaultData.cmdQ);
79+
end = std::chrono::steady_clock::now();
80+
long long elapsedTime = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
81+
7482
if (DebugManager.flags.PrintUmdSharedMigration.get()) {
75-
printf("UMD transferring shared allocation %llx from CPU to GPU\n", reinterpret_cast<unsigned long long int>(ptr));
83+
printf("UMD transferred shared allocation %llx (%zu B) from CPU to GPU (%f us)\n", reinterpret_cast<unsigned long long int>(ptr), pageFaultData.size, elapsedTime / 1e3);
7684
}
77-
this->transferToGpu(ptr, pageFaultData.cmdQ);
85+
7886
this->protectCPUMemoryAccess(ptr, pageFaultData.size);
7987
}
8088
pageFaultData.domain = AllocationDomain::Gpu;
@@ -110,10 +118,17 @@ void PageFaultManager::handleGpuDomainTransferForAubAndTbx(PageFaultManager *pag
110118

111119
inline void PageFaultManager::migrateStorageToCpuDomain(void *ptr, PageFaultData &pageFaultData) {
112120
if (pageFaultData.domain == AllocationDomain::Gpu) {
121+
std::chrono::steady_clock::time_point start;
122+
std::chrono::steady_clock::time_point end;
123+
124+
start = std::chrono::steady_clock::now();
125+
this->transferToCpu(ptr, pageFaultData.size, pageFaultData.cmdQ);
126+
end = std::chrono::steady_clock::now();
127+
long long elapsedTime = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
128+
113129
if (DebugManager.flags.PrintUmdSharedMigration.get()) {
114-
printf("UMD transferring shared allocation %llx from GPU to CPU\n", reinterpret_cast<unsigned long long int>(ptr));
130+
printf("UMD transferred shared allocation %llx (%zu B) from GPU to CPU (%f us)\n", reinterpret_cast<unsigned long long int>(ptr), pageFaultData.size, elapsedTime / 1e3);
115131
}
116-
this->transferToCpu(ptr, pageFaultData.size, pageFaultData.cmdQ);
117132
pageFaultData.unifiedMemoryManager->nonGpuDomainAllocs.push_back(ptr);
118133
}
119134
pageFaultData.domain = AllocationDomain::Cpu;

shared/test/unit_test/page_fault_manager/cpu_page_fault_manager_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocsWhenMovingToGpuDomainWithPr
195195

196196
std::string output = testing::internal::GetCapturedStdout(); // stop capturing
197197

198-
std::string expectedString = "UMD transferring shared allocation";
198+
std::string expectedString = "UMD transferred shared allocation";
199199
uint32_t occurrences = 0u;
200200
uint32_t expectedOccurrences = 1u;
201201
size_t idx = output.find(expectedString);
@@ -290,7 +290,7 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocWhenMoveToGpuDomainWithPrint
290290

291291
std::string output = testing::internal::GetCapturedStdout(); // stop capturing
292292

293-
std::string expectedString = "UMD transferring shared allocation";
293+
std::string expectedString = "UMD transferred shared allocation";
294294
uint32_t occurrences = 0u;
295295
uint32_t expectedOccurrences = 1u;
296296
size_t idx = output.find(expectedString);
@@ -488,7 +488,7 @@ TEST_F(PageFaultManagerTest, whenVerifyingPagefaultWithPrintUsmSharedMigrationDe
488488
EXPECT_EQ(pageFaultManager->accessAllowedSize, 10u);
489489
EXPECT_TRUE(pageFaultManager->isAubWritable);
490490

491-
std::string expectedString = "UMD transferring shared allocation";
491+
std::string expectedString = "UMD transferred shared allocation";
492492
uint32_t occurrences = 0u;
493493
uint32_t expectedOccurrences = 1u;
494494
size_t idx = output.find(expectedString);
@@ -527,7 +527,7 @@ TEST_F(PageFaultManagerTest, givenTbxWhenVerifyingPagefaultWithPrintUsmSharedMig
527527
EXPECT_EQ(pageFaultManager->accessAllowedSize, 10u);
528528
EXPECT_TRUE(pageFaultManager->isAubWritable);
529529

530-
std::string expectedString = "UMD transferring shared allocation";
530+
std::string expectedString = "UMD transferred shared allocation";
531531
uint32_t occurrences = 0u;
532532
uint32_t expectedOccurrences = 1u;
533533
size_t idx = output.find(expectedString);

0 commit comments

Comments
 (0)