Skip to content

Avoid the cacheline alignment requirement for batches #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: sycl-develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions include/cute/atom/copy_traits_xe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ struct XE_2D_LD_Unpack {
uint32_t height;
uint32_t pitch;
uint32_t stride_l = 0;
uint32_t height_offset = 0;



Expand Down Expand Up @@ -253,11 +254,15 @@ struct XE_2D_LD_Unpack {
if constexpr (stride_rank == 3) {
stride_l = size<2>(tensor.stride());
}
if(stride_l % pitch != 0){
CUTE_INVALID_CONTROL_PATH("Incompatible strides in tensor.\n");
};
Comment on lines +257 to +259
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

height_offset = stride_l / pitch;
}

XE_2D_LD_Unpack(Traits_LD_t const &traits) : base_ptr(traits.base_ptr),
width(traits.width), height(traits.height), pitch(traits.pitch),
stride_l(traits.stride_l) {}
stride_l(traits.stride_l), height_offset(traits.height_offset){}

XE_2D_LD_Unpack() {}

Expand All @@ -279,11 +284,12 @@ struct XE_2D_LD_Unpack {
auto [m, n, l] = src.data().coord_;
int x = is_need_reversed ? m : n;
int y = is_need_reversed ? n : m;
y += l * traits.height_offset;

constexpr auto inst_size_bits = detail::size_of_inst_bits<CopyOp, dtype>;

CopyOp::copy(base_addr + l * traits.stride_l,
(traits.width * sizeof_bits_v<dtype>) / sizeof_bits_v<int8_t>, traits.height,
CopyOp::copy(base_addr, (traits.width * sizeof_bits_v<dtype>) / sizeof_bits_v<int8_t>,
traits.height + l * traits.height_offset,
(traits.pitch * sizeof_bits_v<dtype>) / sizeof_bits_v<int8_t>,
intel::coord_t{(int)(x * sizeof_bits_v<dtype> / inst_size_bits), y},
raw_pointer_cast(&((&*dst.data())[0])));
Expand All @@ -305,11 +311,12 @@ struct XE_2D_LD_Unpack {

int x = is_need_reversed ? m : n;
int y = is_need_reversed ? n : m;
y += l * atom.height_offset;

constexpr auto inst_size_bits = detail::size_of_inst_bits<CopyOp, dtype>;

CopyOp::PREFETCH::copy(base_addr + l * atom.stride_l,
(atom.width * sizeof_bits_v<dtype>) / sizeof_bits_v<int8_t>, atom.height,
CopyOp::PREFETCH::copy(base_addr, (atom.width * sizeof_bits_v<dtype>) / sizeof_bits_v<int8_t>,
atom.height + l * atom.height_offset,
(atom.pitch * sizeof_bits_v<dtype>) / sizeof_bits_v<int8_t>,
intel::coord_t{(int)(x * sizeof_bits_v<dtype> / inst_size_bits), y});
}
Expand Down Expand Up @@ -339,6 +346,7 @@ template <class CopyOp, class StrideIndicator = cute::Stride<int64_t, cute::Int<
uint32_t height;
uint32_t pitch;
uint32_t stride_l = 0;
uint32_t height_offset = 0;

XE_2D_ST_Unpack(const void *ptr, uint32_t y,
uint32_t x, uint32_t p = 0) : base_ptr(ptr) {
Expand All @@ -357,11 +365,15 @@ template <class CopyOp, class StrideIndicator = cute::Stride<int64_t, cute::Int<
if constexpr (stride_rank == 3) {
stride_l = size<2>(tensor.stride());
}
if(stride_l % pitch != 0){
CUTE_INVALID_CONTROL_PATH("Incompatible strides in tensor.\n");
};
Comment on lines +368 to +370
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know the effect of this changes on the performance?

height_offset = stride_l / pitch;
}

XE_2D_ST_Unpack(Traits_ST_t const &traits) : base_ptr(traits.base_ptr),
width(traits.width), height(traits.height), pitch(traits.pitch),
stride_l(traits.stride_l) {}
stride_l(traits.stride_l), height_offset(traits.height_offset) {}

XE_2D_ST_Unpack() {}

Expand All @@ -383,11 +395,14 @@ template <class CopyOp, class StrideIndicator = cute::Stride<int64_t, cute::Int<
dtype *base_addr = (dtype *)traits.base_ptr;

auto [m, n, l] = dst.data().coord_;
int x = n;
int y = m;
y += l * traits.height_offset;

CopyOp::copy(base_addr + l * traits.stride_l,
traits.width * sizeof(dtype), traits.height,
CopyOp::copy(base_addr, traits.width * sizeof(dtype),
traits.height + l * traits.height_offset,
traits.pitch * sizeof(dtype),
intel::coord_t{(int)n, (int)m}, &*src.data());
intel::coord_t{x, y}, &*src.data());
}

template <class... TensorArgs>
Expand Down
Loading