17
17
// enqueue_update.cpp test for a test verifying the order of submissions, as
18
18
// the input/output to the kernels can be modified between the submissions.
19
19
struct urEnqueueCommandBufferExpTest
20
- : uur::command_buffer::urCommandBufferExpExecutionTest {
20
+ : uur::command_buffer::urCommandBufferExpExecutionTestWithParam<
21
+ ur_queue_flags_t > {
21
22
virtual void SetUp () override {
22
23
program_name = " increment" ;
23
- UUR_RETURN_ON_FATAL_FAILURE (urCommandBufferExpExecutionTest::SetUp ());
24
+ UUR_RETURN_ON_FATAL_FAILURE (
25
+ urCommandBufferExpExecutionTestWithParam::SetUp ());
24
26
25
- // https://github.com/intel/llvm/issues/18610
26
- UUR_KNOWN_FAILURE_ON (uur::LevelZeroV2{});
27
-
28
- // Create an in-order queue
27
+ // Create an in-order or out-of-order queue, depending on the passed parameter
28
+ ur_queue_flags_t queue_type = std::get<1 >(GetParam ());
29
29
ur_queue_properties_t queue_properties = {
30
- UR_STRUCTURE_TYPE_QUEUE_PROPERTIES, nullptr , 0 };
31
- ASSERT_SUCCESS (
32
- urQueueCreate (context, device, &queue_properties, &in_order_queue));
33
-
34
- // Create an out-of-order queue
35
- queue_properties.flags = UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE;
36
- ASSERT_SUCCESS (
37
- urQueueCreate (context, device, &queue_properties, &out_of_order_queue));
38
- ASSERT_NE (out_of_order_queue, nullptr );
30
+ UR_STRUCTURE_TYPE_QUEUE_PROPERTIES, nullptr , queue_type};
31
+ ASSERT_SUCCESS (urQueueCreate (context, device, &queue_properties,
32
+ &in_or_out_of_order_queue));
39
33
40
34
ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, nullptr , nullptr ,
41
35
allocation_size, &device_ptr));
@@ -45,6 +39,20 @@ struct urEnqueueCommandBufferExpTest
45
39
ASSERT_SUCCESS (urEnqueueUSMFill (queue, device_ptr, sizeof (zero_pattern),
46
40
&zero_pattern, allocation_size, 0 , nullptr ,
47
41
nullptr ));
42
+
43
+ for (int i = 0 ; i < num_copy_buffers; i++) {
44
+ ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, nullptr , nullptr ,
45
+ buffer_size * sizeof (int32_t ),
46
+ (void **)&(dst_buffers[i])));
47
+ ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, nullptr , nullptr ,
48
+ buffer_size * sizeof (int32_t ),
49
+ (void **)&(src_buffers[i])));
50
+
51
+ ASSERT_SUCCESS (urEnqueueUSMFill (
52
+ queue, src_buffers[i], sizeof (zero_pattern), &zero_pattern,
53
+ buffer_size * sizeof (int32_t ), 0 , nullptr , nullptr ));
54
+ }
55
+
48
56
ASSERT_SUCCESS (urQueueFinish (queue));
49
57
50
58
// Create command-buffer with a single kernel that does "Ptr[i] += 1;"
@@ -53,53 +61,101 @@ struct urEnqueueCommandBufferExpTest
53
61
cmd_buf_handle, kernel, n_dimensions, &global_offset, &global_size,
54
62
nullptr , 0 , nullptr , 0 , nullptr , 0 , nullptr , nullptr , nullptr ,
55
63
nullptr ));
64
+
65
+ // Schedule memory copying in order to prolong the buffer execution
66
+ for (int i = 0 ; i < num_copy_buffers; i++) {
67
+ ASSERT_SUCCESS (urCommandBufferAppendUSMMemcpyExp (
68
+ cmd_buf_handle, dst_buffers[i], src_buffers[i],
69
+ buffer_size * sizeof (int32_t ), 0 , nullptr , 0 , nullptr , nullptr ,
70
+ nullptr , nullptr ));
71
+ }
72
+
56
73
ASSERT_SUCCESS (urCommandBufferFinalizeExp (cmd_buf_handle));
57
74
}
58
75
59
76
virtual void TearDown () override {
60
- if (in_order_queue) {
61
- EXPECT_SUCCESS (urQueueRelease (in_order_queue));
62
- }
63
-
64
- if (out_of_order_queue) {
65
- EXPECT_SUCCESS (urQueueRelease (out_of_order_queue));
77
+ if (in_or_out_of_order_queue) {
78
+ EXPECT_SUCCESS (urQueueRelease (in_or_out_of_order_queue));
66
79
}
67
80
68
81
if (device_ptr) {
69
82
EXPECT_SUCCESS (urUSMFree (context, device_ptr));
70
83
}
71
84
72
- UUR_RETURN_ON_FATAL_FAILURE (urCommandBufferExpExecutionTest::TearDown ());
85
+ for (int i = 0 ; i < num_copy_buffers; i++) {
86
+ if (dst_buffers[i]) {
87
+ EXPECT_SUCCESS (urUSMFree (context, dst_buffers[i]));
88
+ }
89
+
90
+ if (src_buffers[i]) {
91
+ EXPECT_SUCCESS (urUSMFree (context, src_buffers[i]));
92
+ }
93
+ }
94
+
95
+ UUR_RETURN_ON_FATAL_FAILURE (
96
+ urCommandBufferExpExecutionTestWithParam::TearDown ());
73
97
}
74
98
75
- ur_queue_handle_t in_order_queue = nullptr ;
76
- ur_queue_handle_t out_of_order_queue = nullptr ;
99
+ ur_queue_handle_t in_or_out_of_order_queue = nullptr ;
77
100
78
101
static constexpr size_t global_size = 16 ;
79
102
static constexpr size_t global_offset = 0 ;
80
103
static constexpr size_t n_dimensions = 1 ;
81
104
static constexpr size_t allocation_size = sizeof (uint32_t ) * global_size;
82
105
void *device_ptr = nullptr ;
106
+
107
+ static constexpr int num_copy_buffers = 10 ;
108
+ static constexpr int buffer_size = 512 ;
109
+ int32_t *dst_buffers[num_copy_buffers] = {};
110
+ int32_t *src_buffers[num_copy_buffers] = {};
83
111
};
84
112
85
- UUR_INSTANTIATE_DEVICE_TEST_SUITE (urEnqueueCommandBufferExpTest);
113
+ std::string deviceTestWithQueueTypePrinter (
114
+ const ::testing::TestParamInfo<
115
+ std::tuple<uur::DeviceTuple, ur_queue_flags_t >> &info) {
116
+ auto device = std::get<0 >(info.param ).device ;
117
+ auto queue_type = std::get<1 >(info.param );
118
+
119
+ std::stringstream ss;
120
+
121
+ switch (queue_type) {
122
+ case 0 :
123
+ ss << " InOrderQueue" ;
124
+ break ;
125
+
126
+ case UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE:
127
+ ss << " OutOfOrderQueue" ;
128
+ break ;
129
+
130
+ default :
131
+ ss << " UnspecifiedQueueType" << queue_type;
132
+ }
133
+
134
+ return uur::GetPlatformAndDeviceName (device) + " __" +
135
+ uur::GTestSanitizeString (ss.str ());
136
+ }
137
+
138
+ UUR_DEVICE_TEST_SUITE_WITH_PARAM (
139
+ urEnqueueCommandBufferExpTest,
140
+ testing::Values (0 , UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE),
141
+ deviceTestWithQueueTypePrinter);
86
142
87
143
// Tests that the same command-buffer submitted across different in-order
88
144
// queues has an implicit dependency on first submission
89
145
TEST_P (urEnqueueCommandBufferExpTest, SerializeAcrossQueues) {
90
146
// Execute command-buffer to first in-order queue (created by parent
91
- // urQueueTest fixture)
147
+ // urQueueTestWithParam fixture)
92
148
ASSERT_SUCCESS (
93
149
urEnqueueCommandBufferExp (queue, cmd_buf_handle, 0 , nullptr , nullptr ));
94
150
95
151
// Execute command-buffer to second in-order queue, should have implicit
96
152
// dependency on first submission.
97
- ASSERT_SUCCESS (urEnqueueCommandBufferExp (in_order_queue, cmd_buf_handle, 0 ,
98
- nullptr , nullptr ));
153
+ ASSERT_SUCCESS (urEnqueueCommandBufferExp (
154
+ in_or_out_of_order_queue, cmd_buf_handle, 0 , nullptr , nullptr ));
99
155
100
156
// Wait for both submissions to complete
101
157
ASSERT_SUCCESS (urQueueFlush (queue));
102
- ASSERT_SUCCESS (urQueueFinish (in_order_queue ));
158
+ ASSERT_SUCCESS (urQueueFinish (in_or_out_of_order_queue ));
103
159
104
160
std::vector<uint32_t > Output (global_size);
105
161
ASSERT_SUCCESS (urEnqueueUSMMemcpy (queue, false , Output.data (), device_ptr,
@@ -113,24 +169,23 @@ TEST_P(urEnqueueCommandBufferExpTest, SerializeAcrossQueues) {
113
169
}
114
170
}
115
171
116
- // Tests that submitting a command-buffer twice to an out-of-order queue
117
- // relying on implicit serialization semantics for dependencies.
118
- TEST_P (urEnqueueCommandBufferExpTest, SerializeOutofOrderQueue) {
119
- ASSERT_SUCCESS (urEnqueueCommandBufferExp (out_of_order_queue, cmd_buf_handle,
120
- 0 , nullptr , nullptr ));
121
- ASSERT_SUCCESS (urEnqueueCommandBufferExp (out_of_order_queue, cmd_buf_handle,
122
- 0 , nullptr , nullptr ));
172
+ TEST_P (urEnqueueCommandBufferExpTest, SerializeInOrOutOfOrderQueue) {
173
+ const int iterations = 5 ;
174
+ for (int i = 0 ; i < iterations; i++) {
175
+ ASSERT_SUCCESS (urEnqueueCommandBufferExp (
176
+ in_or_out_of_order_queue, cmd_buf_handle, 0 , nullptr , nullptr ));
177
+ }
123
178
124
179
// Wait for both submissions to complete
125
- ASSERT_SUCCESS (urQueueFinish (out_of_order_queue ));
180
+ ASSERT_SUCCESS (urQueueFinish (in_or_out_of_order_queue ));
126
181
127
182
std::vector<uint32_t > Output (global_size);
128
- ASSERT_SUCCESS (urEnqueueUSMMemcpy (out_of_order_queue , true , Output. data () ,
129
- device_ptr, allocation_size, 0 , nullptr ,
130
- nullptr ));
183
+ ASSERT_SUCCESS (urEnqueueUSMMemcpy (in_or_out_of_order_queue , true ,
184
+ Output. data (), device_ptr, allocation_size ,
185
+ 0 , nullptr , nullptr ));
131
186
132
187
// Verify
133
- const uint32_t reference = 2 ;
188
+ const uint32_t reference = iterations ;
134
189
for (size_t i = 0 ; i < global_size; i++) {
135
190
ASSERT_EQ (reference, Output[i]);
136
191
}
0 commit comments