summaryrefslogtreecommitdiff
path: root/ggml-metal.m
diff options
context:
space:
mode:
Diffstat (limited to 'ggml-metal.m')
-rw-r--r--ggml-metal.m15
1 files changed, 15 insertions, 0 deletions
diff --git a/ggml-metal.m b/ggml-metal.m
index d23fff1d..835c5f29 100644
--- a/ggml-metal.m
+++ b/ggml-metal.m
@@ -237,6 +237,21 @@ void ggml_metal_free(struct ggml_metal_context * ctx) {
free(ctx);
}
+void * ggml_metal_host_malloc(size_t n) {
+ void * data = NULL;
+ const int result = posix_memalign((void **) &data, getpagesize(), n);
+ if (result != 0) {
+ fprintf(stderr, "%s: error: posix_memalign failed\n", __func__);
+ return NULL;
+ }
+
+ return data;
+}
+
+void ggml_metal_host_free(void * data) {
+ free(data);
+}
+
void ggml_metal_set_n_cb(struct ggml_metal_context * ctx, int n_cb) {
ctx->n_cb = n_cb;
}