-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: main
Are you sure you want to change the base?
Conversation
Keep main function in your C code. Keep just the bare minimum matmul code in c-lisp. |
Can you write code in C to measure flops for our kernel as well? |
@@ -0,0 +1,24 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return bool
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use assert: https://www.javatpoint.com/assert-in-c-programming
I am facing difficulties with makefile (3e60c5b) . Finding it hard to understand documentation. Will come back to this later |
|
||
except KeyboardInterrupt: | ||
print("\nBenchmarking interupted") | ||
os.system(f"rm {output_csv}") |
There was a problem hiding this comment.
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
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? |
Better write python/bash/make |
Should fix MMult_4x4_4 and MMult_4x4_5 |
Implements the runtime C file that has functions to :
A .sexp file with the kernel implementation (incomplete)
A bash script to run the .sexp file