2017-04-14 13:13:38 -0600 | received badge | ● Notable Question (source) |
2016-06-14 16:27:41 -0600 | received badge | ● Popular Question (source) |
2015-08-05 08:29:16 -0600 | commented question | opencv much slower in multithreading Hi Steven, ¿Does the code work for you?... |
2015-08-05 05:08:37 -0600 | commented question | opencv much slower in multithreading LBerger, i think that you are right. Those functions use parallel_for_ in its implementations. If the number of threads is not set with cv::setnumThreads, opencv gets the logical cores of the system by default, so, in the execution of any of those functions 8 or 12 extra suprocesses (in a 4 native cores CPU and in a 6 native CPUs computers that I have used) are created. if you set cv::setnumThreads(0), those subprocesses are not created. I have made test changing this number of threads with cv::setnumThreads but with the same result. StevenPuttemans, Thanks. I hope that you can now reproduce the behaviour. As you can see, the threads are created before, and each thread executes the function with the opencv calls. |
2015-08-04 16:53:59 -0600 | commented question | opencv much slower in multithreading The main function executes the function TestThreads in 1 core, when finish, executes the function in two cores, after in three...and so on until 8 cores, because my cpu has 4 native cores (8 with hyperthreading). It is only to see how the execution time in each thread increases whe the number of threads is increased. You are right. This may be a possible cause because I/O operations may block threads, but if in the for loop inside the TestThreads fuctions the function With_OUT_Opencv (without calls to opencv functions) is called instead of WithOpencv, the behabiour is the expected one. Even leaving only 1 single function call to a opencv function (convert, or blur,...) the delay when increasing the number of threads appears... |
2015-08-04 15:51:54 -0600 | commented question | opencv much slower in multithreading the attached project is not shown... you can download from link text thanks!! |
2015-08-04 15:49:45 -0600 | received badge | ● Editor (source) |
2015-08-04 15:10:39 -0600 | asked a question | opencv much slower in multithreading Im writting a console application that uses open cv and multithreading. Im testing it in a 4 native core CPU (8 with HT enabled) with 12 GB of RAM. Each thread has to execute a function that uses opencv calls. In that case, the time is much bigger executing in parallel several threads than the run time obtained for a single thread. One expects that the time is more or less the same independently the number of threads or increased about 10%, but the run time for each thread increases according to the number of threads used. The more threads, the more the time for each one. I have test cv::setnumThreads(8) and cv::setnumThreads(0) with the same result. If the function is replaced by other function with some own dummy filters over data, the behaviour is the expected one, all threads ends with the same run time independently of the numbre of threads. Does opencv functions block the threads or do some sequential operations that blok threads???. The picture below shows the times obtained in the application: Time in file No. 3 --> means the total time to process a sequence of images (768) in miliseconds, I attach a sample c++ project to test this behaviour. This application executes secuentially 1 to 8 threads. Does anybody know what is happening?. I don`t know what else to do... Thanks. EDIT. Here is the code. I cannot attach a ready to use project to the post. It is in the link of the previous comment. The test image is Test.jpg. The original used is in bmp format. (more) |