Using OpenMP to exploit multicore/multiprocessor systems in VC++ programs is this simple:
int iCPU = omp_get_num_procs();
4. Now set number of threads to be created (say for data parallelism in case of loop parallelization)
5. To actually, convert a single thread loop to multithread, insert this OpenMP pragma
double start = omp_get_wtime();
#pragma omp parallel for private (si)
nested for loop(si=0,si<1000;si++)
double end = omp_get_wtime();
double time_taken = end - start;
6. omp_get_wtime() is called before and after the loop, so as to determine total time taken in execution (wall time).
7. For sure, more number of threads lesser the time in execution
8. To actually confirm this, check under Performance tab of Task Manager (Alt-Ctrl-Del). % CPU Usage is more for more threads meaning better CPU utilization
Caution: Task parallelized should be of greater load than overhead of parallelization. This is very important. Otherwise, you may end up with false notations that OpenMP degrades performance...