char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
f470bc36b
char/aliceai-t5-moe
1#ifdef GGML_USE_CPU_HBM 2 3#include "ggml-backend.h" 4#include "ggml-backend-impl.h" 5#include "ggml-cpu.h" 6#include "ggml-impl.h" 7 8#include "hbm.h" 9 10// buffer type HBM 11 12#include <hbwmalloc.h> 13 14static const char * ggml_backend_cpu_hbm_buffer_type_get_name (ggml_backend_buffer_type_t buft ) { 15return "CPU_HBM" ; 16 17GGML_UNUSED (buft ); 18} 19 20static void ggml_backend_cpu_hbm_buffer_free_buffer (ggml_backend_buffer_t buffer ) { 21hbw_free (buffer -> context ); 22} 23 24static ggml_backend_buffer_t ggml_backend_cpu_hbm_buffer_type_alloc_buffer (ggml_backend_buffer_type_t buft , 25size_t size ) { 26void * ptr ; 27int result = hbw_posix_memalign (& ptr ,ggml_backend_cpu_buffer_type_get_alignment (buft ),size ); 28if (result != 0 ) { 29GGML_LOG_ERROR ("failed to allocate HBM buffer of size %zu\n" ,size ); 30return NULL ; 31 } 32 33ggml_backend_buffer_t buffer = ggml_backend_cpu_buffer_from_ptr (ptr ,size ); 34buffer -> buft = buft ; 35buffer -> iface .free_buffer = ggml_backend_cpu_hbm_buffer_free_buffer ; 36 37return buffer ; 38} 39 40ggml_backend_buffer_type_t ggml_backend_cpu_hbm_buffer_type (void ) { 41static struct ggml_backend_buffer_type ggml_backend_cpu_buffer_type_hbm = { 42/* .iface = */ { 43/* .get_name = */ ggml_backend_cpu_hbm_buffer_type_get_name , 44/* .alloc_buffer = */ ggml_backend_cpu_hbm_buffer_type_alloc_buffer , 45/* .get_alignment = */ ggml_backend_cpu_buffer_type_get_alignment , 46/* .get_max_size = */ nullptr ,// defaults to SIZE_MAX 47/* .get_alloc_size = */ nullptr ,// defaults to ggml_nbytes 48/* .is_host = */ ggml_backend_cpu_buffer_type_is_host , 49 }, 50/* .context = */ nullptr , 51 }; 52 53return & ggml_backend_cpu_buffer_type_hbm ; 54} 55#endif