goodrobots / vision_landing

Precision landing using visual targets
GNU General Public License v3.0
198 stars 70 forks source link

Multi-threading not working on raspberry #95

Open fnoop opened 6 years ago

fnoop commented 6 years ago

track_targets performs better when compiled to use a single thread for marker detection: MParams.maxThreads = 1; When compiled for multiple or maximum threads: MParams.maxThreads = -1;, performance decreases (about 20ms to 25-30ms per frame).

cmake sets c++ flags to: -- C++ flags (Release): -fomit-frame-pointer -O2 -ffast-math -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize -DNDEBUG -Wall

seems to be missing threading flags: -std=c++0x thread.cxx -o thread -pthread

Also check it's building release and not debug

fnoop commented 6 years ago

v.useful info: https://www.raspberrypi.org/forums/viewtopic.php?t=144115

fnoop commented 6 years ago

Actually looks like aruco is compiling with debug flags: -- C++ flags (Debug): -g3 -O0 -DDEBUG -D_DEBUG -W -Wextra -Wno-return-type -Wall

fnoop commented 6 years ago

Added '-DCMAKE_BUILD_TYPE=Release -DENABLE_OPENMP=ON' compile options to turn off debug flags.

cmake/compilerOptions.cmake sets wrong flags for raspberry:

  if(${CMAKE_SYSTEM_PROCESSOR} MATCHES armv7l) # In ARM_COrtex8 with neon, enalble vectorized operations
        set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize ")
    endif()
fnoop commented 6 years ago

changing compile options to:

    if(${CMAKE_SYSTEM_PROCESSOR} MATCHES armv7l) # In ARM_COrtex8 with neon, enalble vectorized operations
        # set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize ")
        set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -march=armv8-a+crc -mfpu=neon-vfpv4 -mtune=cortex-a53 -ftree-vectorize -mfloat-abi=hard -O3 ")
    endif()
fnoop commented 6 years ago

https://github.com/opencv/opencv/wiki/CPU-optimizations-build-options