summaryrefslogtreecommitdiff
path: root/ggml.c
diff options
context:
space:
mode:
Diffstat (limited to 'ggml.c')
-rw-r--r--ggml.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ggml.c b/ggml.c
index 24f0d2fa..4e3e7edb 100644
--- a/ggml.c
+++ b/ggml.c
@@ -22,6 +22,10 @@
#include <float.h>
#include <limits.h>
+#ifdef GGML_USE_METAL
+#include <unistd.h>
+#endif
+
// if C99 - static_assert is noop
// ref: https://stackoverflow.com/a/53923785/4039976
#ifndef static_assert
@@ -122,7 +126,11 @@ typedef void* thread_ret_t;
#else
inline static void* ggml_aligned_malloc(size_t size) {
void* aligned_memory = NULL;
+#ifdef GGML_USE_METAL
+ int result = posix_memalign(&aligned_memory, getpagesize(), size);
+#else
int result = posix_memalign(&aligned_memory, GGML_MEM_ALIGN, size);
+#endif
if (result != 0) {
// Handle allocation failure
return NULL;