Skip to content

Commit

Permalink
[hip] Initialize the executable resource after allocation (#16397)
Browse files Browse the repository at this point in the history
This guarantees that we always have basic bookkeeping structure updated
for the resource. So if something goes wrong when creating the native
executable and we are relying on the `iree_hal_executable_destroy` to
destroy it, we don't crash.

Progress towards #15790
  • Loading branch information
antiagainst authored and monorimet committed Feb 14, 2024
1 parent ed282e2 commit 5f7bf24
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions experimental/hip/native_executable.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ iree_status_t iree_hal_hip_native_executable_create(
(char*)((char*)executable + sizeof(*executable) +
entry_point_count * sizeof(executable->entry_points[0])));

iree_hal_resource_initialize(&iree_hal_hip_native_executable_vtable,
&executable->resource);

// Load the HSACO image - this will fail if the device cannot handle the
// contents. We could check this prior to creating
hipModule_t module = NULL;
Expand All @@ -195,8 +198,6 @@ iree_status_t iree_hal_hip_native_executable_create(
}

if (iree_status_is_ok(status)) {
iree_hal_resource_initialize(&iree_hal_hip_native_executable_vtable,
&executable->resource);
executable->host_allocator = host_allocator;
executable->symbols = symbols;
executable->hip_module = module;
Expand Down

0 comments on commit 5f7bf24

Please sign in to comment.