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

Kernels in C-lisp #70

Open
wants to merge 69 commits into
base: main
Choose a base branch
from

Conversation

BiradarSiddhant02
Copy link

Implements the runtime C file that has functions to :

  1. generate matrices
  2. multiply matrices for reference
  3. compare matrices
  4. print matrices

A .sexp file with the kernel implementation (incomplete)

A bash script to run the .sexp file

@chsasank
Copy link
Owner

Keep main function in your C code. Keep just the bare minimum matmul code in c-lisp.

@chsasank
Copy link
Owner

Can you write code in C to measure flops for our kernel as well?

@@ -0,0 +1,24 @@
#!/bin/bash
Copy link
Owner

Choose a reason for hiding this comment

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

consider writing a make file?

Copy link
Owner

Choose a reason for hiding this comment

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

also set up turnt infra

int compare_matrix(float* res, float* ref, int rows, int cols) {
for (int j = 0; j < cols; j++) {
for (int i = 0; i < rows; i++) {
if (res[j * rows + i] != ref[j * rows + i]) {
Copy link
Owner

Choose a reason for hiding this comment

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

add a small error term. look up np.allclose implementation: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html

create a function all_close

return 1;
}

int compare_matrix(float* res, float* ref, int rows, int cols) {
Copy link
Owner

Choose a reason for hiding this comment

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

return bool

Copy link
Author

Choose a reason for hiding this comment

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

I had initially made it to return bool. But when I print the returned value, it prints 1 or 0, so kept it as int

Copy link
Owner

Choose a reason for hiding this comment

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

but it's better to still return bool for readability

print_matrix(C_kernel, m, n);
print_matrix(C_ref, m, n);

printf("%d\n", compare_matrix(C_kernel, C_ref, m, n));
Copy link
Owner

Choose a reason for hiding this comment

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

just check if this is passed.

Copy link
Author

Choose a reason for hiding this comment

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

I am sorry i didn't understand

Copy link
Owner

Choose a reason for hiding this comment

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

@BiradarSiddhant02
Copy link
Author

I am facing difficulties with makefile (3e60c5b) .

Finding it hard to understand documentation. Will come back to this later

@chsasank chsasank mentioned this pull request Jul 11, 2024
@BiradarSiddhant02 BiradarSiddhant02 changed the title add C code to test kernels Kernels in C-lisp Jul 12, 2024

except KeyboardInterrupt:
print("\nBenchmarking interupted")
os.system(f"rm {output_csv}")
Copy link
Author

Choose a reason for hiding this comment

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

This commit also does not store data or plot when the benchmarking is run for a single time or the process is interupted

@chsasank
Copy link
Owner

Macros look good but I would want a script that run tests for each of the macros and plot perf vs reference

@BiradarSiddhant02
Copy link
Author

Macros look good but I would want a script that run tests for each of the macros and plot perf vs reference

So a turnt.toml file?

@chsasank
Copy link
Owner

Better write python/bash/make

@BiradarSiddhant02
Copy link
Author

Should fix MMult_4x4_4 and MMult_4x4_5

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