Skip to content
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

MatMul single core optimized kernels #1993

Merged
merged 11 commits into from
Dec 19, 2024
Merged

MatMul single core optimized kernels #1993

merged 11 commits into from
Dec 19, 2024

Conversation

endtaka-amd
Copy link
Collaborator

This PR merges changes in the mm.c (optimized single AIE MatMul kernels) along with associated changes in Makefiles. Also, trace.py file has been modified to allow capturing further events (not only the default ones).

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

clang-format

[clang-format] reported by reviewdog 🐶

constexpr int t = 4;
// Since the kernel has been expanded twice for both A ('m' dimension) and B ('n' dimension),
// the following assertions veirify this even division for the single AIE MatMul dimensionality.
// Notice that 'k' dimension is not spatially expanded.
static_assert(m % (2*r) == 0); // 'm' dimension


[clang-format] reported by reviewdog 🐶

static_assert(n % (2*t) == 0); // 'n' dimension


[clang-format] reported by reviewdog 🐶


[clang-format] reported by reviewdog 🐶

int32 *__restrict pC) {


[clang-format] reported by reviewdog 🐶

constexpr int s = 4;
constexpr int t = 4;
// Since the kernel has been expanded twice for both A ('m' dimension) and B ('n' dimension),
// the following assertions veirify this even division for the single AIE MatMul dimensionality
// Notice that 'k' dimension is not spatially expanded.
static_assert(m % (2*r) == 0); // 'm' dimension
static_assert(k % s == 0); // 'k' dimension
static_assert(n % (2*t) == 0); // 'n' dimension


[clang-format] reported by reviewdog 🐶


[clang-format] reported by reviewdog 🐶

bfloat16 *__restrict pC) {


[clang-format] reported by reviewdog 🐶

constexpr int t = 4;
// Since the kernel has been expanded 4 times for both A ('m' dimension) and B ('n' dimension),
// the following assertions veirify this even division for the single AIE MatMul dimensionality
// Notice that 'k' dimension is not spatially expanded.
static_assert(m % (4*r) == 0); // 'm' dimension


[clang-format] reported by reviewdog 🐶

static_assert(n % (4*t) == 0); // 'n' dimension


[clang-format] reported by reviewdog 🐶

float *__restrict pC) {


[clang-format] reported by reviewdog 🐶

constexpr int s = 8;
constexpr int t = 4;
// Since the kernel has been expanded 4 times for both A ('m' dimension) and B ('n' dimension),
// the following assertions veirify this even division for the single AIE MatMul dimensionality
// Notice that 'k' dimension is not spatially expanded.
static_assert(m % (4*r) == 0); // 'm' dimension
static_assert(k % s == 0); // 'k' dimension
static_assert(n % (4*t) == 0); // 'n' dimension


[clang-format] reported by reviewdog 🐶


[clang-format] reported by reviewdog 🐶

int8 *__restrict pC) {


[clang-format] reported by reviewdog 🐶

constexpr int s = 8;
constexpr int t = 8;
// Since the kernel has been expanded 4 times for A ('m' dimension) and 2 times for B ('n' dimension),
// the following assertions veirify this even division for the single AIE MatMul dimensionality
// Notice that 'k' dimension is not spatially expanded.
static_assert(m % (4*r) == 0); // 'm' dimension
static_assert(k % s == 0); // 'k' dimension
static_assert(n % (2*t) == 0); // 'n' dimension


[clang-format] reported by reviewdog 🐶


[clang-format] reported by reviewdog 🐶

int16 *__restrict pC) {


[clang-format] reported by reviewdog 🐶

constexpr int t = 8;
// Since the kernel has been expanded 4 times for A ('m' dimension) and 2 times for B ('n' dimension),
// the following assertions veirify this even division for the single AIE MatMul dimensionality
// Notice that 'k' dimension is not spatially expanded.
static_assert(m % (4*r) == 0); // 'm' dimension


[clang-format] reported by reviewdog 🐶

static_assert(n % (2*t) == 0); // 'n' dimension


[clang-format] reported by reviewdog 🐶


[clang-format] reported by reviewdog 🐶

int32 *__restrict pC) {


[clang-format] reported by reviewdog 🐶

constexpr int t = 8;
// Since the kernel has been expanded twice for both A ('m' dimension) and B ('n' dimension),
// the following assertions veirify this even division for the single AIE MatMul dimensionality
// Notice that 'k' dimension is not spatially expanded.
static_assert(m % (4*r) == 0); // 'm' dimension


[clang-format] reported by reviewdog 🐶

static_assert(n % (2*t) == 0); // 'n' dimension


[clang-format] reported by reviewdog 🐶

endtaka-amd and others added 2 commits December 18, 2024 10:18
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines -36 to -39
# defaults; overwrite if needed
M?=512
K?=512
N?=512
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean to delete these defaults?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I found them confusing, because we already have the sizes in the separate makefiles. But we can keep them if you think they help!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fine to remove

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me put some comments on the Makefiles for the GEMM sizes.

@jgmelber jgmelber self-requested a review December 18, 2024 17:37
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@Xilinx Xilinx deleted a comment from github-actions bot Dec 18, 2024
@endtaka-amd endtaka-amd added this pull request to the merge queue Dec 19, 2024
Merged via the queue into main with commit 6c48e43 Dec 19, 2024
53 checks passed
@endtaka-amd endtaka-amd deleted the matmul_experimentation branch December 19, 2024 22:11
@endtaka-amd endtaka-amd restored the matmul_experimentation branch January 14, 2025 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants