aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGil Pitney <gil.pitney@linaro.org>2014-12-08 18:54:30 -0800
committerGil Pitney <gil.pitney@linaro.org>2014-12-08 18:54:30 -0800
commited97e4c7397909c156c2b7d116f4540880153d29 (patch)
treed1b188536d91ec9126c46b5cb7f9aa4d863b681d
parent9ec15177ee308a2f730d9dbb030352c7ad7fc227 (diff)
Ensure kernel arguments to local address space allocated on 128 byte boundary
Buffers in local space, passed as kernel parameters, are allocated at runtime by shamrock. This patch ensures such allocated memory is aligned for maximum OpenCL data type alignment (double16). Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
-rw-r--r--src/core/cpu/kernel.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/core/cpu/kernel.cpp b/src/core/cpu/kernel.cpp
index 49e4dcc..b89aafa 100644
--- a/src/core/cpu/kernel.cpp
+++ b/src/core/cpu/kernel.cpp
@@ -588,17 +588,19 @@ void *CPUKernelWorkGroup::callArgs(std::vector<void *> &locals_to_free)
{
case Kernel::Arg::Buffer:
{
- MemObject *buffer = *(MemObject **)arg->data();
-
if (arg->file() == Kernel::Arg::Local)
{
// Alloc a buffer and pass it to the kernel
- void *local_buffer = std::malloc(arg->allocAtKernelRuntime());
+ // align for type double16 size.
+ void *local_buffer = NULL;
+ int retval = posix_memalign(&local_buffer, 128, arg->allocAtKernelRuntime());
locals_to_free.push_back(local_buffer);
*(void **)target = local_buffer;
}
else
{
+ MemObject *buffer = *(MemObject **)arg->data();
+
if (!buffer)
{
// We can do that, just send NULL