openmp

OpenMP with OpenCV on OS X

I'm having a problem getting OpenMP and OpenCV to play nicely with a new project in Xcode. The project in its current state does nothing but grab frames from the default camera and put them into a window. This functionality works. However, I would like to grab the frames in a separate thread, and I was hoping I could get some experience ...

How to ensure a dynamically allocated array is private in openmp

I'm working in C with openMP using gcc on a linux machine. In an openmp parallel for loop, I can declare a statically allocated array as private. Consider the code fragment: int a[10]; #pragma omp parallel for shared(none) firstprivate(a) for(i=0;i<4;i++){ And everything works as expected. But if instead I allocate a dynamically, i...

Do I need to #include <omp.h> in my C/C++ sources?

Is it necessary to include omp.h in my C/C++ sources? Why? Or why not? Does the gcc compiler include it by default when used with the -fopenmp flag? It doesn't seem te make a differance. ...

Implementing a parallel algorithm to compute pi

I would like to implement a parallel version of the code below using threads in OpenMP,is there any better way to do this? /* Program to compute Pi using Monte Carlo methods */ #include <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> #include <time.h> #define SEED 35791246 int main(int argc, char* argv) { int ni...

Analogs of Intel's Cluster OpenMP

Hello Are there analogs of Intel Cluster OpenMP? This library simulates shared-memory machine (like SMP or NUMA) while running on distributed memory machine (like Ethernet-connected cluster of PC's). This library allows to start openmp programs directly on cluster. ...

How to use lock in openMP?

I have two piece of C++ code running on 2 different cores. Both of them wirte to the same file. How to use openMP and make sure there is no crash? ...

Why is my computer not showing a speedup when I use parallel code?

So I realize this question sounds stupid (and yes I am using a dual core), but I have tried two different libraries (Grand Central Dispatch and OpenMP), and when using clock() to time the code with and without the lines that make it parallel, the speed is the same. (for the record they were both using their own form of parallel for). T...

Is it possible to separately plug in OpenMP libraries to Visual C++ 2008?

In Visual Studio 2005. OpenMP didn't come with the Express Edition, but it was possible to download it separately and get it set up, since the compiler itself was OMP-enabled. Is the same true with Visual Studio 2008? We are all using Standard Edition which similarly supports OpenMP but doesn't come with the libs/headers. Some code we h...

How well-suited is openMP for parallelizing a chunk of code that is run many times a second?

Say you have a typical game-loop, running about 30 times a second. One particular function takes about 50% of the time and looks like a prime candidate for parallelization - say it's a big loop or there are 4 distinct and independent strands of work going on. Assume we already checked that the function itself can parallelize well in isol...

Segmentation fault on MPI, runs properly on OpenMP

Hi, I am trying to run a program on a computer cluster. The structure of the program is the following: PROGRAM something ... CALL subroutine1(...) ... END PROGRAM SUBROUTINE subroutine1(...) ... DO i=1,n CALL subroutine2(...) ENDDO ... END SUBROUTINE SUBROUTINE subroutine2(...) ... CALL subroutine3(...) CALL subroutine4(...) ... END ...

Is there something like clock() that works better for parallel code?

So I know that clock() measures clock cycles, and thus isn't very good for measuring time, and I know there are functions like omp_get_wtime() for getting the wall time, but it is frustrating for me that the wall time varies so much, and was wondering if there was some way to measure distinct clock cycles (only one cycle even if more tha...

Iteration through std containers in openmp

Hi, people. I try to use openmp for multithreading the loop through std::set. When I write the following code - #pragma omp parallel for for (std::set<A>::const_iterator i = s.begin(); i != s.end(); ++i) { const A a = *i; operate(a); } I get an error - error: invalid type for iteration variable 'i...

Segmentation fault while matrix multiplication using openMp?

My matrix multiplication code is int matMul(int ld, double** matrix) { //local variables initialize omp_set_num_threads(nthreads); \#pragma omp parallel private(tid,diag,ld) shared(i,j,k,matrix) { /* Obtain and print thread id */ tid = omp_get_thread_num(); for ( k=0; k<ld; k++) { if (matrix[k][k] == 0....

OpenMP + SSE gives no speedup

Hi, My Professor found out this interesting experiment of 3D Linearly separable Kernel Convolution using SSE and OpenMP, and gave the task to me to benchmark the statistics on our system. The author claims a crazy 18 fold speedup from the serial approach! Might not be always, but we were expecting at least a 2-4 times speedup running th...

Running multiprocess applications from MATLAB

I've written a multitprocess application in VC++ and tried to execute it with command line arguments with the system command from MATLAB. It runs, but only on one core --- any suggestions? Update:In fact, it doesn't even see the second core. I used OpenMP and used omp_get_max_threads() and omp_get_thread_num() to check and omp_get_max_t...

How to printf a time_t variable as a floating point number?

Hi guys, I'm using a time_t variable in C (openMP enviroment) to keep cpu execution time...I define a float value sum_tot_time to sum time for all cpu's...I mean sum_tot_time is the sum of cpu's time_t values. The problem is that printing the value sum_tot_time it appear as an integer or long, by the way without its decimal part! I tried...

OpenMP - running things in parallel and some in sequence within them

Hi, I have a scenario like: for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { for (k = 0; k < x; k++) { val = 2*i + j + 4*k if (val != 0) { for(t = 0; t < l; t++) { someFunction((i + t) + someFunction(j + t) + k*t) } } } } } Considering...

Dividing sections inside an omp parallel for : OpenMP

Hi, I have a situation like: #pragma omp parallel for private(i, j, k, val, p, l) for (i = 0; i < num1; i++) { for (j = 0; j < num2; j++) { for (k = 0; k < num3; k++) { val = m[i + j*somenum + k*2] if (val != 0) for (l = start; l <= end;...

How to deal with OpenMP thread pool contention

I'm working on an application that uses both coarse and fine grained multi-threading. That is, we manage scheduling of large work units on a pool of threads manually, and then within those work units certain functions utilize OpenMP for finer grain multithreading. We have realized gains by selectively using OpenMP in our costliest loops...

[C++][OpenMP] Proper use of "atomic directive" to lock STL container

I have a large number of sets of integers, which I have, in turn, put into a vector of pointers. I need to be able to update these sets of integers in parallel without causing a race condition. More specifically. I am using OpenMP's "parallel for" construct. For dealing with shared resources, OpenMP offers a handy "atomic directive," w...