#ifndef UCT_CUDA_IPC_CACHE_H_
#define UCT_CUDA_IPC_CACHE_H_
#include <ucs/datastruct/pgtable.h>
#include <ucs/datastruct/list.h>
#include <ucs/type/init_once.h>
#include <ucs/type/spinlock.h>
#include "cuda_ipc_md.h"
#include <cuda.h>
#include <cuda_runtime.h>
typedef struct uct_cuda_ipc_cache uct_cuda_ipc_cache_t;
typedef struct uct_cuda_ipc_cache_region uct_cuda_ipc_cache_region_t;
typedef struct uct_cuda_ipc_rem_memh uct_cuda_ipc_rem_memh_t;
struct uct_cuda_ipc_cache_region {
ucs_pgt_region_t super;
ucs_list_link_t list;
uct_cuda_ipc_key_t key;
void *mapped_addr;
uint64_t refcount;
};
struct uct_cuda_ipc_cache {
pthread_rwlock_t lock;
ucs_pgtable_t pgtable;
char *name;
};
ucs_status_t uct_cuda_ipc_create_cache(uct_cuda_ipc_cache_t **cache,
const char *name);
void uct_cuda_ipc_destroy_cache(uct_cuda_ipc_cache_t *cache);
ucs_status_t
uct_cuda_ipc_map_memhandle(const uct_cuda_ipc_key_t *key, void **mapped_addr);
ucs_status_t uct_cuda_ipc_unmap_memhandle(pid_t pid, uintptr_t d_bptr,
void *mapped_addr, int cache_enabled);
#endif