Skip to content

Commit

Permalink
Fix dealloc barrier.
Browse files Browse the repository at this point in the history
  • Loading branch information
stellaraccident committed Feb 19, 2025
1 parent ff4a031 commit 66f2e05
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
24 changes: 13 additions & 11 deletions shortfin/src/shortfin/array/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,29 @@ storage storage::allocate_device(ScopedDevice &device,
.semaphores = &timeline_sem,
.payload_values = &signal_timepoint,
};
SHORTFIN_SCHED_LOG(
"storage::allocate_device(device={}, affinity={:x}):[{}, Wait@{} ->"
"Signal:@{}]",
static_cast<void *>(device.raw_device()->hal_device()),
device.affinity().queue_affinity(), static_cast<void *>(timeline_sem),
current_timepoint, signal_timepoint);
// Async allocate.
SHORTFIN_THROW_IF_ERROR(iree_hal_device_queue_alloca(
device.raw_device()->hal_device(), device.affinity().queue_affinity(),
wait_semaphore_list, signal_semaphore_list,
IREE_HAL_ALLOCATOR_POOL_DEFAULT, params, allocation_size,
buffer.for_output()));
SHORTFIN_SCHED_LOG(
"storage::allocate_device(device={}, affinity={:x}):[{}, Wait@{}:"
"Signal:@{}] -> buffer={}",
static_cast<void *>(device.raw_device()->hal_device()),
device.affinity().queue_affinity(), static_cast<void *>(timeline_sem),
current_timepoint, signal_timepoint, static_cast<void *>(buffer.get()));

// Device allocations are always async.
// TODO: DO NOT SUBMIT: Enable async destruction.
// TimelineResourceDestructor dtor =
// TimelineResource::CreateAsyncBufferDestructor(device, buffer);
TimelineResourceDestructor dtor =
TimelineResource::CreateAsyncBufferDestructor(device, buffer);
auto resource = device.fiber().NewTimelineResource(std::move(dtor));
resource->set_mutation_barrier(timeline_sem, signal_timepoint);
resource->use_barrier_insert(timeline_sem, signal_timepoint);
return storage(device, std::move(buffer), std::move(resource));
// return storage(device, std::move(buffer),
// device.fiber().NewTimelineResource(std::move(dtor)));
return storage(device, std::move(buffer),
device.fiber().NewTimelineResource());
// device.fiber().NewTimelineResource());
}

storage storage::allocate_host(ScopedDevice &device,
Expand Down
4 changes: 2 additions & 2 deletions shortfin/src/shortfin/local/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ class SHORTFIN_API Scheduler {
TimelineResource::Ref NewTimelineResource(
std::shared_ptr<Fiber> fiber,
TimelineResourceDestructor destructor = nullptr) {
return TimelineResource::Ref(
new TimelineResource(std::move(fiber), semaphore_count_, destructor));
return TimelineResource::Ref(new TimelineResource(
std::move(fiber), semaphore_count_, std::move(destructor)));
}

// Creates a new fence with capacity for all semaphores that are extant at
Expand Down

0 comments on commit 66f2e05

Please sign in to comment.