openmp

No speed-up with useless printf's using OpenMP

I just wrote my first OpenMP program that parallelizes a simple for loop. I ran the code on my dual core machine and saw some speed up when going from 1 thread to 2 threads. However, I ran the same code on a school linux server and saw no speed-up. After trying different things, I finally realized that removing some useless printf statem...

OpenMP implementations in VC++ 2008, 2010

Depending on implementation, OMP can be quite useful to parallelize fairly arbitrary bits of code - e.g a parallel section inside a method that calls two independent methods - or it can be bad. It depends on how threads are created/cached, I think. How does the VC++ 2008 implementation work? And is the 2010 implementation significantly ...

openmp in mex : stackoverflow error

i have got the following fraction of code that getting me the stack overflow error #pragma omp parallel shared(Mo1, Mo2, sum_normalized_p_gn, Data, Mean_Out,Covar_Out,Prior_Out, det) private(i) num_threads( number_threads ) { //every thread has a new copy double* normalized_p_gn = (double*)malloc(NMIX*sizeof(dou...

What is sections in openmp

Hai Will the thread be distributed to the blocks inside the sections or each thread will be assigned to each sections because when i execute the below code NUMBER OF THREADS IS 3 pragma omp sections { #pragma omp section { printf ("id = %d, \n", omp_get_thread_num()); } #pragma omp section { printf ("id = %d...

Why aren't unsigned OpenMP index variables allowed?

I have a loop in my C++/OpenMP code that looks like this: #pragma omp parallel for for(unsigned int i=0; i<count; i++) { // do stuff } When I compile it (with Visual Studio 2005) I get the following error: error C3016: 'i' : index variable in OpenMP 'for' statement must have signed integral type I understand that the error occur...

OpenMP in Fortran

I very rarely use fortran, however I have been tasked with taking legacy code rewriting it to run in parallel. I'm using gfortran for my compiler choice. I found some excellent resources at https://computing.llnl.gov/tutorials/openMP/ as well as a few others. My problem is this, before I add any OpenMP directives, if I simply compile...

Multi-Core Programming. Boost's MPI, OpenMP, TBB, or something else?

Hello, I am totally a novice in Multi-Core Programming, but I do know how to program C++. Now, I am looking around for Multi-Core Programming library. I just want to give it a try, just for fun, and right now, I found 3 APIs, but I am not sure which one should I stick with. Right now, I see Boost's MPI, OpenMP and TBB. For anyone who h...

Linker library for OpenMP for Snow Leopard?

Currently, I am trying out OpenMP on XCode 3.2.2 on Snow Leopard: #include <omp.h> #include <iostream> #include <stdio.h> int main (int argc, char * const argv[]) { #pragma omp parallel printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads()); return 0; } I didn't include any linking lib...

Synchronisation construct inside pragma for

Hi, I have a program block like: for (iIndex1=0; iIndex1 < iSize; iIndex1++) { for (iIndex2=iIndex1+1; iIndex2 < iSize; iIndex2++) { iCount++; fDist =(*this)[iIndex1].distance( (*this)[iIndex2] ); m_oPDF.addPairDistance( fDist ); if ((bShowProgress) && (iCount ...

OpenMP num_threads(1) executes faster than no OpenMP

I’ve run my code in a variety of circumstances which has resulted in what I believe to be odd behavior. My testing was on a dual core intel xeon processor with HT. No OpenMP '#pragma' statement, total runtime = 507 seconds With OpenMP '#pragma' statement specifying 1 core, total runtime = 117 seconds With OpenMP '#pragma' statement sp...

Thread-safty of boost RNG

I have a loop which should be nicely pararellized by insering one openmp pragma: boost::normal_distribution<double> ddist(0, pow(retention, i - 1)); boost::variate_generator<gen &, BOOST_TYPEOF(ddist)> dgen(rng, ddist); // Diamond const std::uint_fast32_t dno = 1 <<...

Is a shared list between multiple threads a race condition?

I've got some multi threaded code that typically runs great, but every so often it will break. I'm trying to pinpoint the problem, but using OpenMP is making that more difficult (the problem does not occur in serial). I know that multiple access to a variable (race conditions) often crashes a program. I've got a list shared between the ...

OpenMP timer doesn't work on inline assembly code?

I'm trying to compare some code samples for speed, and I decided to use the OpenMP timer since I'll eventually be multi threading the code. The timer works great on two of my four code snippets, but not on the other two start=omp_get_wtime(); /*code here*/ finish = omp_get_wtime() - start_time; The four code here sections are serial ...

openmp sections running sequentially

I have the following code: #pragma omp parallel sections private(x,y,cpsrcptr) firstprivate(srcptr) lastprivate(srcptr) { #pragma omp section { //stuff } #pragma omp section { //stuff } } According to the Zoom profiler, two threads are created, one thread executes both the sections, and the other ...

Data parallel libraries in C/C++

I have a C# prototype that is heavily data parallel, and I've had extremely successful order of magnitude speed ups using the Parallel.For construct in .NETv4. Now I need to write the program in native code, and I'm wondering what my options are. I would prefer something somewhat portable across various operating systems and compilers, b...

How to break out of a nested parallel (OpenMP) Fortran loop idiomatically?

Here's sequential code: do i = 1, n do j = i+1, n if ("some_condition(i,j)") then result = "here's result" return end if end do end do Is there a cleaner way to execute iterations of the outer loop concurrently other than: !$OMP PARALLEL private(i,j) !$OMP DO do i = 1, n !$OMP FLUS...

How to control Open MP thread pooling?

Hi, I have been using Open MP to speed up an application. However I seem to be having a problem with the creating of additional thread pools. I am compiling on Windows XP using Visual Studio 2005 (Open MP 1.0). The program is similar to a web server, a request from a client comes in and I spawn a thread (using beginthread), this thread...

Schedule clause in OpenMP

Hi, I have a piece of code (which is part of an application) which I'm trying to optimize using OpenMP, am trying out various scheduling policies. In my case, I noticed that the schedule(RUNTIME) clause has an edge over others (I am not specifying a chunk_size). I've two questions: When I do not specify chunk_size, is there a differen...

segfault with -fopenmp for a trivial program

I am refreshing openmp a bit, and got into this weird situation. Shaved off the bunch, I created this minimal trivial case that shows the issue program ex2 implicit none integer, parameter :: n=10000000 integer :: i real :: x(n) do i=1,n x(i) = 0.0d0 enddo end program with no flags specified, gfortran...

Class Member variables and OpenMP

Hi, I have a scenario like the following: //class somemethod contains the member variables(declaration) val1 and val2, //and is defined in somemethod.h. #include <somemethod.h> void abovefunction(x) { //code that could be made parallel if val1 and val2 is declared private() } //abovefunction() is in somemethod.cpp, where the methods...