diff options
author | Guo Yejun <yejun.guo@intel.com> | 2014-11-10 16:02:37 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-11-10 15:23:43 +0800 |
commit | 48e2da81c01b4bc14b2249a9bead8667319c212d (patch) | |
tree | db2fa27178468691226255119b7685acff28a583 /utests/runtime_use_host_ptr_buffer.cpp | |
parent | f2c57a46de4f51fa5d4c8e02cc751fce7ff417c8 (diff) | |
download | beignet-48e2da81c01b4bc14b2249a9bead8667319c212d.tar.gz |
use posix_memalign instead of aligned_alloc to be more compatible
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.
V2: add check for return value of posix_memalign
Signed-off-by: Guo Yejun <yejun.guo@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'utests/runtime_use_host_ptr_buffer.cpp')
-rw-r--r-- | utests/runtime_use_host_ptr_buffer.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/utests/runtime_use_host_ptr_buffer.cpp b/utests/runtime_use_host_ptr_buffer.cpp index ca06f4be..4603f90d 100644 --- a/utests/runtime_use_host_ptr_buffer.cpp +++ b/utests/runtime_use_host_ptr_buffer.cpp @@ -6,7 +6,10 @@ 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); + + int ret = posix_memalign(&buf_data[0], 4096, sizeof(uint32_t) * n); + OCL_ASSERT(ret == 0); + 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]); |