From e5fe4974bbd57aa1d14e2aa0e8faec80da200aa3 Mon Sep 17 00:00:00 2001 From: Jhen Date: Sat, 2 Sep 2023 11:30:27 +0800 Subject: [PATCH] ggml-alloc : use 4g for MEASURE_MAX_SIZE in 32-bit arm --- ggml-alloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ggml-alloc.c b/ggml-alloc.c index f07a4a217..459f121ca 100644 --- a/ggml-alloc.c +++ b/ggml-alloc.c @@ -284,7 +284,14 @@ struct ggml_allocr * ggml_allocr_new(void * data, size_t size, size_t alignment) // address and size of the buffer when measuring // it needs to be large enough to fit all the tensors, but it cannot overlap with other existing buffers static void * const MEASURE_BASE_ADDR = (void *) 0x1000; +#if defined(__ARM_NEON) && !defined(__aarch64__) +// 32-bit +// TODO: Use for 32-bit x86 as well +static const size_t MEASURE_MAX_SIZE = (1ULL<<32) - 1; // 4 GB +#else +// 64-bit static const size_t MEASURE_MAX_SIZE = 1ULL<<40; // 1 TB +#endif struct ggml_allocr * ggml_allocr_new_measure(size_t alignment) { struct ggml_allocr * alloc = (struct ggml_allocr *)malloc(sizeof(struct ggml_allocr) /* + n_free_blocks * sizeof(struct free_block) */);