Skip to content

Commit a743626

Browse files
Add shared system USM support to stream benchmark
Signed-off-by: Michal Mrozek <[email protected]>
1 parent dff87c2 commit a743626

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

source/benchmarks/memory_benchmark/implementations/l0/stream_memory_l0.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ static TestResult run(const StreamMemoryArguments &arguments, Statistics &statis
4343
if (levelzero.commandQueue == nullptr) {
4444
return TestResult::DeviceNotCapable;
4545
}
46+
if (isSharedSystemPointer(arguments.memoryPlacement)) {
47+
ze_device_memory_access_properties_t memoryAccessCapabilities = {};
48+
ASSERT_ZE_RESULT_SUCCESS(zeDeviceGetMemoryAccessProperties(levelzero.device, &memoryAccessCapabilities));
49+
if (memoryAccessCapabilities.sharedSystemAllocCapabilities == 0) {
50+
return TestResult::DeviceNotCapable;
51+
}
52+
if (arguments.contents != BufferContents::Zeros) {
53+
return TestResult::NoImplementation;
54+
}
55+
}
4656
Timer timer;
4757

4858
// Query double support
@@ -143,7 +153,11 @@ static TestResult run(const StreamMemoryArguments &arguments, Statistics &statis
143153

144154
// Enqueue filling of the buffers and set kernel arguments
145155
for (auto i = 0u; i < buffersCount; i++) {
146-
ASSERT_ZE_RESULT_SUCCESS(BufferContentsHelperL0::fillBuffer(levelzero, buffers[i], bufferSizes[i], arguments.contents, false));
156+
if (isSharedSystemPointer(arguments.memoryPlacement)) {
157+
memset(buffers[i], 0u, bufferSizes[i]);
158+
} else {
159+
ASSERT_ZE_RESULT_SUCCESS(BufferContentsHelperL0::fillBuffer(levelzero, buffers[i], bufferSizes[i], arguments.contents, false));
160+
}
147161
ASSERT_ZE_RESULT_SUCCESS(zeKernelSetArgumentValue(kernel, static_cast<int>(i), sizeof(buffers[i]), &buffers[i]));
148162
}
149163
if (setScalarArgument) {
@@ -165,6 +179,11 @@ static TestResult run(const StreamMemoryArguments &arguments, Statistics &statis
165179

166180
// Benchmark
167181
for (auto i = 0u; i < arguments.iterations; i++) {
182+
if (isSharedSystemPointer(arguments.memoryPlacement)) {
183+
for (auto id = 0u; id < buffersCount; id++) {
184+
memset(buffers[id], 0u, bufferSizes[id]);
185+
}
186+
}
168187
// Launch kernel
169188
timer.measureStart();
170189
ASSERT_ZE_RESULT_SUCCESS(zeCommandQueueExecuteCommandLists(levelzero.commandQueue, 1, &cmdList, 0));
@@ -199,7 +218,7 @@ static TestResult run(const StreamMemoryArguments &arguments, Statistics &statis
199218
ASSERT_ZE_RESULT_SUCCESS(zeEventDestroy(event));
200219
ASSERT_ZE_RESULT_SUCCESS(zeEventPoolDestroy(eventPool));
201220
for (size_t i = 0; i < buffersCount; i++) {
202-
ASSERT_ZE_RESULT_SUCCESS(zeMemFree(levelzero.context, buffers[i]));
221+
ASSERT_ZE_RESULT_SUCCESS(UsmHelper::deallocate(arguments.memoryPlacement, levelzero, buffers[i]));
203222
}
204223
ASSERT_ZE_RESULT_SUCCESS(zeCommandListDestroy(cmdList));
205224
ASSERT_ZE_RESULT_SUCCESS(zeKernelDestroy(kernel));

source/framework/enum/usm_memory_placement.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ inline constexpr bool requiresImport(UsmMemoryPlacement inputType) {
3333
return false;
3434
}
3535

36+
inline constexpr bool isSharedSystemPointer(UsmMemoryPlacement inputType) {
37+
if (inputType == UsmMemoryPlacement::NonUsm ||
38+
inputType == UsmMemoryPlacement::NonUsmMisaligned ||
39+
inputType == UsmMemoryPlacement::NonUsm4KBAligned ||
40+
inputType == UsmMemoryPlacement::NonUsm2MBAligned) {
41+
return true;
42+
}
43+
return false;
44+
}
45+
3646
inline constexpr bool isUsmMemoryType(UsmMemoryPlacement inputType) {
3747
switch (inputType) {
3848
case UsmMemoryPlacement::Host:

0 commit comments

Comments
 (0)