"docker/vscode:/vscode.git/clone" did not exist on "849877159ac0c6cc6397decc31e2b1073d765950"
ggml-cuda.h 1.55 KB
Newer Older
xuxzh1's avatar
init  
xuxzh1 committed
1
2
3
4
5
#pragma once

#include "ggml.h"
#include "ggml-backend.h"

xuxzh1's avatar
update  
xuxzh1 committed
6
7
8
9
10
#ifdef  __cplusplus
extern "C" {
#endif

#ifdef GGML_USE_HIP
xuxzh1's avatar
init  
xuxzh1 committed
11
12
13
14
15
16
17
18
19
20
21
22
#define GGML_CUDA_NAME "ROCm"
#define GGML_CUBLAS_NAME "hipBLAS"
#elif defined(GGML_USE_MUSA)
#define GGML_CUDA_NAME "MUSA"
#define GGML_CUBLAS_NAME "muBLAS"
#else
#define GGML_CUDA_NAME "CUDA"
#define GGML_CUBLAS_NAME "cuBLAS"
#endif
#define GGML_CUDA_MAX_DEVICES       16

// backend API
xuxzh1's avatar
update  
xuxzh1 committed
23
GGML_BACKEND_API ggml_backend_t ggml_backend_cuda_init(int device);
xuxzh1's avatar
init  
xuxzh1 committed
24

xuxzh1's avatar
update  
xuxzh1 committed
25
GGML_BACKEND_API bool ggml_backend_is_cuda(ggml_backend_t backend);
xuxzh1's avatar
init  
xuxzh1 committed
26
27

// device buffer
xuxzh1's avatar
update  
xuxzh1 committed
28
GGML_BACKEND_API ggml_backend_buffer_type_t ggml_backend_cuda_buffer_type(int device);
xuxzh1's avatar
init  
xuxzh1 committed
29
30

// split tensor buffer that splits matrices by rows across multiple devices
xuxzh1's avatar
update  
xuxzh1 committed
31
GGML_BACKEND_API ggml_backend_buffer_type_t ggml_backend_cuda_split_buffer_type(int main_device, const float * tensor_split);
xuxzh1's avatar
init  
xuxzh1 committed
32
33

// pinned host buffer for use with the CPU backend for faster copies between CPU and GPU
xuxzh1's avatar
update  
xuxzh1 committed
34
35
36
37
38
GGML_BACKEND_API ggml_backend_buffer_type_t ggml_backend_cuda_host_buffer_type(void);

GGML_BACKEND_API int  ggml_backend_cuda_get_device_count(void);
GGML_BACKEND_API void ggml_backend_cuda_get_device_description(int device, char * description, size_t description_size);
GGML_BACKEND_API void ggml_backend_cuda_get_device_memory(int device, size_t * free, size_t * total);
xuxzh1's avatar
init  
xuxzh1 committed
39

xuxzh1's avatar
update  
xuxzh1 committed
40
41
GGML_BACKEND_API bool ggml_backend_cuda_register_host_buffer(void * buffer, size_t size);
GGML_BACKEND_API void ggml_backend_cuda_unregister_host_buffer(void * buffer);
xuxzh1's avatar
init  
xuxzh1 committed
42

xuxzh1's avatar
update  
xuxzh1 committed
43
GGML_BACKEND_API ggml_backend_reg_t ggml_backend_cuda_reg(void);
xuxzh1's avatar
init  
xuxzh1 committed
44
45
46
47

#ifdef  __cplusplus
}
#endif