Skip to content

Commit

Permalink
[cuda] Port over allocator and buffer implementation (#13985)
Browse files Browse the repository at this point in the history
This commit ports over existing CUDA driver allocator and buffer
implementation. The main logic is kept as-is, with one noticeable
changes--context wrapper is dropped and fields in it are directly
put in various API calls. This is to make supporting multiple
device and stream easier later. Other changes are just polishing
on comments and errors.

Progress towards #13245
  • Loading branch information
antiagainst committed Jun 8, 2023
1 parent 0dc5de9 commit 1299742
Show file tree
Hide file tree
Showing 9 changed files with 1,281 additions and 0 deletions.
6 changes: 6 additions & 0 deletions experimental/cuda2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ iree_cc_library(
"api.h"
SRCS
"api.h"
"cuda_allocator.c"
"cuda_allocator.h"
"cuda_buffer.c"
"cuda_buffer.h"
"cuda_driver.c"
"memory_pools.c"
"memory_pools.h"
DEPS
::dynamic_symbols
iree::base
Expand Down
24 changes: 24 additions & 0 deletions experimental/cuda2/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@
extern "C" {
#endif // __cplusplus

//===----------------------------------------------------------------------===//
// iree_hal_cuda_device_t
//===----------------------------------------------------------------------===//

// Parameters defining a CUmemoryPool.
typedef struct iree_hal_cuda2_memory_pool_params_t {
// Minimum number of bytes to keep in the pool when trimming with
// iree_hal_device_trim.
uint64_t minimum_capacity;
// Soft maximum number of bytes to keep in the pool.
// When more than this is allocated the extra will be freed at the next
// device synchronization in order to remain under the threshold.
uint64_t release_threshold;
// TODO: per-device access permissions array.
} iree_hal_cuda2_memory_pool_params_t;

// Parameters for each CUmemoryPool used for queue-ordered allocations.
typedef struct iree_hal_cuda2_memory_pooling_params_t {
// Used exclusively for DEVICE_LOCAL allocations.
iree_hal_cuda2_memory_pool_params_t device_local;
// Used for any host-visible/host-local memory types.
iree_hal_cuda2_memory_pool_params_t other;
} iree_hal_cuda2_memory_pooling_params_t;

//===----------------------------------------------------------------------===//
// iree_hal_cuda2_driver_t
//===----------------------------------------------------------------------===//
Expand Down
Loading

0 comments on commit 1299742

Please sign in to comment.