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::urCommandBufferExpExecutionTestWithParam<ur_queue_flags_t > {
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 (urCommandBufferExpExecutionTestWithParam::SetUp ());
24
+ UUR_RETURN_ON_FATAL_FAILURE (
25
+ urCommandBufferExpExecutionTestWithParam::SetUp ());
24
26
25
- // Create an in-order queue
26
- queue_type = std::get<1 >(GetParam ());
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 ());
27
29
ur_queue_properties_t queue_properties = {
28
- UR_STRUCTURE_TYPE_QUEUE_PROPERTIES, nullptr , queue_type}; // GetParam()}; //0};
29
- ASSERT_SUCCESS (
30
- urQueueCreate (context, device, &queue_properties, &in_or_out_of_order_queue));
31
-
32
- // // Create an out-of-order queue
33
- // queue_properties.flags = UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE;
34
- // ASSERT_SUCCESS(
35
- // urQueueCreate(context, device, &queue_properties, &out_of_order_queue));
36
- // 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));
37
33
38
34
ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, nullptr , nullptr ,
39
35
allocation_size, &device_ptr));
@@ -47,13 +43,18 @@ struct urEnqueueCommandBufferExpTest
47
43
std::vector<int > temp_val (buffer_size, 3 );
48
44
49
45
for (int i = 0 ; i < num_copy_buffers; i++) {
50
- ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, nullptr , nullptr , buffer_size * sizeof (int ), (void **) &(dst_buffers[i])));
51
- ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, nullptr , nullptr , buffer_size * sizeof (int ), (void **) &(src_buffers[i])));
52
-
53
- ASSERT_SUCCESS (urEnqueueUSMMemcpy (in_or_out_of_order_queue, false , src_buffers[i], temp_val.data (), buffer_size * sizeof (int ), 0 , nullptr , nullptr ));
46
+ ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, nullptr , nullptr ,
47
+ buffer_size * sizeof (int32_t ),
48
+ (void **)&(dst_buffers[i])));
49
+ ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, nullptr , nullptr ,
50
+ buffer_size * sizeof (int32_t ),
51
+ (void **)&(src_buffers[i])));
52
+
53
+ ASSERT_SUCCESS (urEnqueueUSMMemcpy (
54
+ in_or_out_of_order_queue, false , src_buffers[i], temp_val.data (),
55
+ buffer_size * sizeof (int32_t ), 0 , nullptr , nullptr ));
54
56
}
55
57
56
-
57
58
ASSERT_SUCCESS (urQueueFinish (queue));
58
59
59
60
// Create command-buffer with a single kernel that does "Ptr[i] += 1;"
@@ -63,9 +64,12 @@ struct urEnqueueCommandBufferExpTest
63
64
nullptr , 0 , nullptr , 0 , nullptr , 0 , nullptr , nullptr , nullptr ,
64
65
nullptr ));
65
66
66
-
67
+ // Schedule memory copying in order to prolong the buffer execution
67
68
for (int i = 0 ; i < num_copy_buffers; i++) {
68
- ASSERT_SUCCESS (urCommandBufferAppendUSMMemcpyExp (cmd_buf_handle, dst_buffers[i], src_buffers[i], buffer_size * sizeof (int ), 0 , nullptr , 0 , nullptr , nullptr , nullptr , nullptr ));
69
+ ASSERT_SUCCESS (urCommandBufferAppendUSMMemcpyExp (
70
+ cmd_buf_handle, dst_buffers[i], src_buffers[i],
71
+ buffer_size * sizeof (int32_t ), 0 , nullptr , 0 , nullptr , nullptr , nullptr ,
72
+ nullptr ));
69
73
}
70
74
71
75
ASSERT_SUCCESS (urCommandBufferFinalizeExp (cmd_buf_handle));
@@ -76,10 +80,6 @@ struct urEnqueueCommandBufferExpTest
76
80
EXPECT_SUCCESS (urQueueRelease (in_or_out_of_order_queue));
77
81
}
78
82
79
- // if (out_of_order_queue) {
80
- // EXPECT_SUCCESS(urQueueRelease(out_of_order_queue));
81
- // }
82
-
83
83
if (device_ptr) {
84
84
EXPECT_SUCCESS (urUSMFree (context, device_ptr));
85
85
}
@@ -94,13 +94,11 @@ struct urEnqueueCommandBufferExpTest
94
94
}
95
95
}
96
96
97
- UUR_RETURN_ON_FATAL_FAILURE (urCommandBufferExpExecutionTestWithParam::TearDown ());
97
+ UUR_RETURN_ON_FATAL_FAILURE (
98
+ urCommandBufferExpExecutionTestWithParam::TearDown ());
98
99
}
99
100
100
101
ur_queue_handle_t in_or_out_of_order_queue = nullptr ;
101
- ur_queue_flags_t queue_type; // = 0;
102
-
103
- // ur_queue_handle_t out_of_order_queue = nullptr;
104
102
105
103
static constexpr size_t global_size = 16 ;
106
104
static constexpr size_t global_offset = 0 ;
@@ -110,56 +108,52 @@ struct urEnqueueCommandBufferExpTest
110
108
111
109
static constexpr int num_copy_buffers = 10 ;
112
110
static constexpr int buffer_size = 512 ;
113
- int * dst_buffers[num_copy_buffers];
114
- int * src_buffers[num_copy_buffers];
111
+ int32_t * dst_buffers[num_copy_buffers] = {} ;
112
+ int32_t * src_buffers[num_copy_buffers] = {} ;
115
113
};
116
114
117
-
118
115
std::string deviceTestWithQueueTypePrinter (
119
- const ::testing::TestParamInfo<std::tuple<uur::DeviceTuple, ur_queue_flags_t >> &info) {
116
+ const ::testing::TestParamInfo<
117
+ std::tuple<uur::DeviceTuple, ur_queue_flags_t >> &info) {
120
118
auto device = std::get<0 >(info.param ).device ;
121
119
auto queue_type = std::get<1 >(info.param );
122
120
123
121
std::stringstream ss;
124
122
125
123
switch (queue_type) {
126
- case 0 :
127
- ss << " InOrderQueue" ;
128
- break ;
124
+ case 0 :
125
+ ss << " InOrderQueue" ;
126
+ break ;
129
127
130
- // change to if and bitwise and?
131
- case UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE:
132
- ss << " OutOfOrderQueue" ;
133
- break ;
128
+ case UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE:
129
+ ss << " OutOfOrderQueue" ;
130
+ break ;
134
131
135
- default :
136
- ss << " UnspecifiedQueueType" << queue_type;
132
+ default :
133
+ ss << " UnspecifiedQueueType" << queue_type;
137
134
}
138
135
139
-
140
136
return uur::GetPlatformAndDeviceName (device) + " __" +
141
137
uur::GTestSanitizeString (ss.str ());
142
138
}
143
139
144
- // UUR_INSTANTIATE_DEVICE_TEST_SUITE(urEnqueueCommandBufferExpTest);
145
- UUR_DEVICE_TEST_SUITE_WITH_PARAM (urEnqueueCommandBufferExpTest, testing::Values(0 , UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE), deviceTestWithQueueTypePrinter);
140
+ UUR_DEVICE_TEST_SUITE_WITH_PARAM (
141
+ urEnqueueCommandBufferExpTest,
142
+ testing::Values (0 , UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE),
143
+ deviceTestWithQueueTypePrinter);
146
144
147
145
// Tests that the same command-buffer submitted across different in-order
148
146
// queues has an implicit dependency on first submission
149
147
TEST_P (urEnqueueCommandBufferExpTest, SerializeAcrossQueues) {
150
148
// Execute command-buffer to first in-order queue (created by parent
151
- // urQueueTest fixture)
152
- if (queue_type == UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) {
153
- GTEST_SKIP () << " unwantedoutoforder" ;
154
- }
155
-
149
+ // urQueueTestWithParam fixture)
156
150
ASSERT_SUCCESS (
157
151
urEnqueueCommandBufferExp (queue, cmd_buf_handle, 0 , nullptr , nullptr ));
158
152
159
153
// Execute command-buffer to second in-order queue, should have implicit
160
154
// dependency on first submission.
161
- ASSERT_SUCCESS (urEnqueueCommandBufferExp (in_or_out_of_order_queue, cmd_buf_handle, 0 ,
162
- nullptr , nullptr ));
155
+ ASSERT_SUCCESS (urEnqueueCommandBufferExp (
156
+ in_or_out_of_order_queue, cmd_buf_handle, 0 , nullptr , nullptr ));
163
157
164
158
// Wait for both submissions to complete
165
159
ASSERT_SUCCESS (urQueueFlush (queue));
@@ -177,47 +171,24 @@ TEST_P(urEnqueueCommandBufferExpTest, SerializeAcrossQueues) {
177
171
}
178
172
}
179
173
180
- // // Tests that submitting a command-buffer twice to an out-of-order queue
181
- // // relying on implicit serialization semantics for dependencies.
182
- // TEST_P(urEnqueueCommandBufferExpTest, SerializeOutofOrderQueue) {
183
- // ASSERT_SUCCESS(urEnqueueCommandBufferExp(out_of_order_queue, cmd_buf_handle,
184
- // 0, nullptr, nullptr));
185
- // ASSERT_SUCCESS(urEnqueueCommandBufferExp(out_of_order_queue, cmd_buf_handle,
186
- // 0, nullptr, nullptr));
187
-
188
- // // Wait for both submissions to complete
189
- // ASSERT_SUCCESS(urQueueFinish(out_of_order_queue));
190
-
191
- // std::vector<uint32_t> Output(global_size);
192
- // ASSERT_SUCCESS(urEnqueueUSMMemcpy(out_of_order_queue, true, Output.data(),
193
- // device_ptr, allocation_size, 0, nullptr,
194
- // nullptr));
195
-
196
- // // Verify
197
- // const uint32_t reference = 2;
198
- // for (size_t i = 0; i < global_size; i++) {
199
- // ASSERT_EQ(reference, Output[i]);
200
- // }
201
- // }
202
-
203
174
TEST_P (urEnqueueCommandBufferExpTest, SerializeInOrOutOfOrderQueue) {
204
175
const int iterations = 5 ;
205
176
for (int i = 0 ; i < iterations; i++) {
206
- ASSERT_SUCCESS (urEnqueueCommandBufferExp (in_or_out_of_order_queue, cmd_buf_handle,
207
- 0 , nullptr , nullptr ));
177
+ ASSERT_SUCCESS (urEnqueueCommandBufferExp (
178
+ in_or_out_of_order_queue, cmd_buf_handle, 0 , nullptr , nullptr ));
208
179
}
209
180
210
181
// Wait for both submissions to complete
211
182
ASSERT_SUCCESS (urQueueFinish (in_or_out_of_order_queue));
212
183
213
184
std::vector<uint32_t > Output (global_size);
214
- ASSERT_SUCCESS (urEnqueueUSMMemcpy (in_or_out_of_order_queue, true , Output. data (),
215
- device_ptr, allocation_size, 0 , nullptr ,
216
- nullptr ));
185
+ ASSERT_SUCCESS (urEnqueueUSMMemcpy (in_or_out_of_order_queue, true ,
186
+ Output. data (), device_ptr, allocation_size ,
187
+ 0 , nullptr , nullptr ));
217
188
218
189
// Verify
219
190
const uint32_t reference = iterations;
220
191
for (size_t i = 0 ; i < global_size; i++) {
221
192
ASSERT_EQ (reference, Output[i]);
222
193
}
223
- }
194
+ }
0 commit comments