Reputation: 1375
I am trying to parallelize some code, but I am running into (presumably dumb) problems. The example code below returns "12", although I'd expect "21".
omp_get_max_threads() returns 8, omp_get_num_threads() returns 1 and omp_get_thread_num() returns 0 when I call them anywhere in this block. I guess I can conclude that it just gets executed by the master thread sequentially.
#include <omp.h>
#include <iostream>
#include <Windows.h>
using namespace std;
int main() {
#pragma omp parallel sections num_threads(2)
{
#pragma omp section
{ Sleep(200);
cout << "1"; }
#pragma omp section
{ cout << "2"; }
}
}
What am I doing wrong? How can I force parallel processing of these sections?
For context: I am streaming data from two USB 3.0 cameras and calling the image from each sequentially is so slow that I am losing frames. I would like to basically set one thread aside for each camera to constantly demand its image.
This question has a similar title but didn't help. I'm using Visual Studio 2010.
Upvotes: 1
Views: 1532
Reputation: 1375
The comments were correct: I forgot to set up OMP support in the project settings.
Remarkably, the number of frames I can transfer from the cameras dropped. Maximizing the bandwidth used is not as simple as that I suppose.
Upvotes: 1