Renaming HAL function host allocator args to host_allocator. (#9388)
diff --git a/experimental/rocm/registration/driver_module.c b/experimental/rocm/registration/driver_module.c index 2db41b4..8b4b9cc 100644 --- a/experimental/rocm/registration/driver_module.c +++ b/experimental/rocm/registration/driver_module.c
@@ -30,7 +30,7 @@ } static iree_status_t iree_hal_rocm_driver_factory_try_create( - void *self, iree_hal_driver_id_t driver_id, iree_allocator_t allocator, + void *self, iree_hal_driver_id_t driver_id, iree_allocator_t host_allocator, iree_hal_driver_t **out_driver) { IREE_ASSERT_ARGUMENT(out_driver); *out_driver = NULL; @@ -48,7 +48,7 @@ iree_hal_rocm_driver_options_t driver_options; iree_hal_rocm_driver_options_initialize(&driver_options); iree_status_t status = iree_hal_rocm_driver_create( - identifier, &driver_options, allocator, out_driver); + identifier, &driver_options, host_allocator, out_driver); IREE_TRACE_ZONE_END(z0); return status; }
diff --git a/runtime/src/iree/hal/driver.c b/runtime/src/iree/hal/driver.c index 778aaed..cb1f9a8 100644 --- a/runtime/src/iree/hal/driver.c +++ b/runtime/src/iree/hal/driver.c
@@ -18,7 +18,7 @@ IREE_HAL_API_RETAIN_RELEASE(driver); IREE_API_EXPORT iree_status_t iree_hal_driver_query_available_devices( - iree_hal_driver_t* driver, iree_allocator_t allocator, + iree_hal_driver_t* driver, iree_allocator_t host_allocator, iree_hal_device_info_t** out_device_infos, iree_host_size_t* out_device_info_count) { IREE_ASSERT_ARGUMENT(driver); @@ -27,33 +27,33 @@ *out_device_info_count = 0; IREE_TRACE_ZONE_BEGIN(z0); iree_status_t status = _VTABLE_DISPATCH(driver, query_available_devices)( - driver, allocator, out_device_infos, out_device_info_count); + driver, host_allocator, out_device_infos, out_device_info_count); IREE_TRACE_ZONE_END(z0); return status; } IREE_API_EXPORT iree_status_t iree_hal_driver_create_device( iree_hal_driver_t* driver, iree_hal_device_id_t device_id, - iree_allocator_t allocator, iree_hal_device_t** out_device) { + iree_allocator_t host_allocator, iree_hal_device_t** out_device) { IREE_ASSERT_ARGUMENT(driver); IREE_ASSERT_ARGUMENT(out_device); *out_device = NULL; IREE_TRACE_ZONE_BEGIN(z0); iree_status_t status = _VTABLE_DISPATCH(driver, create_device)( - driver, device_id, allocator, out_device); + driver, device_id, host_allocator, out_device); IREE_TRACE_ZONE_END(z0); return status; } IREE_API_EXPORT iree_status_t iree_hal_driver_create_default_device( - iree_hal_driver_t* driver, iree_allocator_t allocator, + iree_hal_driver_t* driver, iree_allocator_t host_allocator, iree_hal_device_t** out_device) { IREE_ASSERT_ARGUMENT(driver); IREE_ASSERT_ARGUMENT(out_device); *out_device = NULL; IREE_TRACE_ZONE_BEGIN(z0); iree_status_t status = _VTABLE_DISPATCH(driver, create_device)( - driver, IREE_HAL_DRIVER_ID_INVALID, allocator, out_device); + driver, IREE_HAL_DRIVER_ID_INVALID, host_allocator, out_device); IREE_TRACE_ZONE_END(z0); return status; }
diff --git a/runtime/src/iree/hal/driver.h b/runtime/src/iree/hal/driver.h index 65cbd66..cb7390a 100644 --- a/runtime/src/iree/hal/driver.h +++ b/runtime/src/iree/hal/driver.h
@@ -74,19 +74,19 @@ // the caller is done with it |out_device_infos| must be freed with that same // allocator by the caller. IREE_API_EXPORT iree_status_t iree_hal_driver_query_available_devices( - iree_hal_driver_t* driver, iree_allocator_t allocator, + iree_hal_driver_t* driver, iree_allocator_t host_allocator, iree_hal_device_info_t** out_device_infos, iree_host_size_t* out_device_info_count); // Creates a device as queried with iree_hal_driver_query_available_devices. IREE_API_EXPORT iree_status_t iree_hal_driver_create_device( iree_hal_driver_t* driver, iree_hal_device_id_t device_id, - iree_allocator_t allocator, iree_hal_device_t** out_device); + iree_allocator_t host_allocator, iree_hal_device_t** out_device); // Creates the driver-defined "default" device. This may simply be the first // device enumerated. IREE_API_EXPORT iree_status_t iree_hal_driver_create_default_device( - iree_hal_driver_t* driver, iree_allocator_t allocator, + iree_hal_driver_t* driver, iree_allocator_t host_allocator, iree_hal_device_t** out_device); //===----------------------------------------------------------------------===// @@ -97,13 +97,13 @@ void(IREE_API_PTR* destroy)(iree_hal_driver_t* driver); iree_status_t(IREE_API_PTR* query_available_devices)( - iree_hal_driver_t* driver, iree_allocator_t allocator, + iree_hal_driver_t* driver, iree_allocator_t host_allocator, iree_hal_device_info_t** out_device_infos, iree_host_size_t* out_device_info_count); iree_status_t(IREE_API_PTR* create_device)(iree_hal_driver_t* driver, iree_hal_device_id_t device_id, - iree_allocator_t allocator, + iree_allocator_t host_allocator, iree_hal_device_t** out_device); } iree_hal_driver_vtable_t; IREE_HAL_ASSERT_VTABLE_LAYOUT(iree_hal_driver_vtable_t);
diff --git a/runtime/src/iree/hal/driver_registry.c b/runtime/src/iree/hal/driver_registry.c index 864cd7d..e1f6013 100644 --- a/runtime/src/iree/hal/driver_registry.c +++ b/runtime/src/iree/hal/driver_registry.c
@@ -188,7 +188,7 @@ } IREE_API_EXPORT iree_status_t iree_hal_driver_registry_enumerate( - iree_hal_driver_registry_t* registry, iree_allocator_t allocator, + iree_hal_driver_registry_t* registry, iree_allocator_t host_allocator, iree_hal_driver_info_t** out_driver_infos, iree_host_size_t* out_driver_info_count) { IREE_ASSERT_ARGUMENT(registry); @@ -223,7 +223,7 @@ iree_host_size_t total_driver_infos_size = total_driver_info_count * sizeof(iree_hal_driver_info_t); if (iree_status_is_ok(status)) { - status = iree_allocator_malloc(allocator, + status = iree_allocator_malloc(host_allocator, total_driver_infos_size + total_storage_size, (void**)out_driver_infos); } @@ -255,7 +255,7 @@ // Cleanup memory if we failed. if (!iree_status_is_ok(status) && *out_driver_infos) { - iree_allocator_free(allocator, *out_driver_infos); + iree_allocator_free(host_allocator, *out_driver_infos); } IREE_TRACE_ZONE_END(z0); return status; @@ -263,7 +263,7 @@ IREE_API_EXPORT iree_status_t iree_hal_driver_registry_try_create( iree_hal_driver_registry_t* registry, iree_hal_driver_id_t driver_id, - iree_allocator_t allocator, iree_hal_driver_t** out_driver) { + iree_allocator_t host_allocator, iree_hal_driver_t** out_driver) { IREE_ASSERT_ARGUMENT(registry); if (driver_id == IREE_HAL_DRIVER_ID_INVALID) { return iree_make_status(IREE_STATUS_INVALID_ARGUMENT, "invalid driver id"); @@ -297,7 +297,7 @@ IREE_API_EXPORT iree_status_t iree_hal_driver_registry_try_create_by_name( iree_hal_driver_registry_t* registry, iree_string_view_t driver_name, - iree_allocator_t allocator, iree_hal_driver_t** out_driver) { + iree_allocator_t host_allocator, iree_hal_driver_t** out_driver) { IREE_ASSERT_ARGUMENT(registry); IREE_TRACE_ZONE_BEGIN(z0); IREE_TRACE_ZONE_APPEND_TEXT(z0, driver_name.data, driver_name.size); @@ -347,7 +347,7 @@ // example a delay-loaded driver cannot be created even if it was enumerated. if (hit_driver_id != IREE_HAL_DRIVER_ID_INVALID) { status = hit_factory->try_create(hit_factory->self, hit_driver_id, - allocator, out_driver); + host_allocator, out_driver); } else { status = iree_make_status(IREE_STATUS_NOT_FOUND, "no driver '%.*s' registered",
diff --git a/runtime/src/iree/hal/driver_registry.h b/runtime/src/iree/hal/driver_registry.h index fad02b4..c6c36b4 100644 --- a/runtime/src/iree/hal/driver_registry.h +++ b/runtime/src/iree/hal/driver_registry.h
@@ -69,7 +69,7 @@ // Called with the driver registry lock held; may be called from any thread. iree_status_t(IREE_API_PTR* try_create)(void* self, iree_hal_driver_id_t driver_id, - iree_allocator_t allocator, + iree_allocator_t host_allocator, iree_hal_driver_t** out_driver); } iree_hal_driver_factory_t; @@ -123,9 +123,9 @@ const iree_hal_driver_factory_t* factory); // Enumerates all drivers from registered factories and returns them as a list. -// The provided |allocator| will be used to allocate the returned list and after -// the caller is done with it |out_driver_infos| must be freed with that same -// allocator by the caller. +// The provided |host_allocator| will be used to allocate the returned list and +// after the caller is done with it |out_driver_infos| must be freed with that +// same allocator by the caller. // // The set of drivers returned should be considered the superset of those that // may be available for successful creation as it's possible that delay-loaded @@ -134,7 +134,7 @@ // Thread-safe. Note that the factory may be unregistered between the query // completing and any attempt to instantiate the driver. IREE_API_EXPORT iree_status_t iree_hal_driver_registry_enumerate( - iree_hal_driver_registry_t* registry, iree_allocator_t allocator, + iree_hal_driver_registry_t* registry, iree_allocator_t host_allocator, iree_hal_driver_info_t** out_driver_infos, iree_host_size_t* out_driver_info_count); @@ -147,7 +147,7 @@ // perform additional loading/verification/etc before returning. IREE_API_EXPORT iree_status_t iree_hal_driver_registry_try_create( iree_hal_driver_registry_t* registry, iree_hal_driver_id_t driver_id, - iree_allocator_t allocator, iree_hal_driver_t** out_driver); + iree_allocator_t host_allocator, iree_hal_driver_t** out_driver); // Attempts to create a driver registered with the given canonical driver name. // Effectively enumerate + find by name + try_create if found. Factories are @@ -159,7 +159,7 @@ // perform additional loading/verification/etc before returning. IREE_API_EXPORT iree_status_t iree_hal_driver_registry_try_create_by_name( iree_hal_driver_registry_t* registry, iree_string_view_t driver_name, - iree_allocator_t allocator, iree_hal_driver_t** out_driver); + iree_allocator_t host_allocator, iree_hal_driver_t** out_driver); #ifdef __cplusplus } // extern "C"
diff --git a/runtime/src/iree/hal/drivers/cuda/dynamic_symbols.c b/runtime/src/iree/hal/drivers/cuda/dynamic_symbols.c index b381b2b..9715a46 100644 --- a/runtime/src/iree/hal/drivers/cuda/dynamic_symbols.c +++ b/runtime/src/iree/hal/drivers/cuda/dynamic_symbols.c
@@ -41,12 +41,14 @@ } iree_status_t iree_hal_cuda_dynamic_symbols_initialize( - iree_allocator_t allocator, iree_hal_cuda_dynamic_symbols_t* out_syms) { + iree_allocator_t host_allocator, + iree_hal_cuda_dynamic_symbols_t* out_syms) { IREE_TRACE_ZONE_BEGIN(z0); memset(out_syms, 0, sizeof(*out_syms)); iree_status_t status = iree_dynamic_library_load_from_files( IREE_ARRAYSIZE(kCUDALoaderSearchNames), kCUDALoaderSearchNames, - IREE_DYNAMIC_LIBRARY_FLAG_NONE, allocator, &out_syms->loader_library); + IREE_DYNAMIC_LIBRARY_FLAG_NONE, host_allocator, + &out_syms->loader_library); if (iree_status_is_not_found(status)) { iree_status_ignore(status); return iree_make_status(
diff --git a/runtime/src/iree/hal/drivers/cuda/dynamic_symbols.h b/runtime/src/iree/hal/drivers/cuda/dynamic_symbols.h index 2ee7c9a..44750f7 100644 --- a/runtime/src/iree/hal/drivers/cuda/dynamic_symbols.h +++ b/runtime/src/iree/hal/drivers/cuda/dynamic_symbols.h
@@ -32,7 +32,7 @@ // iree_hal_cuda_dynamic_symbols_deinitialize must be used to release the // library resources. iree_status_t iree_hal_cuda_dynamic_symbols_initialize( - iree_allocator_t allocator, iree_hal_cuda_dynamic_symbols_t* out_syms); + iree_allocator_t host_allocator, iree_hal_cuda_dynamic_symbols_t* out_syms); // Deinitializes |syms| by unloading the backing library. All function pointers // will be invalidated. They _may_ still work if there are other reasons the
diff --git a/runtime/src/iree/hal/drivers/cuda/registration/driver_module.c b/runtime/src/iree/hal/drivers/cuda/registration/driver_module.c index 5d645d5..27cf2f3 100644 --- a/runtime/src/iree/hal/drivers/cuda/registration/driver_module.c +++ b/runtime/src/iree/hal/drivers/cuda/registration/driver_module.c
@@ -43,7 +43,7 @@ } static iree_status_t iree_hal_cuda_driver_factory_try_create( - void* self, iree_hal_driver_id_t driver_id, iree_allocator_t allocator, + void* self, iree_hal_driver_id_t driver_id, iree_allocator_t host_allocator, iree_hal_driver_t** out_driver) { IREE_ASSERT_ARGUMENT(out_driver); *out_driver = NULL; @@ -69,7 +69,7 @@ iree_string_view_t identifier = iree_make_cstring_view("cuda"); iree_status_t status = iree_hal_cuda_driver_create( - identifier, &default_params, &driver_options, allocator, out_driver); + identifier, &default_params, &driver_options, host_allocator, out_driver); IREE_TRACE_ZONE_END(z0); return status; }
diff --git a/runtime/src/iree/hal/drivers/local_sync/sync_driver.c b/runtime/src/iree/hal/drivers/local_sync/sync_driver.c index df31140..f4d23f3 100644 --- a/runtime/src/iree/hal/drivers/local_sync/sync_driver.c +++ b/runtime/src/iree/hal/drivers/local_sync/sync_driver.c
@@ -96,7 +96,7 @@ } static iree_status_t iree_hal_sync_driver_query_available_devices( - iree_hal_driver_t* base_driver, iree_allocator_t allocator, + iree_hal_driver_t* base_driver, iree_allocator_t host_allocator, iree_hal_device_info_t** out_device_infos, iree_host_size_t* out_device_info_count) { static const iree_hal_device_info_t device_infos[1] = { @@ -107,7 +107,8 @@ }; *out_device_info_count = IREE_ARRAYSIZE(device_infos); return iree_allocator_clone( - allocator, iree_make_const_byte_span(device_infos, sizeof(device_infos)), + host_allocator, + iree_make_const_byte_span(device_infos, sizeof(device_infos)), (void**)out_device_infos); }
diff --git a/runtime/src/iree/hal/drivers/local_task/task_driver.c b/runtime/src/iree/hal/drivers/local_task/task_driver.c index b57f44a..3ff1a87 100644 --- a/runtime/src/iree/hal/drivers/local_task/task_driver.c +++ b/runtime/src/iree/hal/drivers/local_task/task_driver.c
@@ -102,7 +102,7 @@ } static iree_status_t iree_hal_task_driver_query_available_devices( - iree_hal_driver_t* base_driver, iree_allocator_t allocator, + iree_hal_driver_t* base_driver, iree_allocator_t host_allocator, iree_hal_device_info_t** out_device_infos, iree_host_size_t* out_device_info_count) { static const iree_hal_device_info_t device_infos[1] = { @@ -113,7 +113,8 @@ }; *out_device_info_count = IREE_ARRAYSIZE(device_infos); return iree_allocator_clone( - allocator, iree_make_const_byte_span(device_infos, sizeof(device_infos)), + host_allocator, + iree_make_const_byte_span(device_infos, sizeof(device_infos)), (void**)out_device_infos); }
diff --git a/runtime/src/iree/hal/drivers/vulkan/registration/driver_module.cc b/runtime/src/iree/hal/drivers/vulkan/registration/driver_module.cc index 52685d7..d280779 100644 --- a/runtime/src/iree/hal/drivers/vulkan/registration/driver_module.cc +++ b/runtime/src/iree/hal/drivers/vulkan/registration/driver_module.cc
@@ -28,7 +28,7 @@ "Enables Vulkan tracing (if IREE tracing is enabled)."); static iree_status_t iree_hal_vulkan_create_driver_with_flags( - iree_string_view_t identifier, iree_allocator_t allocator, + iree_string_view_t identifier, iree_allocator_t host_allocator, iree_hal_driver_t** out_driver) { IREE_TRACE_SCOPE(); @@ -65,10 +65,10 @@ // does not have the expected functions. iree_hal_vulkan_syms_t* syms = NULL; IREE_RETURN_IF_ERROR( - iree_hal_vulkan_syms_create_from_system_loader(allocator, &syms)); + iree_hal_vulkan_syms_create_from_system_loader(host_allocator, &syms)); iree_status_t status = iree_hal_vulkan_driver_create( - identifier, &driver_options, syms, allocator, out_driver); + identifier, &driver_options, syms, host_allocator, out_driver); iree_hal_vulkan_syms_release(syms); return status; @@ -89,7 +89,7 @@ } static iree_status_t iree_hal_vulkan_driver_factory_try_create( - void* self, iree_hal_driver_id_t driver_id, iree_allocator_t allocator, + void* self, iree_hal_driver_id_t driver_id, iree_allocator_t host_allocator, iree_hal_driver_t** out_driver) { if (driver_id != IREE_HAL_VULKAN_1_X_DRIVER_ID) { return iree_make_status(IREE_STATUS_UNAVAILABLE, @@ -102,7 +102,7 @@ // can name them here: iree_string_view_t identifier = iree_make_cstring_view("vulkan"); - return iree_hal_vulkan_create_driver_with_flags(identifier, allocator, + return iree_hal_vulkan_create_driver_with_flags(identifier, host_allocator, out_driver); }
diff --git a/runtime/src/iree/hal/local/elf/platform.h b/runtime/src/iree/hal/local/elf/platform.h index 03af89b..affb922 100644 --- a/runtime/src/iree/hal/local/elf/platform.h +++ b/runtime/src/iree/hal/local/elf/platform.h
@@ -143,12 +143,12 @@ // Implemented by VirtualAlloc+MEM_RESERVE/mmap+PROT_NONE. iree_status_t iree_memory_view_reserve(iree_memory_view_flags_t flags, iree_host_size_t total_length, - iree_allocator_t allocator, + iree_allocator_t host_allocator, void** out_base_address); // Releases a range of virtual address void iree_memory_view_release(void* base_address, iree_host_size_t total_length, - iree_allocator_t allocator); + iree_allocator_t host_allocator); // Commits pages overlapping the byte ranges defined by |byte_ranges|. // Ranges will be adjusted to the page granularity of the view.
diff --git a/runtime/src/iree/hal/local/elf/platform/apple.c b/runtime/src/iree/hal/local/elf/platform/apple.c index c6c8129..65b6544 100644 --- a/runtime/src/iree/hal/local/elf/platform/apple.c +++ b/runtime/src/iree/hal/local/elf/platform/apple.c
@@ -80,7 +80,7 @@ iree_status_t iree_memory_view_reserve(iree_memory_view_flags_t flags, iree_host_size_t total_length, - iree_allocator_t allocator, + iree_allocator_t host_allocator, void** out_base_address) { *out_base_address = NULL; IREE_TRACE_ZONE_BEGIN(z0); @@ -107,7 +107,7 @@ } void iree_memory_view_release(void* base_address, iree_host_size_t total_length, - iree_allocator_t allocator) { + iree_allocator_t host_allocator) { IREE_TRACE_ZONE_BEGIN(z0); // NOTE: return value ignored as this is a shutdown path.
diff --git a/runtime/src/iree/hal/local/elf/platform/generic.c b/runtime/src/iree/hal/local/elf/platform/generic.c index 0f68592..776fbda 100644 --- a/runtime/src/iree/hal/local/elf/platform/generic.c +++ b/runtime/src/iree/hal/local/elf/platform/generic.c
@@ -41,20 +41,20 @@ iree_status_t iree_memory_view_reserve(iree_memory_view_flags_t flags, iree_host_size_t total_length, - iree_allocator_t allocator, + iree_allocator_t host_allocator, void** out_base_address) { *out_base_address = NULL; IREE_TRACE_ZONE_BEGIN(z0); iree_status_t status = - iree_allocator_malloc(allocator, total_length, out_base_address); + iree_allocator_malloc(host_allocator, total_length, out_base_address); IREE_TRACE_ZONE_END(z0); return status; } void iree_memory_view_release(void* base_address, iree_host_size_t total_length, - iree_allocator_t allocator) { + iree_allocator_t host_allocator) { IREE_TRACE_ZONE_BEGIN(z0); - iree_allocator_free(allocator, base_address); + iree_allocator_free(host_allocator, base_address); IREE_TRACE_ZONE_END(z0); }
diff --git a/runtime/src/iree/hal/local/elf/platform/linux.c b/runtime/src/iree/hal/local/elf/platform/linux.c index 4dfc1ff..900f19a 100644 --- a/runtime/src/iree/hal/local/elf/platform/linux.c +++ b/runtime/src/iree/hal/local/elf/platform/linux.c
@@ -55,7 +55,7 @@ iree_status_t iree_memory_view_reserve(iree_memory_view_flags_t flags, iree_host_size_t total_length, - iree_allocator_t allocator, + iree_allocator_t host_allocator, void** out_base_address) { *out_base_address = NULL; IREE_TRACE_ZONE_BEGIN(z0); @@ -76,7 +76,7 @@ } void iree_memory_view_release(void* base_address, iree_host_size_t total_length, - iree_allocator_t allocator) { + iree_allocator_t host_allocator) { IREE_TRACE_ZONE_BEGIN(z0); // NOTE: return value ignored as this is a shutdown path.
diff --git a/runtime/src/iree/hal/local/elf/platform/windows.c b/runtime/src/iree/hal/local/elf/platform/windows.c index 7d3b313..1bf079b 100644 --- a/runtime/src/iree/hal/local/elf/platform/windows.c +++ b/runtime/src/iree/hal/local/elf/platform/windows.c
@@ -68,7 +68,7 @@ iree_status_t iree_memory_view_reserve(iree_memory_view_flags_t flags, iree_host_size_t total_length, - iree_allocator_t allocator, + iree_allocator_t host_allocator, void** out_base_address) { *out_base_address = NULL; IREE_TRACE_ZONE_BEGIN(z0); @@ -88,7 +88,7 @@ } void iree_memory_view_release(void* base_address, iree_host_size_t total_length, - iree_allocator_t allocator) { + iree_allocator_t host_allocator) { IREE_TRACE_ZONE_BEGIN(z0); // NOTE: return value ignored as this is a shutdown path. VirtualFree(base_address, 0, MEM_RELEASE);