Skip to content

Commit 433ea9b

Browse files
Add scenarios using copy engine to memory copy tests (#288)
* Add scenarios using copy engine to memory copy tests Signed-off-by: Misiak, Konstanty <[email protected]>
1 parent d0c5de8 commit 433ea9b

File tree

2 files changed

+194
-58
lines changed

2 files changed

+194
-58
lines changed

conformance_tests/core/test_copy/src/test_copy.cpp

Lines changed: 182 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ using namespace level_zero_tests;
2626

2727
namespace {
2828

29+
void get_copy_and_compute_ordinals(
30+
const std::vector<ze_command_queue_group_properties_t>
31+
&cmd_queue_group_props,
32+
int &compute_ordinal, int &copy_ordinal) {
33+
for (uint32_t i = 0; i < cmd_queue_group_props.size(); i++) {
34+
if (cmd_queue_group_props[i].flags &
35+
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE &&
36+
compute_ordinal < 0) {
37+
compute_ordinal = i;
38+
}
39+
if (cmd_queue_group_props[i].flags &
40+
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY &&
41+
!(cmd_queue_group_props[i].flags &
42+
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE) &&
43+
copy_ordinal < 0) {
44+
copy_ordinal = i;
45+
}
46+
if (compute_ordinal >= 0 && copy_ordinal >= 0) {
47+
break;
48+
}
49+
}
50+
}
51+
2952
class zeCommandListAppendMemoryFillTests : public ::testing::Test {
3053
protected:
3154
void RunMaxMemoryFillTest(bool is_immediate, bool is_shared_system);
@@ -35,29 +58,6 @@ class zeCommandListAppendMemoryFillTests : public ::testing::Test {
3558
bool is_immediate, bool is_shared_system, bool use_copy_engine);
3659
void RunGivenMemorySizeAndValueWhenAppendingMemoryFillWithWaitEventTest(
3760
bool is_immediate, bool is_shared_system, bool use_copy_engine);
38-
39-
void get_copy_and_compute_ordinals(
40-
const std::vector<ze_command_queue_group_properties_t>
41-
&cmd_queue_group_props,
42-
int &compute_ordinal, int &copy_ordinal) {
43-
for (uint32_t i = 0; i < cmd_queue_group_props.size(); i++) {
44-
if (cmd_queue_group_props[i].flags &
45-
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE &&
46-
compute_ordinal < 0) {
47-
compute_ordinal = i;
48-
}
49-
if (cmd_queue_group_props[i].flags &
50-
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY &&
51-
!(cmd_queue_group_props[i].flags &
52-
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE) &&
53-
copy_ordinal < 0) {
54-
copy_ordinal = i;
55-
}
56-
if (compute_ordinal >= 0 && copy_ordinal >= 0) {
57-
break;
58-
}
59-
}
60-
}
6161
};
6262

6363
void zeCommandListAppendMemoryFillTests::
@@ -69,9 +69,8 @@ void zeCommandListAppendMemoryFillTests::
6969
int compute_ordinal = -1, copy_ordinal = -1;
7070
get_copy_and_compute_ordinals(cmd_queue_group_props, compute_ordinal,
7171
copy_ordinal);
72-
if (use_copy_engine && copy_ordinal < 0) {
73-
GTEST_SKIP() << "Device does not support copy queue, skipping the test";
74-
}
72+
ASSERT_TRUE((use_copy_engine && copy_ordinal >= 0) ||
73+
(!use_copy_engine && compute_ordinal >= 0));
7574

7675
auto cmd_bundle = lzt::create_command_bundle(
7776
lzt::get_default_context(), zeDevice::get_instance()->get_device(), 0,
@@ -213,9 +212,8 @@ void zeCommandListAppendMemoryFillTests::
213212
int compute_ordinal = -1, copy_ordinal = -1;
214213
get_copy_and_compute_ordinals(cmd_queue_group_props, compute_ordinal,
215214
copy_ordinal);
216-
if (use_copy_engine && copy_ordinal < 0) {
217-
GTEST_SKIP() << "Device does not support copy queue";
218-
}
215+
ASSERT_TRUE((use_copy_engine && copy_ordinal >= 0) ||
216+
(!use_copy_engine && compute_ordinal >= 0));
219217

220218
auto cmd_bundle = lzt::create_command_bundle(
221219
lzt::get_default_context(), zeDevice::get_instance()->get_device(), 0,
@@ -309,9 +307,8 @@ void zeCommandListAppendMemoryFillTests::
309307
int compute_ordinal = -1, copy_ordinal = -1;
310308
get_copy_and_compute_ordinals(cmd_queue_group_props, compute_ordinal,
311309
copy_ordinal);
312-
if (use_copy_engine && copy_ordinal < 0) {
313-
GTEST_SKIP() << "Device does not support copy queue";
314-
}
310+
ASSERT_TRUE((use_copy_engine && copy_ordinal >= 0) ||
311+
(!use_copy_engine && compute_ordinal >= 0));
315312

316313
auto cmd_bundle = lzt::create_command_bundle(
317314
lzt::get_default_context(), zeDevice::get_instance()->get_device(), 0,
@@ -1346,21 +1343,33 @@ INSTANTIATE_TEST_SUITE_P(MemoryCopies, AppendMemoryCopyRegionWithSharedSystem,
13461343

13471344
class zeCommandListAppendMemoryCopyTests : public ::testing::Test {
13481345
protected:
1349-
void
1350-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(bool is_immediate,
1351-
bool is_shared_system);
1346+
void RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(
1347+
bool is_immediate, bool is_shared_system, bool use_copy_engine);
13521348
void RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(
1353-
bool is_immediate, bool is_shared_system);
1349+
bool is_immediate, bool is_shared_system, bool use_copy_engine);
13541350
void RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(
1355-
bool is_immediate, bool is_shared_system);
1351+
bool is_immediate, bool is_shared_system, bool use_copy_engine);
13561352
void RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyRegionWithWaitEventTest(
13571353
bool is_immediate, bool is_shared_system);
13581354
};
13591355

13601356
void zeCommandListAppendMemoryCopyTests::
1361-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(
1362-
bool is_immediate, bool is_shared_system) {
1363-
auto cmd_bundle = lzt::create_command_bundle(is_immediate);
1357+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(bool is_immediate,
1358+
bool is_shared_system,
1359+
bool use_copy_engine) {
1360+
auto cmd_queue_group_props = get_command_queue_group_properties(
1361+
zeDevice::get_instance()->get_device());
1362+
1363+
int compute_ordinal = -1, copy_ordinal = -1;
1364+
get_copy_and_compute_ordinals(cmd_queue_group_props, compute_ordinal,
1365+
copy_ordinal);
1366+
ASSERT_TRUE((use_copy_engine && copy_ordinal >= 0) ||
1367+
(!use_copy_engine && compute_ordinal >= 0));
1368+
1369+
auto cmd_bundle = lzt::create_command_bundle(
1370+
lzt::get_default_context(), zeDevice::get_instance()->get_device(), 0,
1371+
use_copy_engine ? copy_ordinal : compute_ordinal, is_immediate);
1372+
13641373
const size_t size = 16;
13651374
const std::vector<char> host_memory(size, 123);
13661375
void *memory = lzt::allocate_device_memory_with_allocator_selector(
@@ -1378,34 +1387,72 @@ void zeCommandListAppendMemoryCopyTests::
13781387
LZT_TEST_F(
13791388
zeCommandListAppendMemoryCopyTests,
13801389
GivenHostMemoryDeviceHostMemoryAndSizeWhenAppendingMemoryCopyThenSuccessIsReturned) {
1381-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(false, false);
1390+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(false, false, false);
13821391
}
13831392

13841393
LZT_TEST_F(
13851394
zeCommandListAppendMemoryCopyTests,
13861395
GivenHostMemoryDeviceHostMemoryAndSizeWhenAppendingMemoryCopyOnImmediateCmdListThenSuccessIsReturned) {
1387-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(true, false);
1396+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(true, false, false);
13881397
}
13891398

13901399
LZT_TEST_F(
13911400
zeCommandListAppendMemoryCopyTests,
13921401
GivenHostMemoryAndSizeWhenAppendingMemoryCopyToSharedSystemMemoryThenSuccessIsReturnedWithSharedSystemAllocator) {
13931402
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1394-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(false, true);
1403+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(false, true, false);
13951404
}
13961405

13971406
LZT_TEST_F(
13981407
zeCommandListAppendMemoryCopyTests,
13991408
GivenHostMemoryAndSizeWhenAppendingMemoryCopyToSharedSystemMemoryOnImmediateCmdListThenSuccessIsReturnedWithSharedSystemAllocator) {
14001409
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1401-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(true, true);
1410+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(true, true, false);
1411+
}
1412+
1413+
LZT_TEST_F(
1414+
zeCommandListAppendMemoryCopyTests,
1415+
GivenHostMemoryDeviceHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyThenSuccessIsReturned) {
1416+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(false, false, true);
1417+
}
1418+
1419+
LZT_TEST_F(
1420+
zeCommandListAppendMemoryCopyTests,
1421+
GivenHostMemoryDeviceHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyOnImmediateCmdListThenSuccessIsReturned) {
1422+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(true, false, true);
1423+
}
1424+
1425+
LZT_TEST_F(
1426+
zeCommandListAppendMemoryCopyTests,
1427+
GivenHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyToSharedSystemMemoryThenSuccessIsReturnedWithSharedSystemAllocator) {
1428+
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1429+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(false, true, true);
1430+
}
1431+
1432+
LZT_TEST_F(
1433+
zeCommandListAppendMemoryCopyTests,
1434+
GivenHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyToSharedSystemMemoryOnImmediateCmdListThenSuccessIsReturnedWithSharedSystemAllocator) {
1435+
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1436+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyTest(true, true, true);
14021437
}
14031438

14041439
void zeCommandListAppendMemoryCopyTests::
14051440
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(
1406-
bool is_immediate, bool is_shared_system) {
1441+
bool is_immediate, bool is_shared_system, bool use_copy_engine) {
1442+
auto cmd_queue_group_props = get_command_queue_group_properties(
1443+
zeDevice::get_instance()->get_device());
1444+
1445+
int compute_ordinal = -1, copy_ordinal = -1;
1446+
get_copy_and_compute_ordinals(cmd_queue_group_props, compute_ordinal,
1447+
copy_ordinal);
1448+
ASSERT_TRUE((use_copy_engine && copy_ordinal >= 0) ||
1449+
(!use_copy_engine && compute_ordinal >= 0));
1450+
1451+
auto cmd_bundle = lzt::create_command_bundle(
1452+
lzt::get_default_context(), zeDevice::get_instance()->get_device(), 0,
1453+
use_copy_engine ? copy_ordinal : compute_ordinal, is_immediate);
1454+
14071455
lzt::zeEventPool ep;
1408-
auto cmd_bundle = lzt::create_command_bundle(is_immediate);
14091456
const size_t size = 16;
14101457
const std::vector<char> host_memory(size, 123);
14111458
void *memory = lzt::allocate_device_memory_with_allocator_selector(
@@ -1426,34 +1473,80 @@ void zeCommandListAppendMemoryCopyTests::
14261473
LZT_TEST_F(
14271474
zeCommandListAppendMemoryCopyTests,
14281475
GivenHostMemoryDeviceHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventThenSuccessIsReturned) {
1429-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(false, false);
1476+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(false, false,
1477+
false);
14301478
}
14311479

14321480
LZT_TEST_F(
14331481
zeCommandListAppendMemoryCopyTests,
14341482
GivenHostMemoryDeviceHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventOnImmediateCmdListThenSuccessIsReturned) {
1435-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(true, false);
1483+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(true, false,
1484+
false);
14361485
}
14371486

14381487
LZT_TEST_F(
14391488
zeCommandListAppendMemoryCopyTests,
14401489
GivenHostMemoryAndSizeWhenAppendingMemoryCopyToSharedSystemMemoryWithHEventThenSuccessIsReturnedWithSharedSystemAllocator) {
14411490
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1442-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(false, true);
1491+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(false, true,
1492+
false);
14431493
}
14441494

14451495
LZT_TEST_F(
14461496
zeCommandListAppendMemoryCopyTests,
14471497
GivenHostMemoryAndSizeWhenAppendingMemoryCopyToSharedSystemMemoryWithHEventOnImmediateCmdListThenSuccessIsReturnedWithSharedSystemAllocator) {
14481498
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1449-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(true, true);
1499+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(true, true,
1500+
false);
1501+
}
1502+
1503+
LZT_TEST_F(
1504+
zeCommandListAppendMemoryCopyTests,
1505+
GivenHostMemoryDeviceHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyWithHEventThenSuccessIsReturned) {
1506+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(false, false,
1507+
true);
1508+
}
1509+
1510+
LZT_TEST_F(
1511+
zeCommandListAppendMemoryCopyTests,
1512+
GivenHostMemoryDeviceHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyWithHEventOnImmediateCmdListThenSuccessIsReturned) {
1513+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(true, false,
1514+
true);
1515+
}
1516+
1517+
LZT_TEST_F(
1518+
zeCommandListAppendMemoryCopyTests,
1519+
GivenHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyToSharedSystemMemoryWithHEventThenSuccessIsReturnedWithSharedSystemAllocator) {
1520+
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1521+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(false, true,
1522+
true);
1523+
}
1524+
1525+
LZT_TEST_F(
1526+
zeCommandListAppendMemoryCopyTests,
1527+
GivenHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyToSharedSystemMemoryWithHEventOnImmediateCmdListThenSuccessIsReturnedWithSharedSystemAllocator) {
1528+
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1529+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithHEventTest(true, true,
1530+
true);
14501531
}
14511532

14521533
void zeCommandListAppendMemoryCopyTests::
14531534
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(
1454-
bool is_immediate, bool is_shared_system) {
1535+
bool is_immediate, bool is_shared_system, bool use_copy_engine) {
1536+
auto cmd_queue_group_props = get_command_queue_group_properties(
1537+
zeDevice::get_instance()->get_device());
1538+
1539+
int compute_ordinal = -1, copy_ordinal = -1;
1540+
get_copy_and_compute_ordinals(cmd_queue_group_props, compute_ordinal,
1541+
copy_ordinal);
1542+
ASSERT_TRUE((use_copy_engine && copy_ordinal >= 0) ||
1543+
(!use_copy_engine && compute_ordinal >= 0));
1544+
1545+
auto cmd_bundle = lzt::create_command_bundle(
1546+
lzt::get_default_context(), zeDevice::get_instance()->get_device(), 0,
1547+
use_copy_engine ? copy_ordinal : compute_ordinal, is_immediate);
1548+
14551549
lzt::zeEventPool ep;
1456-
auto cmd_bundle = lzt::create_command_bundle(is_immediate);
14571550
const size_t size = 16;
14581551
const std::vector<char> host_memory(size, 123);
14591552
void *memory = lzt::allocate_device_memory_with_allocator_selector(
@@ -1477,30 +1570,61 @@ void zeCommandListAppendMemoryCopyTests::
14771570
LZT_TEST_F(
14781571
zeCommandListAppendMemoryCopyTests,
14791572
GivenHostMemoryDeviceHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventThenSuccessIsReturned) {
1480-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(false,
1481-
false);
1573+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(
1574+
false, false, false);
14821575
}
14831576

14841577
LZT_TEST_F(
14851578
zeCommandListAppendMemoryCopyTests,
14861579
GivenHostMemoryDeviceHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventOnImmediateCmdListThenSuccessIsReturned) {
1487-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(true,
1580+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(true, false,
14881581
false);
14891582
}
14901583

14911584
LZT_TEST_F(
14921585
zeCommandListAppendMemoryCopyTests,
14931586
GivenHostMemoryAndSizeWhenAppendingMemoryCopyToSharedSystemMemoryWithWaitEventThenSuccessIsReturnedWithSharedSystemAllocator) {
14941587
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1495-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(false,
1496-
true);
1588+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(false, true,
1589+
false);
14971590
}
14981591

14991592
LZT_TEST_F(
15001593
zeCommandListAppendMemoryCopyTests,
15011594
GivenHostMemoryAndSizeWhenAppendingMemoryCopyToSharedSystemMemoryWithWaitEventOnImmediateCmdListThenSuccessIsReturnedWithSharedSystemAllocator) {
15021595
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1503-
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(true, true);
1596+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(true, true,
1597+
false);
1598+
}
1599+
1600+
LZT_TEST_F(
1601+
zeCommandListAppendMemoryCopyTests,
1602+
GivenHostMemoryDeviceHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyWithWaitEventThenSuccessIsReturned) {
1603+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(
1604+
false, false, true);
1605+
}
1606+
1607+
LZT_TEST_F(
1608+
zeCommandListAppendMemoryCopyTests,
1609+
GivenHostMemoryDeviceHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyWithWaitEventOnImmediateCmdListThenSuccessIsReturned) {
1610+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(true, false,
1611+
true);
1612+
}
1613+
1614+
LZT_TEST_F(
1615+
zeCommandListAppendMemoryCopyTests,
1616+
GivenHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyToSharedSystemMemoryWithWaitEventThenSuccessIsReturnedWithSharedSystemAllocator) {
1617+
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1618+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(false, true,
1619+
true);
1620+
}
1621+
1622+
LZT_TEST_F(
1623+
zeCommandListAppendMemoryCopyTests,
1624+
GivenHostMemorySizeAndCopyEngineWhenAppendingMemoryCopyToSharedSystemMemoryWithWaitEventOnImmediateCmdListThenSuccessIsReturnedWithSharedSystemAllocator) {
1625+
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1626+
RunGivenHostMemoryAndSizeWhenAppendingMemoryCopyWithWaitEventTest(true, true,
1627+
true);
15041628
}
15051629

15061630
void zeCommandListAppendMemoryCopyTests::

0 commit comments

Comments
 (0)