[Mesa-dev] [PATCH] clover: Properly align local pointers passed as kernel args
Tom Stellard
thomas.stellard at amd.com
Tue Mar 31 18:18:53 PDT 2015
---
src/gallium/state_trackers/clover/core/kernel.cpp | 1 +
src/gallium/state_trackers/clover/core/module.hpp | 9 +++++----
src/gallium/state_trackers/clover/llvm/invocation.cpp | 6 +++++-
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp
index 606e4e9..32274dd 100644
--- a/src/gallium/state_trackers/clover/core/kernel.cpp
+++ b/src/gallium/state_trackers/clover/core/kernel.cpp
@@ -421,6 +421,7 @@ kernel::local_argument::set(size_t size, const void *value) {
void
kernel::local_argument::bind(exec_context &ctx,
const module::argument &marg) {
+ ctx.mem_local = util_align_npot(ctx.mem_local, marg.value_align);
auto v = bytes(ctx.mem_local);
extend(v, module::argument::zero_ext, marg.target_size);
diff --git a/src/gallium/state_trackers/clover/core/module.hpp b/src/gallium/state_trackers/clover/core/module.hpp
index c0bc320..5840891 100644
--- a/src/gallium/state_trackers/clover/core/module.hpp
+++ b/src/gallium/state_trackers/clover/core/module.hpp
@@ -77,24 +77,25 @@ namespace clover {
argument(enum type type, size_t size,
size_t target_size, size_t target_align,
enum ext_type ext_type,
- enum semantic semantic = general) :
+ enum semantic semantic = general, size_t value_align = 1) :
type(type), size(size),
target_size(target_size), target_align(target_align),
- ext_type(ext_type), semantic(semantic) { }
+ value_align(value_align), ext_type(ext_type), semantic(semantic) { }
argument(enum type type, size_t size) :
type(type), size(size),
- target_size(size), target_align(1),
+ target_size(size), target_align(1), value_align(1),
ext_type(zero_ext), semantic(general) { }
argument() : type(scalar), size(0),
- target_size(0), target_align(1),
+ target_size(0), target_align(1), value_align(1),
ext_type(zero_ext), semantic(general) { }
type type;
size_t size;
size_t target_size;
size_t target_align;
+ size_t value_align;
ext_type ext_type;
semantic semantic;
};
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 70ef526..1158440 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -433,10 +433,14 @@ namespace {
unsigned address_space = llvm::cast<llvm::PointerType>(arg_type)->getAddressSpace();
if (address_space == address_spaces[clang::LangAS::opencl_local
- clang::LangAS::Offset]) {
+ llvm::Type *pointee_type = arg_type->getPointerElementType();
+ size_t value_align = TD.getABITypeAlignment(pointee_type);
args.push_back(module::argument(module::argument::local,
arg_api_size, target_size,
target_align,
- module::argument::zero_ext));
+ module::argument::zero_ext,
+ module::argument::general,
+ value_align));
} else {
// XXX: Correctly handle constant address space. There is no
// way for r600g to pass a handle for constant buffers back
--
2.0.4
More information about the mesa-dev
mailing list