Skip to content

Commit

Permalink
[HIP] Adds support for creating devices (iree-org#15887)
Browse files Browse the repository at this point in the history
Progress towards iree-org#15790
  • Loading branch information
nithinsubbiah authored and ramiro050 committed Dec 19, 2023
1 parent bdb3a49 commit 00bedf3
Show file tree
Hide file tree
Showing 7 changed files with 623 additions and 6 deletions.
5 changes: 5 additions & 0 deletions experimental/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ iree_cc_library(
"hip_allocator.h"
"hip_buffer.c"
"hip_buffer.h"
"hip_device.c"
"hip_device.h"
"hip_driver.c"
"memory_pools.c"
"memory_pools.h"
Expand All @@ -38,7 +40,10 @@ iree_cc_library(
::dynamic_symbols
iree::base
iree::base::core_headers
iree::base::internal
iree::base::internal::arena
iree::hal
iree::hal::utils::buffer_transfer
COPTS
"-D__HIP_PLATFORM_HCC__=1"
PUBLIC
Expand Down
27 changes: 27 additions & 0 deletions experimental/hip/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@ typedef struct iree_hal_hip_memory_pooling_params_t {
iree_hal_hip_memory_pool_params_t other;
} iree_hal_hip_memory_pooling_params_t;

// Parameters configuring an iree_hal_hip_device_t.
// Must be initialized with iree_hal_hip_device_params_initialize prior to
// use.
typedef struct iree_hal_hip_device_params_t {
// Number of queues exposed on the device.
// Each queue acts as a separate synchronization scope where all work executes
// concurrently unless prohibited by semaphores.
iree_host_size_t queue_count;

// Total size of each block in the device shared block pool.
// Larger sizes will lower overhead and ensure the heap isn't hit for
// transient allocations while also increasing memory consumption.
iree_host_size_t arena_block_size;

// Whether to use async allocations even if reported as available by the
// device. Defaults to true when the device supports it.
bool async_allocations;

// Parameters for each hipMemPool_t used for queue-ordered allocations.
iree_hal_hip_memory_pooling_params_t memory_pools;
} iree_hal_hip_device_params_t;

// Initializes |out_params| to default values.
IREE_API_EXPORT void iree_hal_hip_device_params_initialize(
iree_hal_hip_device_params_t* out_params);

//===----------------------------------------------------------------------===//
// iree_hal_hip_driver_t
//===----------------------------------------------------------------------===//
Expand All @@ -60,6 +86,7 @@ IREE_API_EXPORT void iree_hal_hip_driver_options_initialize(
// |out_driver| must be released by the caller (see iree_hal_driver_release).
IREE_API_EXPORT iree_status_t iree_hal_hip_driver_create(
iree_string_view_t identifier, const iree_hal_hip_driver_options_t* options,
const iree_hal_hip_device_params_t* default_params,
iree_allocator_t host_allocator, iree_hal_driver_t** out_driver);

#ifdef __cplusplus
Expand Down
2 changes: 2 additions & 0 deletions experimental/hip/dynamic_symbol_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// HIP symbols
//===----------------------------------------------------------------------===//

IREE_HIP_PFN_DECL(hipCtxSetCurrent, hipCtx_t)
IREE_HIP_PFN_DECL(hipDeviceGet, hipDevice_t *, int)
IREE_HIP_PFN_DECL(hipDeviceGetAttribute, int *, hipDeviceAttribute_t, int)
IREE_HIP_PFN_DECL(hipDeviceGetName, char *, int, hipDevice_t)
Expand Down Expand Up @@ -62,6 +63,7 @@ IREE_HIP_PFN_DECL(hipModuleLoadData, hipModule_t *, const void *)
IREE_HIP_PFN_DECL(hipModuleLoadDataEx, hipModule_t *, const void *,
unsigned int, hipJitOption *, void **)
IREE_HIP_PFN_DECL(hipModuleUnload, hipModule_t)
IREE_HIP_PFN_DECL(hipSetDevice, int)
IREE_HIP_PFN_DECL(hipStreamCreateWithFlags, hipStream_t *, unsigned int)
IREE_HIP_PFN_DECL(hipStreamDestroy, hipStream_t)
IREE_HIP_PFN_DECL(hipStreamSynchronize, hipStream_t)
Expand Down
Loading

0 comments on commit 00bedf3

Please sign in to comment.