[Beignet] [PATCH 2/2] use posix_memalign instead of aligned_alloc to be more compatible
Guo Yejun
yejun.guo at intel.com
Sun Nov 9 23:35:35 PST 2014
At some systems, function aligned_alloc is not supported.
>From Linux Programmer's Manual:
The function aligned_alloc() was added to glibc in version 2.16.
The function posix_memalign() is available since glibc 2.1.91.
Signed-off-by: Guo Yejun <yejun.guo at intel.com>
---
utests/runtime_use_host_ptr_buffer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/utests/runtime_use_host_ptr_buffer.cpp b/utests/runtime_use_host_ptr_buffer.cpp
index ca06f4b..fdf0998 100644
--- a/utests/runtime_use_host_ptr_buffer.cpp
+++ b/utests/runtime_use_host_ptr_buffer.cpp
@@ -6,7 +6,7 @@ static void runtime_use_host_ptr_buffer(void)
// Setup kernel and buffers
OCL_CREATE_KERNEL("runtime_use_host_ptr_buffer");
- buf_data[0] = (uint32_t*) aligned_alloc(4096, sizeof(uint32_t) * n);
+ posix_memalign((void**)&buf_data[0], 4096, sizeof(uint32_t) * n);
for (uint32_t i = 0; i < n; ++i) ((uint32_t*)buf_data[0])[i] = i;
OCL_CREATE_BUFFER(buf[0], CL_MEM_USE_HOST_PTR, n * sizeof(uint32_t), buf_data[0]);
--
2.1.0
More information about the Beignet
mailing list