@@ -22,6 +22,10 @@ namespace lzt = level_zero_tests;
22
22
23
23
namespace {
24
24
25
+ using lzt::to_int;
26
+ using lzt::to_u32;
27
+ using lzt::to_u8;
28
+
25
29
using cmdListVec = std::vector<ze_command_list_handle_t >;
26
30
using cmdQueueVec = std::vector<ze_command_queue_handle_t >;
27
31
@@ -158,7 +162,7 @@ class zeCommandListResetTests : public ::testing::Test {
158
162
lzt::append_barrier (bundle.list );
159
163
160
164
uint8_t pattern = 0xAA ;
161
- int pattern_size = 1 ;
165
+ size_t pattern_size = 1 ;
162
166
auto memory_fill_mem = lzt::allocate_shared_memory (size);
163
167
memset (memory_fill_mem, 0 , size);
164
168
lzt::append_memory_fill (bundle.list , memory_fill_mem, &pattern,
@@ -186,7 +190,7 @@ class zeCommandListResetTests : public ::testing::Test {
186
190
ze_kernel_handle_t kernel =
187
191
lzt::create_function (module , " cmdlist_add_constant" );
188
192
lzt::set_group_size (kernel, 1 , 1 , 1 );
189
- ze_group_count_t args = {static_cast < uint32_t > (size), 1 , 1 };
193
+ ze_group_count_t args = {to_u32 (size), 1 , 1 };
190
194
191
195
const int addval = 10 ;
192
196
auto kernel_buffer = lzt::allocate_shared_memory (size * sizeof (int ));
@@ -231,12 +235,12 @@ class zeCommandListResetTests : public ::testing::Test {
231
235
if (execute_all_commands || is_immediate) {
232
236
lzt::validate_data_pattern (host_mem, size, 1 );
233
237
if (lzt::image_support ()) {
234
- EXPECT_EQ (0 , compare_data_pattern (*dest_host_image_ptr,
235
- img_ptr->dflt_host_image_ , 0 , 0 ,
236
- img_ptr->dflt_host_image_ .width (),
237
- img_ptr->dflt_host_image_ .height (), 0 ,
238
- 0 , img_ptr->dflt_host_image_ .width (),
239
- img_ptr->dflt_host_image_ .height ()));
238
+ EXPECT_EQ (0 , compare_data_pattern (
239
+ *dest_host_image_ptr, img_ptr->dflt_host_image_ , 0U ,
240
+ 0U , img_ptr->dflt_host_image_ .width (),
241
+ img_ptr->dflt_host_image_ .height (), 0U , 0U ,
242
+ img_ptr->dflt_host_image_ .width (),
243
+ img_ptr->dflt_host_image_ .height ()));
240
244
delete img_ptr;
241
245
delete dest_host_image_ptr;
242
246
}
@@ -252,12 +256,12 @@ class zeCommandListResetTests : public ::testing::Test {
252
256
EXPECT_EQ (static_cast <uint8_t *>(memory_fill_mem)[i], 0 );
253
257
}
254
258
if (lzt::image_support ()) {
255
- EXPECT_NE (0 , compare_data_pattern (*dest_host_image_ptr,
256
- img_ptr->dflt_host_image_ , 0 , 0 ,
257
- img_ptr->dflt_host_image_ .width (),
258
- img_ptr->dflt_host_image_ .height (), 0 ,
259
- 0 , img_ptr->dflt_host_image_ .width (),
260
- img_ptr->dflt_host_image_ .height ()));
259
+ EXPECT_NE (0 , compare_data_pattern (
260
+ *dest_host_image_ptr, img_ptr->dflt_host_image_ , 0U ,
261
+ 0U , img_ptr->dflt_host_image_ .width (),
262
+ img_ptr->dflt_host_image_ .height (), 0U , 0U ,
263
+ img_ptr->dflt_host_image_ .width (),
264
+ img_ptr->dflt_host_image_ .height ()));
261
265
delete img_ptr;
262
266
delete dest_host_image_ptr;
263
267
}
@@ -343,17 +347,17 @@ LZT_TEST(zeCommandListReuseTests,
343
347
lzt::append_memory_copy (cmdlist_mem_zero, host_buffer, device_buffer, size);
344
348
lzt::close_command_list (cmdlist_mem_zero);
345
349
346
- const int num_execute = 5 ;
347
- for (int i = 0 ; i < num_execute; i++) {
350
+ const uint32_t num_execute = 5 ;
351
+ for (uint32_t i = 0U ; i < num_execute; i++) {
348
352
lzt::execute_command_lists (cmdq, 1 , &cmdlist_mem_zero, nullptr );
349
353
lzt::synchronize (cmdq, UINT64_MAX);
350
- for (int j = 0 ; j < size; j++)
354
+ for (size_t j = 0U ; j < size; j++)
351
355
ASSERT_EQ (static_cast <uint8_t *>(host_buffer)[j], 0x0 )
352
356
<< " Memory Set did not match." ;
353
357
354
358
lzt::execute_command_lists (cmdq, 1 , &cmdlist_mem_set, nullptr );
355
359
lzt::synchronize (cmdq, UINT64_MAX);
356
- for (int j = 0 ; j < size; j++)
360
+ for (size_t j = 0U ; j < size; j++)
357
361
ASSERT_EQ (static_cast <uint8_t *>(host_buffer)[j], 0x1 )
358
362
<< " Memory Set did not match." ;
359
363
}
@@ -447,7 +451,7 @@ void RunWhenResetThenVerifyOnlySubsequentInstructionsExecuted(
447
451
std::vector<uint8_t > val;
448
452
for (size_t i = 0 ; i < num_instr; i++) {
449
453
buffer.push_back (lzt::allocate_shared_memory (size));
450
- val.push_back (static_cast < uint8_t > (i + 1 ));
454
+ val.push_back (to_u8 (i + 1 ));
451
455
}
452
456
453
457
// Begin with num_instr command list instructions, reset and reduce by one
@@ -525,7 +529,7 @@ LZT_TEST_P(zeCommandListFlagTests,
525
529
auto host_memory = lzt::allocate_host_memory (size);
526
530
auto device = lzt::zeDevice::get_instance ()->get_device ();
527
531
uint8_t pattern = 0xAB ;
528
- const int pattern_size = 1 ;
532
+ const size_t pattern_size = 1 ;
529
533
ze_command_list_flags_t flags = std::get<0 >(GetParam ());
530
534
bool is_immediate = std::get<1 >(GetParam ());
531
535
auto cmd_bundle = lzt::create_command_bundle (device, flags, is_immediate);
@@ -597,7 +601,7 @@ RunGivenCommandListWithMultipleAppendMemoryCopiesFollowedByResetInLoopTest(
597
601
temp1 = static_cast <uint8_t *>(host_memory_src);
598
602
temp2 = static_cast <uint8_t *>(host_memory_dst);
599
603
for (uint32_t i = 0 ; i < max_copy_count; i++) {
600
- temp1[i] = i ;
604
+ temp1[i] = to_u8 (i) ;
601
605
temp2[i] = 0 ;
602
606
}
603
607
for (uint32_t i = 0 ; i < max_copy_count; i++) {
@@ -635,7 +639,7 @@ LZT_TEST(
635
639
zeCommandListAppendMemoryCopyTest,
636
640
GivenCommandListWithMultipleAppendMemoryCopiesFollowedByResetInLoopThenSuccessIsReturnedWithSharedSystemAllocator) {
637
641
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
638
- for (int i = 1 ; i < 4 ; ++i) {
642
+ for (uint32_t i = 1 ; i < 4 ; ++i) {
639
643
std::bitset<2 > bits (i);
640
644
RunGivenCommandListWithMultipleAppendMemoryCopiesFollowedByResetInLoopTest (
641
645
bits[1 ], bits[0 ]);
@@ -722,7 +726,7 @@ RunGivenTwoCommandQueuesHavingCommandListsWithScratchSpaceThenSuccessIsReturnedT
722
726
size, is_shared_system_dst);
723
727
724
728
uint8_t pattern = 0xAB ;
725
- const int pattern_size = 1 ;
729
+ const size_t pattern_size = 1 ;
726
730
uint32_t num_iterations = 2 ;
727
731
728
732
auto context = lzt::get_default_context ();
@@ -765,7 +769,8 @@ RunGivenTwoCommandQueuesHavingCommandListsWithScratchSpaceThenSuccessIsReturnedT
765
769
&offsetBuffer);
766
770
// if groupSize is greater then memory count, then at least one thread group
767
771
// should be dispatched
768
- uint32_t threadGroup = arraySize / groupSize > 1 ? arraySize / groupSize : 1 ;
772
+ uint32_t threadGroup =
773
+ arraySize / groupSize > 1 ? to_u32 (arraySize / groupSize) : 1 ;
769
774
ze_group_count_t thread_group_dimensions = {threadGroup, 1 , 1 };
770
775
771
776
for (uint32_t i = 0 ; i < num_iterations; i++) {
@@ -863,7 +868,7 @@ LZT_TEST(
863
868
zeCommandListAppendMemoryCopyTest,
864
869
GivenTwoCommandQueuesHavingCommandListsWithScratchSpaceThenSuccessIsReturnedWithSharedSystemAllocator) {
865
870
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
866
- for (int i = 1 ; i < 8 ; ++i) {
871
+ for (uint32_t i = 1 ; i < 8 ; ++i) {
867
872
std::bitset<3 > bits (i);
868
873
RunGivenTwoCommandQueuesHavingCommandListsWithScratchSpaceThenSuccessIsReturnedTest (
869
874
bits[2 ], bits[1 ], bits[0 ]);
@@ -930,11 +935,12 @@ class zeCommandListEventCounterTests : public lzt::zeEventPoolTests {
930
935
};
931
936
932
937
static void RunAppendLaunchKernelEvent (cmdListVec cmdlist, cmdQueueVec cmdqueue,
933
- ze_event_handle_t event, int num_cmdlist,
934
- void *buffer, const size_t size) {
938
+ ze_event_handle_t event,
939
+ size_t num_cmdlist, void *buffer,
940
+ const size_t size) {
935
941
936
942
const int addval = 10 ;
937
- const int num_iterations = 100 ;
943
+ const uint32_t num_iterations = 100 ;
938
944
int addval2 = 0 ;
939
945
const uint64_t timeout = UINT64_MAX - 1 ;
940
946
@@ -949,28 +955,28 @@ static void RunAppendLaunchKernelEvent(cmdListVec cmdlist, cmdQueueVec cmdqueue,
949
955
950
956
memset (buffer, 0x0 , num_cmdlist * size * sizeof (int ));
951
957
952
- for (int n = 0 ; n < num_cmdlist; n++) {
958
+ for (size_t n = 0 ; n < num_cmdlist; n++) {
953
959
int *p_dev = static_cast <int *>(buffer);
954
960
p_dev += (n * size);
955
961
lzt::set_argument_value (kernel, 0 , sizeof (p_dev), &p_dev);
956
962
lzt::set_argument_value (kernel, 1 , sizeof (addval), &addval);
957
963
ze_group_count_t tg;
958
- tg.groupCountX = static_cast < uint32_t > (size);
964
+ tg.groupCountX = to_u32 (size);
959
965
tg.groupCountY = 1 ;
960
966
tg.groupCountZ = 1 ;
961
967
962
968
lzt::append_launch_function (cmdlist[n], kernel, &tg, nullptr , 0 , nullptr );
963
969
964
970
totalVal[n] = 0 ;
965
- for (int i = 0 ; i < (num_iterations - 1 ); i++) {
971
+ for (uint32_t i = 0 ; i < (num_iterations - 1 ); i++) {
966
972
addval2 = lzt::generate_value<int >() & 0xFFFF ;
967
973
totalVal[n] += addval2;
968
974
lzt::set_argument_value (kernel, 1 , sizeof (addval2), &addval2);
969
975
970
976
lzt::append_launch_function (cmdlist[n], kernel, &tg, nullptr , 0 , nullptr );
971
977
}
972
978
addval2 = lzt::generate_value<int >() & 0xFFFF ;
973
- ;
979
+
974
980
totalVal[n] += addval2;
975
981
lzt::set_argument_value (kernel, 1 , sizeof (addval2), &addval2);
976
982
if (n == 0 ) {
@@ -985,7 +991,7 @@ static void RunAppendLaunchKernelEvent(cmdListVec cmdlist, cmdQueueVec cmdqueue,
985
991
986
992
EXPECT_ZE_RESULT_SUCCESS (zeEventHostSynchronize (event, timeout));
987
993
988
- for (int n = 0 ; n < num_cmdlist; n++) {
994
+ for (uint32_t n = 0 ; n < num_cmdlist; n++) {
989
995
for (size_t i = 0 ; i < size; i++) {
990
996
EXPECT_EQ (static_cast <int *>(buffer)[(n * size) + i],
991
997
(addval + totalVal[n]));
@@ -999,7 +1005,7 @@ static void RunAppendLaunchKernelEvent(cmdListVec cmdlist, cmdQueueVec cmdqueue,
999
1005
static void RunAppendLaunchKernelEventL0SharedAlloc (cmdListVec cmdlist,
1000
1006
cmdQueueVec cmdqueue,
1001
1007
ze_event_handle_t event,
1002
- int num_cmdlist,
1008
+ size_t num_cmdlist,
1003
1009
const size_t size) {
1004
1010
void *buffer = lzt::allocate_shared_memory (num_cmdlist * size * sizeof (int ));
1005
1011
RunAppendLaunchKernelEvent (cmdlist, cmdqueue, event, num_cmdlist, buffer,
@@ -1010,7 +1016,7 @@ static void RunAppendLaunchKernelEventL0SharedAlloc(cmdListVec cmdlist,
1010
1016
static void RunAppendLaunchKernelEventHostMalloc (cmdListVec cmdlist,
1011
1017
cmdQueueVec cmdqueue,
1012
1018
ze_event_handle_t event,
1013
- int num_cmdlist,
1019
+ size_t num_cmdlist,
1014
1020
const size_t size) {
1015
1021
void *buffer = malloc (num_cmdlist * size * sizeof (int ));
1016
1022
ASSERT_NE (nullptr , buffer);
@@ -1022,7 +1028,7 @@ static void RunAppendLaunchKernelEventHostMalloc(cmdListVec cmdlist,
1022
1028
static void RunAppendLaunchKernelEventHostNew (cmdListVec cmdlist,
1023
1029
cmdQueueVec cmdqueue,
1024
1030
ze_event_handle_t event,
1025
- int num_cmdlist,
1031
+ size_t num_cmdlist,
1026
1032
const size_t size) {
1027
1033
int *buffer = new int [num_cmdlist * size];
1028
1034
ASSERT_NE (nullptr , buffer);
@@ -1034,7 +1040,7 @@ static void RunAppendLaunchKernelEventHostNew(cmdListVec cmdlist,
1034
1040
static void RunAppendLaunchKernelEventHostUniquePtr (cmdListVec cmdlist,
1035
1041
cmdQueueVec cmdqueue,
1036
1042
ze_event_handle_t event,
1037
- int num_cmdlist,
1043
+ size_t num_cmdlist,
1038
1044
const size_t size) {
1039
1045
std::unique_ptr<int []> buffer (new int [num_cmdlist * size]);
1040
1046
ASSERT_NE (nullptr , buffer);
@@ -1045,7 +1051,7 @@ static void RunAppendLaunchKernelEventHostUniquePtr(cmdListVec cmdlist,
1045
1051
static void RunAppendLaunchKernelEventHostSharedPtr (cmdListVec cmdlist,
1046
1052
cmdQueueVec cmdqueue,
1047
1053
ze_event_handle_t event,
1048
- int num_cmdlist,
1054
+ size_t num_cmdlist,
1049
1055
const size_t size) {
1050
1056
std::shared_ptr<int []> buffer (new int [num_cmdlist * size]);
1051
1057
ASSERT_NE (nullptr , buffer);
@@ -1054,7 +1060,7 @@ static void RunAppendLaunchKernelEventHostSharedPtr(cmdListVec cmdlist,
1054
1060
}
1055
1061
1056
1062
typedef void (*RunAppendLaunchKernelEventFunc)(cmdListVec, cmdQueueVec,
1057
- ze_event_handle_t , int ,
1063
+ ze_event_handle_t , size_t ,
1058
1064
const size_t );
1059
1065
1060
1066
static void
@@ -1068,7 +1074,7 @@ RunAppendLaunchKernelEventLoop(cmdListVec cmdlist, cmdQueueVec cmdqueue,
1068
1074
}
1069
1075
1070
1076
constexpr size_t size = 16 ;
1071
- for (int i = 1 ; i <= cmdlist.size (); i++) {
1077
+ for (size_t i = 1 ; i <= cmdlist.size (); i++) {
1072
1078
LOG_INFO << " Testing " << i << " command list(s)" ;
1073
1079
func (cmdlist, cmdqueue, event, i, size);
1074
1080
}
0 commit comments