@@ -30,25 +30,40 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
3030 ze_command_list_handle_t CommandList,
3131 ze_command_list_handle_t CommandListTranslated,
3232 ze_command_list_handle_t CommandListResetEvents,
33- ze_command_list_handle_t CopyCommandList,
34- ZeStruct<ze_command_list_desc_t > ZeDesc,
35- ZeStruct<ze_command_list_desc_t > ZeCopyDesc,
33+ ze_command_list_handle_t CopyCommandList, ur_event_handle_t SignalEvent,
34+ ur_event_handle_t WaitEvent, ur_event_handle_t AllResetEvent,
3635 const ur_exp_command_buffer_desc_t *Desc, const bool IsInOrderCmdList);
3736
3837 ~ur_exp_command_buffer_handle_t_ ();
3938
40- void RegisterSyncPoint (ur_exp_command_buffer_sync_point_t SyncPoint,
41- ur_event_handle_t Event) {
42- SyncPoints[SyncPoint] = Event;
43- NextSyncPoint++;
44- }
39+ void registerSyncPoint (ur_exp_command_buffer_sync_point_t SyncPoint,
40+ ur_event_handle_t Event);
4541
46- ur_exp_command_buffer_sync_point_t GetNextSyncPoint () const {
42+ ur_exp_command_buffer_sync_point_t getNextSyncPoint () const {
4743 return NextSyncPoint;
4844 }
4945
5046 // Indicates if a copy engine is available for use
51- bool UseCopyEngine () const { return ZeCopyCommandList != nullptr ; }
47+ bool useCopyEngine () const { return ZeCopyCommandList != nullptr ; }
48+
49+ /* *
50+ * Obtains a fence for a specific L0 queue. If there is already an available
51+ * fence for this queue, it will be reused.
52+ * @param[in] ZeCommandQueue The L0 queue associated with the fence.
53+ * @param[out] ZeFence The fence.
54+ * @return UR_RESULT_SUCCESS or an error code on failure
55+ */
56+ ur_result_t getFenceForQueue (ze_command_queue_handle_t &ZeCommandQueue,
57+ ze_fence_handle_t &ZeFence);
58+
59+ /* *
60+ * Chooses which command list to use when appending a command to this command
61+ * buffer.
62+ * @param[in] PreferCopyEngine If true, will try to choose a copy engine
63+ * command-list. Will choose a compute command-list otherwise.
64+ * @return The chosen command list.
65+ */
66+ ze_command_list_handle_t chooseCommandList (bool PreferCopyEngine);
5267
5368 // UR context associated with this command-buffer
5469 ur_context_handle_t Context;
@@ -61,12 +76,17 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
6176 ze_command_list_handle_t ZeComputeCommandListTranslated;
6277 // Level Zero command list handle
6378 ze_command_list_handle_t ZeCommandListResetEvents;
64- // Level Zero command list descriptor
65- ZeStruct<ze_command_list_desc_t > ZeCommandListDesc;
6679 // Level Zero Copy command list handle
6780 ze_command_list_handle_t ZeCopyCommandList;
68- // Level Zero Copy command list descriptor
69- ZeStruct<ze_command_list_desc_t > ZeCopyCommandListDesc;
81+ // Event which will signals the most recent execution of the command-buffer
82+ // has finished
83+ ur_event_handle_t SignalEvent = nullptr ;
84+ // Event which a command-buffer waits on until the wait-list dependencies
85+ // passed to a command-buffer enqueue have been satisfied.
86+ ur_event_handle_t WaitEvent = nullptr ;
87+ // Event which a command-buffer waits on until the main command-list event
88+ // have been reset.
89+ ur_event_handle_t AllResetEvent = nullptr ;
7090 // This flag is must be set to false if at least one copy command has been
7191 // added to `ZeCopyCommandList`
7292 bool MCopyCommandListEmpty = true ;
@@ -77,26 +97,15 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
7797 // Must be an element in ZeFencesMap, so is not required to be destroyed
7898 // itself.
7999 ze_fence_handle_t ZeActiveFence;
80- // Queue properties from command-buffer descriptor
81- // TODO: Do we need these?
82- ur_queue_properties_t QueueProperties;
83100 // Map of sync_points to ur_events
84101 std::unordered_map<ur_exp_command_buffer_sync_point_t , ur_event_handle_t >
85102 SyncPoints;
86103 // Next sync_point value (may need to consider ways to reuse values if 32-bits
87104 // is not enough)
88105 ur_exp_command_buffer_sync_point_t NextSyncPoint;
89- // List of Level Zero events associated to submitted commands.
106+ // List of Level Zero events associated with submitted commands.
90107 std::vector<ze_event_handle_t > ZeEventsList;
91- // Event which will signals the most recent execution of the command-buffer
92- // has finished
93- ur_event_handle_t SignalEvent = nullptr ;
94- // Event which a command-buffer waits on until the wait-list dependencies
95- // passed to a command-buffer enqueue have been satisfied.
96- ur_event_handle_t WaitEvent = nullptr ;
97- // Event which a command-buffer waits on until the main command-list event
98- // have been reset.
99- ur_event_handle_t AllResetEvent = nullptr ;
108+
100109 // Indicates if command-buffer commands can be updated after it is closed.
101110 bool IsUpdatable = false ;
102111 // Indicates if command buffer was finalized.
0 commit comments