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

Segfault happens with examples/main.c #678

Closed
gigony opened this issue Jul 16, 2024 · 1 comment · Fixed by #679
Closed

Segfault happens with examples/main.c #678

gigony opened this issue Jul 16, 2024 · 1 comment · Fixed by #679

Comments

@gigony
Copy link

gigony commented Jul 16, 2024

Hi @yamaguchi1024,

While trying to execute the example code, I found that there is a regression due to the following PR:

The order of the parameters has changed from C, A, B (by your original code) to A, C, B (by PR 468), but the main.c file wasn't updated.

@proc
def rank_k_reduce_6x16(
    K: size,
    A: f32[6, K] @ DRAM,
    C: f32[6, 16] @ DRAM,
    B: f32[K, 16] @ DRAM,
):

I think the following change is needed:

diff --git a/examples/main.c b/examples/main.c
index 5051c42..fbbed91 100644
--- a/examples/main.c
+++ b/examples/main.c
@@ -34,7 +34,7 @@ int main() {
   // Calling original matmul
   start = clock();
   for (int i = 0; i < 1000; i++)
-    rank_k_reduce_6x16(NULL, K, C, A, B);
+    rank_k_reduce_6x16(NULL, K, A, C, B);
   end = clock();
 
   msec = (end - start) * 1000 / CLOCKS_PER_SEC;
@@ -44,7 +44,7 @@ int main() {
   // Calling scheduled matmul
   start = clock();
   for (int i = 0; i < 1000; i++)
-    rank_k_reduce_6x16_scheduled(NULL, K, C, A, B);
+    rank_k_reduce_6x16_scheduled(NULL, K, A, C, B);
   end = clock();
 
   msec = (end - start) * 1000 / CLOCKS_PER_SEC;

How to reproduce:

cd examples
exocc -o . --stem avx2_matmul x86_matmul.py
gcc -o avx2_matmul -march=native main.c avx2_matmul.c
./avx2_matmul
# [1]    3897329 segmentation fault (core dumped)  ./avx2_matmul

After fixing the issue locally, I can run it:

❯ ./avx2_matmul
Time taken for original matmul: 0 seconds 291 milliseconds
Time taken for scheduled matmul: 0 seconds 47 milliseconds

Thanks!

@yamaguchi1024
Copy link
Member

Hi @gigony, thanks for trying out Exo and thanks for creating an issue!! I will fix this issue but feel free to open a PR as well

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 a pull request may close this issue.

2 participants