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