This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Make sure that the size of module (or kernel) lds struct is multiple of its alignment.
AbandonedPublic

Authored by hsmhsm on Jun 10 2021, 5:26 AM.

Details

Summary

When we create module (or per kernel) lds struct, we fix its alignment as the largest of struct
members. Add padding at the end of the struct so that the size of struct is multiple of its alignment.

Diff Detail

Event Timeline

hsmhsm created this revision.Jun 10 2021, 5:26 AM
hsmhsm requested review of this revision.Jun 10 2021, 5:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2021, 5:26 AM
foad added a comment.Jun 10 2021, 6:01 AM

When we create module (or per kernel) lds struct, we fix its alignment as the largest of struct
members. Add padding at the end of the struct so that the size of struct is multiple of its alignment.

Why?

When we create module (or per kernel) lds struct, we fix its alignment as the largest of struct
members. Add padding at the end of the struct so that the size of struct is multiple of its alignment.

Why?

Actually, in general scenario it is needed - imagine that we create an array of struct, if we don't do it, then array elements starting from index may not aligned.

But here it is special case. We don't create array of these structs. Hence it is not required here. I will abondon the patch.

hsmhsm abandoned this revision.Jun 10 2021, 7:39 PM

module (and kernel) lds struct is a special case, where we do not need padding at the end of struct, I realized it later. Hence, this patch does not make sense, abandoning it.