[Beignet] [PATCH 1/2] use posix_memalign instead of aligned_alloc to be more compatible

Guo Yejun yejun.guo at intel.com
Sun Nov 9 23:34:57 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>
---
 src/cl_device_id.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/cl_device_id.c b/src/cl_device_id.c
index e3b0c64..6e27925 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -407,7 +407,8 @@ brw_gt3_break:
   cl_buffer_mgr bufmgr = cl_driver_get_bufmgr(dummy);
 
   const size_t sz = 4096;
-  char* host_ptr = (char*)aligned_alloc(4096, sz);
+  void* host_ptr;
+  posix_memalign(&host_ptr, 4096, sz);
   cl_buffer bo = cl_buffer_alloc_userptr(bufmgr, "CL memory object", host_ptr, sz, 0);
   if (bo == NULL)
     ret->host_unified_memory = CL_FALSE;
-- 
2.1.0



More information about the Beignet mailing list