diff options
| author | Roy Spliet <[email protected]> | 2019-07-25 18:34:44 +0100 |
|---|---|---|
| committer | Roy Spliet <[email protected]> | 2019-10-17 11:39:02 +0100 |
| commit | 55a05c11b0af3159d81bce823c1fda4fb3cd04e3 (patch) | |
| tree | ceda8b518ff98c3547f52c50056a35bf62ad411d /libopencl | |
| parent | 6cdb7b18f70f8a1da200020f1b72f56fc33864d8 (diff) | |
libopencl: Calculate a valid offset in bind_args()
v2: Adhere to alignment requirements.
v3: Small style fix.
Signed-off-by: Roy Spliet <[email protected]>
Diffstat (limited to 'libopencl')
| -rw-r--r-- | libopencl/opencl_runtime_api.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libopencl/opencl_runtime_api.cc b/libopencl/opencl_runtime_api.cc index 23e52f6..752bfdf 100644 --- a/libopencl/opencl_runtime_api.cc +++ b/libopencl/opencl_runtime_api.cc @@ -263,15 +263,27 @@ void _cl_kernel::SetKernelArg( cl_int _cl_kernel::bind_args( gpgpu_ptx_sim_arg_list_t &arg_list ) { + size_t offset = 0; + assert( arg_list.empty() ); unsigned k=0; std::map<unsigned, arg_info>::iterator i; for( i = m_args.begin(); i!=m_args.end(); i++ ) { if( i->first != k ) return CL_INVALID_KERNEL_ARGS; + arg_info arg = i->second; - gpgpu_ptx_sim_arg param( arg.m_arg_value, arg.m_arg_size, 0); + const symbol *sym = m_kernel_impl->get_arg(i->first); + const type_info_key &t = sym->type()->get_key(); + + int align = (t.get_alignment_spec() == -1) ? arg.m_arg_size : t.get_alignment_spec(); + if( offset % align ) + offset += (align - (offset % align)); + + gpgpu_ptx_sim_arg param( arg.m_arg_value, arg.m_arg_size, offset ); arg_list.push_front( param ); + + offset += arg.m_arg_size; k++; } return CL_SUCCESS; |
