x86simulator requires VALGRIND_HOME, VALGRIND_LIB, and PATH environmental variables configured for your host computer configuration. Exit the Vitis IDE, and set the following environmental variables, and relaunch the Vitis IDE. For example:
export PATH=<Install_Path>/valgrind/3.16.1/:$PATH
export VALGRIND_HOME=<Install_Path>/valgrind/3.16.1/
export VALGRIND_LIB=<Install_Path>valgrind/3.16.1/lib/
After relaunching, enable the Valgrind option in the launch configuration settings or update the configuration file,
$(COMPONENT_NAME)/Output/x86sim/Work/options/x86sim.options.Run x86simulation by selecting the Run option under X86SIMULATION in the Flow navigator.
With no violations in the kernel code, the valgrind messages looks similar to the following in the console:
x86simulator --pkg-dir=./Work --i=.. --valgrind It is recommended to use Valgrind version 3.14.0 or higher. ==21151== Memcheck, a memory error detector ==21151== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==21151== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info ==21151== Command: ./Work/pthread/sim.out ==21151== INFO: Reading options file './Work/options/x86sim.options'. ==21151== ==21151== HEAP SUMMARY: ==21151== in use at exit: 183,522 bytes in 530 blocks ==21151== total heap usage: 179,047 allocs, 178,517 frees, 9,342,021 bytes allocated ==21151== ==21151== For a detailed leak analysis, rerun with: --leak-check=full ==21151== ==21151== For lists of detected and suppressed errors, rerun with: -s ==21151== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Add the memory read violation to the kernel code, and see the valgrind messages.
Open
src/kernels/peak_detect.cc, and change line 25 tov_in = *(InIter+8500000500).Build the AI Engine component, and run the x86simulation. Observe the console for the following messages in the output console:
x86simulator --pkg-dir=./Work --i=.. --valgrind .. .. .. ==15387== by 0x411D64: operator= (vbit_vector.h:237) ==15387== by 0x411D64: operator= (vbit_vector.h:507) ==15387== by 0x411D64: v16int32::operator=(v16int32 const&) (me_chess_types.h:2654) ==15387== by 0x411A60: aie::detail::vector<int, 16u>::operator=(aie::detail::vector<int, 16u> const&) (vector.hpp:304) ==15387== by 0x40C382: peak_detect(adf::io_buffer<int, adf::direction::in, adf::io_buffer_config<adf::extents<4294967295u>, adf::locking::sync, adf::addressing::linear, adf::margin<0u> > >&, adf::io_buffer<int, adf::direction::out, adf::io_buffer_config<adf::extents<4294967295u>, adf::locking::sync, adf::addressing::linear, adf::margin<0u> > >&, output_stream<int>*, adf::io_buffer<float, adf::direction::out, adf::io_buffer_config<adf::extents<4294967295u>, adf::locking::sync, adf::addressing::linear, adf::margin<0u> > >&) (peak_detect.cc:20) .. .. ==15387== For lists of detected and suppressed errors, rerun with: -s ==15387== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) /proj/xbuilds/SWIP/2023.1_0427_0137/installs/lin64/Vitis/2023.1/aietools/bin/x86simulator: line 374: 15387 Segmentation fault valgrind $VALGRIND_ARGS $X86SIM_PROG
Valgrind points out the file that has out-of-bound read access with the line number as shown above.