Skip to content

Commit cf52deb

Browse files
Add scenarios using BCS to image SVM tests
- Added new scenarios - Refactored code for choosing queue ordinals Signed-off-by: Misiak, Konstanty <[email protected]>
1 parent 47b7c6c commit cf52deb

File tree

2 files changed

+132
-15
lines changed

2 files changed

+132
-15
lines changed

conformance_tests/core/test_copy/src/test_copy_image.cpp

Lines changed: 124 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,42 @@ LZT_TEST_F(
691691
lzt::free_memory(buff_out_top);
692692
}
693693

694+
LZT_TEST_F(
695+
zeCommandListAppendImageCopyTests,
696+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingCopyEngineAndDeviceMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
697+
if (!(lzt::image_support())) {
698+
GTEST_SKIP();
699+
}
700+
void *buff_in_top = lzt::allocate_device_memory(image_size);
701+
void *buff_out_bot = lzt::allocate_device_memory(image_size);
702+
void *buff_in_bot = lzt::allocate_device_memory(image_size);
703+
void *buff_out_top = lzt::allocate_device_memory(image_size);
704+
test_image_mem_copy_use_regions(buff_in_bot, buff_in_top, buff_out_bot,
705+
buff_out_top, false, true);
706+
lzt::free_memory(buff_in_bot);
707+
lzt::free_memory(buff_in_top);
708+
lzt::free_memory(buff_out_bot);
709+
lzt::free_memory(buff_out_top);
710+
}
711+
712+
LZT_TEST_F(
713+
zeCommandListAppendImageCopyTests,
714+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryToImmediateCmdListUsingCopyEngineAndDeviceMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
715+
if (!(lzt::image_support())) {
716+
GTEST_SKIP();
717+
}
718+
void *buff_in_top = lzt::allocate_device_memory(image_size);
719+
void *buff_out_bot = lzt::allocate_device_memory(image_size);
720+
void *buff_in_bot = lzt::allocate_device_memory(image_size);
721+
void *buff_out_top = lzt::allocate_device_memory(image_size);
722+
test_image_mem_copy_use_regions(buff_in_bot, buff_in_top, buff_out_bot,
723+
buff_out_top, true, true);
724+
lzt::free_memory(buff_in_bot);
725+
lzt::free_memory(buff_in_top);
726+
lzt::free_memory(buff_out_bot);
727+
lzt::free_memory(buff_out_top);
728+
}
729+
694730
LZT_TEST_F(
695731
zeCommandListAppendImageCopyTests,
696732
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingDeviceMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
@@ -717,6 +753,32 @@ LZT_TEST_F(
717753
lzt::free_memory(buff_out);
718754
}
719755

756+
LZT_TEST_F(
757+
zeCommandListAppendImageCopyTests,
758+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingCopyEngineAndDeviceMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
759+
if (!(lzt::image_support())) {
760+
GTEST_SKIP();
761+
}
762+
void *buff_in = lzt::allocate_device_memory(image_size);
763+
void *buff_out = lzt::allocate_device_memory(image_size);
764+
test_image_mem_copy_no_regions(buff_in, buff_out, false, true);
765+
lzt::free_memory(buff_in);
766+
lzt::free_memory(buff_out);
767+
}
768+
769+
LZT_TEST_F(
770+
zeCommandListAppendImageCopyTests,
771+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryToImmediateCmdListUsingCopyEngineAndDeviceMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
772+
if (!(lzt::image_support())) {
773+
GTEST_SKIP();
774+
}
775+
void *buff_in = lzt::allocate_device_memory(image_size);
776+
void *buff_out = lzt::allocate_device_memory(image_size);
777+
test_image_mem_copy_no_regions(buff_in, buff_out, true, true);
778+
lzt::free_memory(buff_in);
779+
lzt::free_memory(buff_out);
780+
}
781+
720782
LZT_TEST_F(
721783
zeCommandListAppendImageCopyTests,
722784
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingSharedMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
@@ -753,6 +815,42 @@ LZT_TEST_F(
753815
lzt::free_memory(buff_out_top);
754816
}
755817

818+
LZT_TEST_F(
819+
zeCommandListAppendImageCopyTests,
820+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingCopyEngineAndSharedMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
821+
if (!(lzt::image_support())) {
822+
GTEST_SKIP();
823+
}
824+
void *buff_in_top = lzt::allocate_shared_memory(image_size);
825+
void *buff_out_bot = lzt::allocate_shared_memory(image_size);
826+
void *buff_in_bot = lzt::allocate_shared_memory(image_size);
827+
void *buff_out_top = lzt::allocate_shared_memory(image_size);
828+
test_image_mem_copy_use_regions(buff_in_bot, buff_in_top, buff_out_bot,
829+
buff_out_top, false, true);
830+
lzt::free_memory(buff_in_bot);
831+
lzt::free_memory(buff_in_top);
832+
lzt::free_memory(buff_out_bot);
833+
lzt::free_memory(buff_out_top);
834+
}
835+
836+
LZT_TEST_F(
837+
zeCommandListAppendImageCopyTests,
838+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryToImmediateCmdListUsingCopyEngineAndSharedMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
839+
if (!(lzt::image_support())) {
840+
GTEST_SKIP();
841+
}
842+
void *buff_in_top = lzt::allocate_shared_memory(image_size);
843+
void *buff_out_bot = lzt::allocate_shared_memory(image_size);
844+
void *buff_in_bot = lzt::allocate_shared_memory(image_size);
845+
void *buff_out_top = lzt::allocate_shared_memory(image_size);
846+
test_image_mem_copy_use_regions(buff_in_bot, buff_in_top, buff_out_bot,
847+
buff_out_top, true, true);
848+
lzt::free_memory(buff_in_bot);
849+
lzt::free_memory(buff_in_top);
850+
lzt::free_memory(buff_out_bot);
851+
lzt::free_memory(buff_out_top);
852+
}
853+
756854
LZT_TEST_F(
757855
zeCommandListAppendImageCopyTests,
758856
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingSharedMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
@@ -779,6 +877,32 @@ LZT_TEST_F(
779877
lzt::free_memory(buff_out);
780878
}
781879

880+
LZT_TEST_F(
881+
zeCommandListAppendImageCopyTests,
882+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingCopyEngineAndSharedMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
883+
if (!(lzt::image_support())) {
884+
GTEST_SKIP();
885+
}
886+
void *buff_in = lzt::allocate_shared_memory(image_size);
887+
void *buff_out = lzt::allocate_shared_memory(image_size);
888+
test_image_mem_copy_no_regions(buff_in, buff_out, false, true);
889+
lzt::free_memory(buff_in);
890+
lzt::free_memory(buff_out);
891+
}
892+
893+
LZT_TEST_F(
894+
zeCommandListAppendImageCopyTests,
895+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryToImmediateCmdListUsingCopyEngineAndSharedMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
896+
if (!(lzt::image_support())) {
897+
GTEST_SKIP();
898+
}
899+
void *buff_in = lzt::allocate_shared_memory(image_size);
900+
void *buff_out = lzt::allocate_shared_memory(image_size);
901+
test_image_mem_copy_no_regions(buff_in, buff_out, true, true);
902+
lzt::free_memory(buff_in);
903+
lzt::free_memory(buff_out);
904+
}
905+
782906
LZT_TEST_F(
783907
zeCommandListAppendImageCopyTests,
784908
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingSharedSystemMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturnedWithSharedSystemAllocator) {
@@ -817,8 +941,6 @@ LZT_TEST_F(
817941
lzt::aligned_free(buff_out_top);
818942
}
819943

820-
821-
822944
LZT_TEST_F(
823945
zeCommandListAppendImageCopyTests,
824946
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryToImmediateCmdListUsingSharedSystemMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturnedWithSharedSystemAllocator) {

conformance_tests/core/test_memory/src/test_svm.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,12 @@ class SharedSystemMemoryLaunchCooperativeKernelTests
157157
LZT_TEST_P(
158158
SharedSystemMemoryLaunchCooperativeKernelTests,
159159
GivenSharedSystemMemoryAllocationsAsKernelArgumentsWhenCooperativeKernelExecutesThenValueIsCorrect) {
160-
int ordinal = -1;
161160
auto command_queue_group_properties =
162161
lzt::get_command_queue_group_properties(device);
163-
for (int i = 0; i < command_queue_group_properties.size(); i++) {
164-
if (command_queue_group_properties[i].flags &
165-
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS) {
166-
ordinal = i;
167-
break;
168-
}
169-
}
170-
if (ordinal < 0) {
162+
auto ordinal = lzt::get_queue_ordinal(
163+
command_queue_group_properties,
164+
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS, 0);
165+
if (!ordinal) {
171166
LOG_WARNING << "No command queues that support cooperative kernels";
172167
GTEST_SKIP();
173168
}
@@ -209,15 +204,15 @@ LZT_TEST_P(
209204
return n - (n >> 1);
210205
}(max_coop_group_count);
211206

212-
uint32_t group_count = (num_elements < suggested_group_count)
213-
? num_elements
207+
uint32_t group_count = (lzt::to_u32(num_elements) < suggested_group_count)
208+
? lzt::to_u32(num_elements)
214209
: suggested_group_count;
215210
LOG_INFO << "Group count: " << group_count;
216211

217212
void *output = lzt::allocate_shared_memory_with_allocator_selector(
218213
group_count * sizeof(int), 1, 0, 0, device, is_dst_shared_system);
219214

220-
uint32_t group_size = num_elements / group_count;
215+
uint32_t group_size = lzt::to_u32(num_elements) / group_count;
221216
LOG_INFO << "Group size: " << group_size;
222217
ASSERT_LE(group_size, compute_properties.maxGroupSizeX);
223218

@@ -227,7 +222,7 @@ LZT_TEST_P(
227222
lzt::set_argument_value(function, 2, group_size * sizeof(int), nullptr);
228223

229224
lzt::zeCommandBundle cmd_bundle = lzt::create_command_bundle(
230-
lzt::get_default_context(), device, 0, ordinal, use_immediate_cmdlist);
225+
lzt::get_default_context(), device, 0, *ordinal, use_immediate_cmdlist);
231226

232227
ze_group_count_t thread_group_dimensions = {group_count, 1, 1};
233228
lzt::append_launch_cooperative_function(

0 commit comments

Comments
 (0)