metal : page align the data ptr
ggml-ci
This commit is contained in:
parent
07a1b052e5
commit
ec0859d85d
1 changed files with 8 additions and 0 deletions
|
@ -2656,6 +2656,14 @@ ggml_backend_buffer_t ggml_backend_metal_buffer_from_ptr(void * data, size_t siz
|
||||||
ctx->n_buffers = 0;
|
ctx->n_buffers = 0;
|
||||||
|
|
||||||
const size_t size_page = sysconf(_SC_PAGESIZE);
|
const size_t size_page = sysconf(_SC_PAGESIZE);
|
||||||
|
|
||||||
|
// page-align the data ptr
|
||||||
|
{
|
||||||
|
const uintptr_t offs = (uintptr_t) data % size_page;
|
||||||
|
data = (void *) ((char *) data - offs);
|
||||||
|
size += offs;
|
||||||
|
}
|
||||||
|
|
||||||
size_t size_aligned = size;
|
size_t size_aligned = size;
|
||||||
if ((size_aligned % size_page) != 0) {
|
if ((size_aligned % size_page) != 0) {
|
||||||
size_aligned += (size_page - (size_aligned % size_page));
|
size_aligned += (size_page - (size_aligned % size_page));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue