@@ -129,6 +129,68 @@ TEST_P(CommandEventSyncUpdateTest, USMFillExp) {
129129 }
130130}
131131
132+ // Test fill using a large pattern size since implementations may need to handle
133+ // this differently.
134+ TEST_P (CommandEventSyncUpdateTest, USMFillLargePatternExp) {
135+ // Device ptrs are allocated in the test fixture with 32-bit values * num
136+ // elements, since we are doubling the pattern size we want to treat those
137+ // device pointers as if they were created with half the number of elements.
138+ constexpr size_t modifiedElementSize = elements / 2 ;
139+ // Get wait event from queue fill on ptr 0
140+ uint64_t patternX = 42 ;
141+ ASSERT_SUCCESS (urEnqueueUSMFill (queue, device_ptrs[0 ], sizeof (patternX),
142+ &patternX, allocation_size, 0 , nullptr ,
143+ &external_events[0 ]));
144+
145+ // Test fill command overwriting ptr 0 waiting on queue event
146+ uint64_t patternY = 0xA ;
147+ ASSERT_SUCCESS (urCommandBufferAppendUSMFillExp (
148+ updatable_cmd_buf_handle, device_ptrs[0 ], &patternY, sizeof (patternY),
149+ allocation_size, 0 , nullptr , 1 , &external_events[0 ], nullptr ,
150+ &external_events[1 ], &command_handles[0 ]));
151+ ASSERT_NE (nullptr , command_handles[0 ]);
152+ ASSERT_SUCCESS (urCommandBufferFinalizeExp (updatable_cmd_buf_handle));
153+ ASSERT_SUCCESS (urCommandBufferEnqueueExp (updatable_cmd_buf_handle, queue, 0 ,
154+ nullptr , nullptr ));
155+
156+ // Queue read ptr 0 based on event returned from command-buffer command
157+ std::array<uint64_t , modifiedElementSize> host_enqueue_ptr{};
158+ ASSERT_SUCCESS (urEnqueueUSMMemcpy (queue, false , host_enqueue_ptr.data (),
159+ device_ptrs[0 ], allocation_size, 1 ,
160+ &external_events[1 ], nullptr ));
161+
162+ // Verify
163+ ASSERT_SUCCESS (urQueueFinish (queue));
164+ for (size_t i = 0 ; i < modifiedElementSize; i++) {
165+ ASSERT_EQ (host_enqueue_ptr[i], patternY);
166+ }
167+
168+ uint64_t patternZ = 666 ;
169+ ASSERT_SUCCESS (urEnqueueUSMFill (queue, device_ptrs[0 ], sizeof (patternZ),
170+ &patternZ, allocation_size, 0 , nullptr ,
171+ &external_events[2 ]));
172+
173+ // Update command command-wait event to wait on fill of new value
174+ ASSERT_SUCCESS (urCommandBufferUpdateWaitEventsExp (command_handles[0 ], 1 ,
175+ &external_events[2 ]));
176+
177+ // Get a new signal event for command-buffer
178+ ASSERT_SUCCESS (urCommandBufferUpdateSignalEventExp (command_handles[0 ],
179+ &external_events[3 ]));
180+ ASSERT_SUCCESS (urCommandBufferEnqueueExp (updatable_cmd_buf_handle, queue, 0 ,
181+ nullptr , nullptr ));
182+
183+ ASSERT_SUCCESS (urEnqueueUSMMemcpy (queue, false , host_enqueue_ptr.data (),
184+ device_ptrs[0 ], allocation_size, 1 ,
185+ &external_events[3 ], nullptr ));
186+
187+ // Verify update
188+ ASSERT_SUCCESS (urQueueFinish (queue));
189+ for (size_t i = 0 ; i < modifiedElementSize; i++) {
190+ ASSERT_EQ (host_enqueue_ptr[i], patternY);
191+ }
192+ }
193+
132194TEST_P (CommandEventSyncUpdateTest, MemBufferCopyExp) {
133195 // Get wait event from queue fill on buffer 0
134196 uint32_t patternX = 42 ;
@@ -532,6 +594,68 @@ TEST_P(CommandEventSyncUpdateTest, MemBufferWriteRectExp) {
532594 }
533595}
534596
597+ // Test fill using a large pattern size since implementations may need to handle
598+ // this differently.
599+ TEST_P (CommandEventSyncUpdateTest, MemBufferFillLargePatternExp) {
600+ // Device buffers are allocated in the test fixture with 32-bit values * num
601+ // elements, since we are doubling the pattern size we want to treat those
602+ // device pointers as if they were created with half the number of elements.
603+ constexpr size_t modifiedElementSize = elements / 2 ;
604+ // Get wait event from queue fill on buffer 0
605+ uint64_t patternX = 42 ;
606+ ASSERT_SUCCESS (urEnqueueMemBufferFill (queue, buffers[0 ], &patternX,
607+ sizeof (patternX), 0 , allocation_size,
608+ 0 , nullptr , &external_events[0 ]));
609+
610+ // Test fill command overwriting buffer 0 based on queue event
611+ uint64_t patternY = 0xA ;
612+ ASSERT_SUCCESS (urCommandBufferAppendMemBufferFillExp (
613+ updatable_cmd_buf_handle, buffers[0 ], &patternY, sizeof (patternY), 0 ,
614+ allocation_size, 0 , nullptr , 1 , &external_events[0 ], nullptr ,
615+ &external_events[1 ], &command_handles[0 ]));
616+ ASSERT_NE (nullptr , command_handles[0 ]);
617+ ASSERT_SUCCESS (urCommandBufferFinalizeExp (updatable_cmd_buf_handle));
618+ ASSERT_SUCCESS (urCommandBufferEnqueueExp (updatable_cmd_buf_handle, queue, 0 ,
619+ nullptr , nullptr ));
620+
621+ // Queue read buffer 0 based on event returned from command-buffer command
622+ std::array<uint64_t , modifiedElementSize> host_enqueue_ptr{};
623+ ASSERT_SUCCESS (urEnqueueMemBufferRead (
624+ queue, buffers[0 ], false , 0 , allocation_size, host_enqueue_ptr.data (),
625+ 1 , &external_events[1 ], nullptr ));
626+
627+ // Verify
628+ ASSERT_SUCCESS (urQueueFinish (queue));
629+ for (size_t i = 0 ; i < modifiedElementSize; i++) {
630+ ASSERT_EQ (host_enqueue_ptr[i], patternY);
631+ }
632+
633+ uint64_t patternZ = 666 ;
634+ ASSERT_SUCCESS (urEnqueueMemBufferFill (queue, buffers[0 ], &patternZ,
635+ sizeof (patternZ), 0 , allocation_size,
636+ 0 , nullptr , &external_events[2 ]));
637+
638+ // Update command command-wait event to wait on fill of new value
639+ ASSERT_SUCCESS (urCommandBufferUpdateWaitEventsExp (command_handles[0 ], 1 ,
640+ &external_events[2 ]));
641+
642+ // Get a new signal event for command-buffer
643+ ASSERT_SUCCESS (urCommandBufferUpdateSignalEventExp (command_handles[0 ],
644+ &external_events[3 ]));
645+
646+ ASSERT_SUCCESS (urCommandBufferEnqueueExp (updatable_cmd_buf_handle, queue, 0 ,
647+ nullptr , nullptr ));
648+ ASSERT_SUCCESS (urEnqueueMemBufferRead (
649+ queue, buffers[0 ], false , 0 , allocation_size, host_enqueue_ptr.data (),
650+ 1 , &external_events[3 ], nullptr ));
651+
652+ // Verify update
653+ ASSERT_SUCCESS (urQueueFinish (queue));
654+ for (size_t i = 0 ; i < modifiedElementSize; i++) {
655+ ASSERT_EQ (host_enqueue_ptr[i], patternY);
656+ }
657+ }
658+
535659TEST_P (CommandEventSyncUpdateTest, MemBufferFillExp) {
536660 // Get wait event from queue fill on buffer 0
537661 uint32_t patternX = 42 ;
0 commit comments