Compilation success with pthreads enabled

- The project can be compiled with pthread enabled on opencv build
	- FIXME: Needed to add a call to pthread_cond_init() in the main component for the linker to work.
	The pthread_cond implementation is done in esp-idf/components/pthreads/
- The optimization hasn't yet enhanced the benchmark performances, hasn't found why for now
This commit is contained in:
Joachim
2020-03-30 12:39:59 +02:00
parent d73da63355
commit ab6954cc23
9 changed files with 21 additions and 7 deletions

View File

@ -305,6 +305,12 @@ if(ESP32)
endif() endif()
``` ```
The checks for system libraries (`libpthread`, `libdl`, `libm`, `librt`) are also activated by changing the line 607 of the `CMakeList.txt` file:
```cmake
if(UNIX OF ESP32)
```
The `cmake` command is run, leading to the following errors: The `cmake` command is run, leading to the following errors:
@ -512,7 +518,17 @@ The library is compiled in the `3rdparty/` folder. Copy this folder into the esp
## Adding parallel support ## Adding parallel support
TODO To add loop parallelization on the 2 cores of the esp32, the following modifications are done:
* Changed cmake command with `-DWITH_PTHREADS_PF=ON`
* Had to temporary add a pthread_cond usage in the main component for the link to work (otherwise had an *undefined reference to pthread_cond_* functions)
* The pthread_cond implementation is in the esp-idf pthread component. Haven't found yet how to link it
* In `parallel.cpp` function `getNumberOfCPUs`:
* For now, couldn't make `sysconf` function to work (to get the number of cpus), so returns 2 if ESP32 is defined
* In idf menuconfig:
* set pthread default stack size to 8192
These modifications haven't improved the performances on the benchmark for now.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -950,6 +950,10 @@ int cv::getNumberOfCPUs(void)
#endif #endif
#if defined(ESP32)
ncpus = 2; // TODO: Only for ESP32D0WD
#endif
return ncpus != 0 ? ncpus : 1; return ncpus != 0 ? ncpus : 1;
} }

View File

@ -7,13 +7,7 @@
#include "parallel_impl.hpp" #include "parallel_impl.hpp"
#ifdef HAVE_PTHREADS_PF #ifdef HAVE_PTHREADS_PF
#ifdef __cplusplus
extern "C" {
#endif
#include <pthread.h> #include <pthread.h>
#ifdef __cplusplus
}
#endif
#include <opencv2/core/utils/configuration.private.hpp> #include <opencv2/core/utils/configuration.private.hpp>