Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenMP not using all available cores on Raspberry Pi 2

I'm using OpenTLD (that uses OpenCV for image analysis) in a Raspberry Pi 2 project for object tracking. In order to combat lag issues (about 3 seconds of video lag) I enabled OpenMP support when I compiled. Now, I get only about 2 seconds of lag. Running top tells me that at most only ~170% CPU is being used by opentld, leading me to suspect that OpenMP is using only two of the Raspberry Pi 2's four cores.

From what I understand of this Wikipedia diagram, OpenMP should be able to utilize all four cores. Is this a matter of OpenMP not recognizing all the cores, or is it something else?

like image 322
faeophyta Avatar asked Nov 10 '22 17:11

faeophyta


1 Answers

First of all, you should do export OMP_NUM_THREADS=4 on the console.

Top reporting usages of 170% for the CPU, doesn't necessarily mean you're only running with 2 threads. The code might be memory bound and that might also deliver low CPU usage levels.

like image 104
a3mlord Avatar answered Nov 15 '22 04:11

a3mlord