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

Xpulp kernel in conv_2d.h has out of bounds memory accesses #47

Open
oakentling opened this issue Jun 22, 2022 · 0 comments
Open

Xpulp kernel in conv_2d.h has out of bounds memory accesses #47

oakentling opened this issue Jun 22, 2022 · 0 comments

Comments

@oakentling
Copy link
Contributor

oakentling commented Jun 22, 2022

The kernel conv2d_3x3_unrolled2_i8_xpulpv2 from software/runtime/xpulp/conv_2d.h used in the application software/apps/onv2d_i8/main.c will result in out of bounds memory accesses. This was discovered by running the benchmark in the hardware folder with snitch_tracing enabled. The trace will contain X values which hardware/scripts/gen_trace.py cannot handle at the moment.

Steps to reproduce problem:

  1. In hardware/Makefile set snitch_trace?=1 (l. 49) and change l. 271 to benchmark: log simcvcs.

  2. In software/runtime/crt0.S replace l.88-89 with wfi. (This step might be optional)

  3. In the software folder, run make apps xpulpimg=1 config=mempool.

  4. If necessary, do unset CC && unset CXX. In the hardware folder, run make benchmark config=mempool xpulpimg=1 app=conv2d_i8.
    --> this will result in hardware/scripts/gen_trace.py failing
    TRACE:
    python3 /scratch/bsc22f8/git/oswaldlo1/mempool/hardware/scripts/gen_trace.py -p --csv build/traces/results.csv build/traces/trace_hart_0x0000 > build/trace_hart_0x0000.trace
    Traceback (most recent call last):
    File "/scratch/bsc22f8/git/oswaldlo1/mempool/hardware/scripts/gen_trace.py", line 910, in <module> sys.exit(main()
    File "/scratch/bsc22f8/git/oswaldlo1/mempool/hardware/scripts/gen_trace.py", line 828, in main args.permissive)
    File "/scratch/bsc22f8/git/oswaldlo1/mempool/hardware/scripts/gen_trace.py", line 541, in annotate_insn permissive)
    File "/scratch/bsc22f8/git/oswaldlo1/mempool/hardware/scripts/gen_trace.py", line 374, in annotate_snitch int_lit(extras['ld_result_32'])))
    KeyError: 'ld_result_32'
    make[1]: *** [build/trace_hart_0x0000.trace] Error 1

  5. When looking at the end of the file hardware/build/trace_hart_0x0000.trace it is clear that the last few instructions try to load values from an out of bound address 0x0040400. The address is defined in software/bin/conv2d_i8.dump as <out>.

  6. Further when looking in hardware/build/trace_hart_0x0000.dasm and searching for the number in the first column of trace_hart_0x0000.trace where the problem occurs, one can find values which contain X's. These are the reason why gen_trace.py fails.

@SamuelRiedel

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

1 participant