Skip to content

Commit 9f166eb

Browse files
committed
fix for x86 platform of cross numa opt
1 parent 881c060 commit 9f166eb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ggml/src/ggml-cpu/amx/amx.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#include <cstring>
1717
#include <memory>
1818

19+
#ifdef GGML_USE_NUMA_MIGRATE
20+
#include <numa.h>
21+
#endif
22+
1923
#if defined(__AMX_INT8__) && defined(__AVX512VNNI__)
2024

2125
// AMX type_trais
@@ -43,7 +47,11 @@ static ggml::cpu::tensor_traits * get_tensor_traits(ggml_backend_buffer_t, struc
4347

4448
// AMX buffer interface
4549
static void ggml_backend_amx_buffer_free_buffer(ggml_backend_buffer_t buffer) {
50+
#ifdef GGML_USE_NUMA_MIGRATE
51+
numa_free(buffer->context, buffer->size);
52+
#else
4653
free(buffer->context);
54+
#endif
4755
}
4856

4957
static void * ggml_backend_amx_buffer_get_base(ggml_backend_buffer_t buffer) {
@@ -123,7 +131,11 @@ static const char * ggml_backend_amx_buffer_type_get_name(ggml_backend_buffer_ty
123131
}
124132

125133
static ggml_backend_buffer_t ggml_backend_amx_buffer_type_alloc_buffer(ggml_backend_buffer_type_t buft, size_t size) {
134+
#ifdef GGML_USE_NUMA_MIGRATE
135+
void * data = numa_alloc_onnode(size, 0);
136+
#else
126137
void * data = ggml_aligned_malloc(size);
138+
#endif
127139
if (data == NULL) {
128140
fprintf(stderr, "%s: failed to allocate buffer of size %zu\n", __func__, size);
129141
return NULL;

0 commit comments

Comments
 (0)