@@ -86,16 +86,18 @@ iree_status_t iree_task_executor_create(
86
86
// executor and since we know the precise lifetime of them we can keep them
87
87
// entirely within the system here.
88
88
if (iree_status_is_ok (status )) {
89
- status = iree_task_pool_initialize (
90
- allocator , sizeof (iree_task_dispatch_slice_t ),
91
- worker_count * IREE_TASK_EXECUTOR_INITIAL_SLICE_RESERVATION_PER_WORKER ,
92
- & executor -> slice_task_pool );
89
+ status = iree_task_pool_initialize (allocator , sizeof (iree_task_fence_t ), 8 ,
90
+ & executor -> fence_task_pool );
93
91
}
94
92
if (iree_status_is_ok (status )) {
95
93
status = iree_task_pool_initialize (
96
- allocator , sizeof (iree_task_dispatch_shard_t ),
97
- worker_count * IREE_TASK_EXECUTOR_INITIAL_SHARD_RESERVATION_PER_WORKER ,
98
- & executor -> shard_task_pool );
94
+ allocator ,
95
+ iree_max (sizeof (iree_task_dispatch_shard_t ),
96
+ sizeof (iree_task_dispatch_slice_t )),
97
+ worker_count *
98
+ iree_max (IREE_TASK_EXECUTOR_INITIAL_SHARD_RESERVATION_PER_WORKER ,
99
+ IREE_TASK_EXECUTOR_INITIAL_SLICE_RESERVATION_PER_WORKER ),
100
+ & executor -> dispatch_task_pool );
99
101
}
100
102
101
103
// Bring up the workers; the threads will be created here but be suspended
@@ -169,8 +171,8 @@ static void iree_task_executor_destroy(iree_task_executor_t* executor) {
169
171
iree_slim_mutex_deinitialize (& executor -> coordinator_mutex );
170
172
iree_atomic_task_slist_deinitialize (& executor -> incoming_ready_slist );
171
173
iree_atomic_task_slist_deinitialize (& executor -> incoming_waiting_slist );
172
- iree_task_pool_deinitialize (& executor -> slice_task_pool );
173
- iree_task_pool_deinitialize (& executor -> shard_task_pool );
174
+ iree_task_pool_deinitialize (& executor -> fence_task_pool );
175
+ iree_task_pool_deinitialize (& executor -> dispatch_task_pool );
174
176
iree_allocator_free (executor -> allocator , executor );
175
177
176
178
IREE_TRACE_ZONE_END (z0 );
@@ -188,6 +190,19 @@ void iree_task_executor_release(iree_task_executor_t* executor) {
188
190
}
189
191
}
190
192
193
+ iree_status_t iree_task_executor_acquire_fence (iree_task_executor_t * executor ,
194
+ iree_task_scope_t * scope ,
195
+ iree_task_fence_t * * out_fence ) {
196
+ * out_fence = NULL ;
197
+ iree_task_fence_t * fence = NULL ;
198
+ IREE_RETURN_IF_ERROR (iree_task_pool_acquire (& executor -> fence_task_pool ,
199
+ (iree_task_t * * )& fence ));
200
+ iree_task_fence_initialize (scope , fence );
201
+ fence -> header .pool = & executor -> fence_task_pool ;
202
+ * out_fence = fence ;
203
+ return iree_ok_status ();
204
+ }
205
+
191
206
// Schedules a generic task to a worker matching its affinity.
192
207
// The task will be posted to the worker mailbox and available for the worker to
193
208
// begin processing as soon as the |post_batch| is submitted.
@@ -262,11 +277,11 @@ void iree_task_executor_schedule_ready_tasks(
262
277
} else {
263
278
if (task -> flags & IREE_TASK_FLAG_DISPATCH_SLICED ) {
264
279
iree_task_dispatch_issue_sliced ((iree_task_dispatch_t * )task ,
265
- & executor -> slice_task_pool ,
280
+ & executor -> dispatch_task_pool ,
266
281
pending_submission , post_batch );
267
282
} else {
268
283
iree_task_dispatch_issue_sharded ((iree_task_dispatch_t * )task ,
269
- & executor -> shard_task_pool ,
284
+ & executor -> dispatch_task_pool ,
270
285
pending_submission , post_batch );
271
286
}
272
287
}
@@ -520,17 +535,7 @@ static void iree_task_executor_wait_any_task(
520
535
void iree_task_executor_coordinate (iree_task_executor_t * executor ,
521
536
iree_task_worker_t * current_worker ,
522
537
bool speculative ) {
523
- if (speculative ) {
524
- if (!iree_slim_mutex_try_lock (& executor -> coordinator_mutex )) {
525
- // Another thread is already holding the coordination lock.
526
- // Return to the caller to wait for it to finish.
527
- // TODO(benvanik): spin here if it's likely we'll have work after the
528
- // other coordinator finishes - that way we don't enter the wait.
529
- return ;
530
- }
531
- } else {
532
- iree_slim_mutex_lock (& executor -> coordinator_mutex );
533
- }
538
+ iree_slim_mutex_lock (& executor -> coordinator_mutex );
534
539
IREE_TRACE_ZONE_BEGIN (z0 );
535
540
536
541
// We may be adding tasks/waiting/etc on each pass through coordination - to
0 commit comments