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

Patmos simulator fails when calling printf() with multiple cores #18

Open
michael-platzer opened this issue Nov 4, 2021 · 1 comment

Comments

@michael-platzer
Copy link

The Patmos simulator pasim produces an error (unaligned memory access) when the function printf() is called and the number of cores is greater than 1.

To reproduce, write a short Hello World program and execute following commands:

$ cat test.c
#include <stdio.h>
int main() {
    printf("Hello world!\n");
    return 0;
}
$ patmos-clang test.c
$ pasim a.out 
Hello world!
$ pasim -N 2 a.out 
[Error] Unaligned memory access: 00000003

00047280<pthread_mutex_init:.LBB163_2:.LBB163_3 + 0x8>:              lwm r2 = [r1 + 0]

Cycle : 48930, PC : 0004728c<pthread_mutex_init:.LBB163_2:.LBB163_3 + 0x14>
Stacktrace:
#0 0x471e4 <pthread_mutex_init>(): $rsp 0x6c8 stack cache size 0x780
   at 0x4728c (base: 0x47244 <pthread_mutex_init:.LBB163_2:.Ltmp1904 + 0xc>, offset: 0x48 <pthread_mutex_init:.LBB163_2:.LBB163_3 + 0x14>)
t-crest/patmos#1 0x25304 <std>(): $rsp 0x6c8 stack cache size 0x7a0
   at 0x253a0 (base: 0x25304 <.LBB46_0:std>, offset: 0x9c <std + 0x9c>)
t-crest/patmos#2 0x24f34 <__sinit>(): $rsp 0x6c8 stack cache size 0x7e0
   at 0x25014 (base: 0x24fb4 <__sinit:.LBB38_2:.Ltmp260 + 0xc>, offset: 0x60 <__sinit:.LBB38_2:.Ltmp260 + 0x6c>)

No error is produced if printf() is removed from the program:

$ cat test.c
#include <stdio.h>
int main() {
    return 0;
}
$ patmos-clang test.c
$ pasim -N 2 a.out
$ echo $?
0
@Emoun
Copy link
Member

Emoun commented Nov 5, 2021

Since this is an issue with pasim, I'm moving it to the simulator's repo.

@Emoun Emoun transferred this issue from t-crest/patmos Nov 5, 2021
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

No branches or pull requests

2 participants