clover: Local memory needs to be aligned.

Fixes a couple of OpenCL CTS tests.

v3:
* Add a comment in module.hpp explaining that target_align means
  something different for arguments of type local (Francisco Jerez)
* Squash in the fix for the LLVM backend.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Pierre Moreau <dev@pmoreau.org>
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10256>
This commit is contained in:
Karol Herbst
2020-08-16 01:51:49 +02:00
committed by Marge Bot
parent 8061dfef6b
commit 5ffe059fd2
4 changed files with 16 additions and 4 deletions
+2 -1
View File
@@ -523,11 +523,12 @@ 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 = ::align(ctx.mem_local, marg.target_align);
auto v = bytes(ctx.mem_local);
extend(v, module::argument::zero_ext, marg.target_size);
byteswap(v, ctx.q->device().endianness());
align(ctx.input, marg.target_align);
align(ctx.input, ctx.q->device().address_bits() / 8);
insert(ctx.input, v);
ctx.mem_local += _storage;
+3 -1
View File
@@ -125,7 +125,9 @@ namespace clover {
type type;
size_t size;
size_t target_size;
size_t target_align;
size_t target_align; // For arguments of type local, this represents
// the alignment requirement for the pointed
// type and for the pointer itself.
ext_type ext_type;
semantic semantic;
arg_info info;
@@ -213,8 +213,11 @@ namespace {
const auto offset =
static_cast<unsigned>(clang::LangAS::opencl_local);
if (address_space == map[offset]) {
const auto pointee_type = cast<
::llvm::PointerType>(actual_type)->getElementType();
args.emplace_back(module::argument::local, arg_api_size,
target_size, target_align,
target_size,
dl.getABITypeAlignment(pointee_type),
module::argument::zero_ext);
} else {
// XXX: Correctly handle constant address space. There is no
@@ -350,10 +350,16 @@ namespace {
if (opcode == SpvOpTypePointer)
pointer_types[id] = get<SpvId>(inst, 3);
module::size_t alignment;
if (storage_class == SpvStorageClassWorkgroup)
alignment = opcode == SpvOpTypePointer ? types[pointer_types[id]].target_align : 0;
else
alignment = pointer_byte_size;
types[id] = { convert_storage_class(storage_class, err),
sizeof(cl_mem),
static_cast<module::size_t>(pointer_byte_size),
static_cast<module::size_t>(pointer_byte_size),
alignment,
module::argument::zero_ext };
types[id].info.address_qualifier = convert_storage_class_to_cl(storage_class);
break;