<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Newbie in multi-threaded programming and OpenMP with a hand in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/917997#M4858</link>
    <description>&lt;P&gt;Hi Andreas,&lt;/P&gt;
&lt;P&gt;I can answer a few of your questions.&lt;/P&gt;
&lt;P&gt;1) installing an OpenMP-aware compiler&lt;/P&gt;
&lt;P&gt;OpenMP is an organization (and specification) that specifies a set of compiler directives as a set of #pragmas for C/C++ and comments for FORTRAN. So if you are not using an OpenMP aware compiler you are not by definition using OpenMP.&lt;/P&gt;
&lt;P&gt;My OpenMP environment is WindowsXP Pro and Intel Visual Fortran. The systems I run on are two Intel HT only systems and one dual processor/4 core AMDOpteron system. Initialy I had problems on the HT only systems were I observed a decrease in performance. Now I can see up to 30% improvement on the HT only systems. On the 4-core Opteron I can see about 300% over single core. Some sections of code experience ~400% improvementsome no improvement.&lt;/P&gt;
&lt;P&gt;2) How can I verify that my system indeed supports OpenMP after I have installed such a compiler?&lt;/P&gt;
&lt;P&gt;In your test program:&lt;/P&gt;
&lt;P&gt; #pragma omp parallel sections num_threads(4)&lt;BR /&gt;  {&lt;BR /&gt;   #pragma omp section&lt;BR /&gt;   f(0);&lt;BR /&gt;   #pragma omp section&lt;BR /&gt;   f(1);&lt;BR /&gt;   #pragma omp section&lt;BR /&gt;   f(2);&lt;BR /&gt;   #pragma omp section&lt;BR /&gt;   f(3);&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;Have the function f print the entry argument and print the OpenMP thread number.&lt;/P&gt;
&lt;P&gt;printf should be thread safe but if you have problems with multiple threads using printf then use the entry arg to f(int i) as an index into a global table (int fTable[4];) then store the thread number into the array&lt;/P&gt;&lt;B&gt;&lt;FONT face="Courier" size="2"&gt;
&lt;P align="left"&gt; fTable&lt;I&gt; = omp_get_thread_num();&lt;/I&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;
&lt;P&gt;Then after the close of the test section print out the contents of the fTable&lt;/P&gt;
&lt;P&gt;If you do not see four different threads then your code might not be running with OpenMP.&lt;/P&gt;
&lt;P&gt;You do realize that the C++ OpenMP ships with no-op stub routines that can be linked into the program in lieu of the OpenMP runtime system. Have you verified that you are using the OpenMP runtime system library instead of the no-op stub routines?&lt;/P&gt;
&lt;P&gt;3) On an OpenMP-aware compiler, is it enough to use the #pragma's or do I also need to add the -openmp option? If I get a message such as "OpenMP DEFINED SECTION WAS PARALLELIZED" during compilation, can I rest assured that the program will execute using mupltiple threads?&lt;/P&gt;
&lt;P&gt;Get your test example working with multiple threadswhile using -openmp. Then try without -openmp. As I do not use Intel C++ I cannot try this for you. There may be an issue as to what is pulled from the runtime library. i.e. without -openmp the no-op stubs get linked in. It may be that -openmp is required on main. You can experiment if/if not.&lt;/P&gt;
&lt;P&gt;4) --- I cannot help you here&lt;/P&gt;
&lt;P&gt;5) --- see answer for 2)&lt;/P&gt;
&lt;P&gt;6) - threading tools.&lt;/P&gt;
&lt;P&gt;As you stand now it is a case of "Are you running with parallel sections or not".&lt;/P&gt;
&lt;P&gt;For this, modify the test case such that your function f() takes 2 seconds
to run using1 processor. Make this a compute bound test. The program shouldrun 8 seconds with 4 serial calls to f(). If running configured for parallel it should be much less. &lt;/P&gt;
&lt;P&gt;Good luck&lt;/P&gt;
&lt;P&gt;I am quiet pleased with OpenMP in Intel Visual Fortran (on Windoz). I am sure you will be too once you get the test configuration working. I think you may have a linking problem (using no-op stubs).&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jul 2006 23:35:53 GMT</pubDate>
    <dc:creator>jimdempseyatthecove</dc:creator>
    <dc:date>2006-07-07T23:35:53Z</dc:date>
    <item>
      <title>Newbie in multi-threaded programming and OpenMP with a handful of questions</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/917996#M4857</link>
      <description>Greetings to all,&lt;BR /&gt;
&lt;BR /&gt;
I have been working on signal processing and perceptual components
applications using C++ for some time, but lately I've run into some
execution speed problems, so I've decided to try out multi-threaded
programming. After a couple of days of playing around with pthreads and
OpenMP, I can say I am positively stumped with what seem to be very
simple stuff, so I ask for your help (and understanding if these
questions are simply too naive). All my experiments have been carried
out on a 32-bit Dual Xeon @ 2.8 GHz with 2 GB of RAM running SuSe Linux
9.3.&lt;BR /&gt;
&lt;BR /&gt;
1) First of all, is there a way of using OpenMP other than installing
an OpenMP-aware compiler (I have used Intel's Linux C++ Compiler 9.1 as
a starting point)?&lt;BR /&gt;
&lt;BR /&gt;
2) How can I verify that my system indeed supports OpenMP after I have
installed such a compiler? I know that there are a number of
environmental variables (such as OMP_NUM_THREADS), however I get
nothing when I echo one of them. Are these set implicitly when OpenMP
support is installed or do I have to do that myself by running a script
or using the export command on a shell?&lt;BR /&gt;
&lt;BR /&gt;
3) From what I can tell, including &lt;OMP.H&gt; is only necessary if I
need to use one of the run-time library functions, such as
omp_get_num_threads(), whereas the use of #pragma's does not require
&lt;OMP.H&gt;. Is that correct? On an OpenMP-aware compiler, is it
enough to use the #pragma's or do I also need to add the -openmp
option? If I get a message such as "OpenMP DEFINED SECTION WAS
PARALLELIZED" during compilation, can I rest assured that the program
will execute using mupltiple threads?&lt;BR /&gt;
&lt;BR /&gt;
4) I have been trying to make KDevelop (version 3.2) use the Intel
Compiler instead of the default gcc/g++ (since the version I have does
not seem to support OpenMP), but without any success. Although I have
installed the Linux Compiler, when I go to Project -&amp;gt; Project
Options -&amp;gt; Configure Options -&amp;gt; C++, the only compiler listed is
the GNU C++ one. How can I enable other compilers?&lt;BR /&gt;
&lt;BR /&gt;
5) I did manage to use the Eclipse tool provided in the Intel compiler
installation to create a project and test OpenMP, however the results
were quite disappointing in terms of speed: 25% and 50% reduction when
using 2 and 4 threads respectively, when compared to the serialized
version. Assuming that I have indeed setup OpenMP support correctly,
this probably means that I have parallelized my code quite poorly (to
say the least). The program works iteratively on new frames captured
from a camera and performs the same sequence of operations on each
pixel of the image buffer. Since operations on one pixel do not depend
on what happens with the others, I thought of breaking up the image on
2 or 4 parts and run the same function on each sub-image. The OpenMP
construct I used in the 4-thread case looks as follows:&lt;BR /&gt;
&lt;BR /&gt;
  #pragma omp parallel sections num_threads(4)&lt;BR /&gt;
  {&lt;BR /&gt;
   #pragma omp section&lt;BR /&gt;
   f(0);&lt;BR /&gt;
   #pragma omp section&lt;BR /&gt;
   f(1);&lt;BR /&gt;
   #pragma omp section&lt;BR /&gt;
 
  f(2);&lt;BR /&gt;
   #pragma omp section&lt;BR /&gt;
   f(3);&lt;BR /&gt;
  }&lt;BR /&gt;
&lt;BR /&gt;
Notice that although the same function is called for all sections, each
thread is expected to work on different (and non-overlapping) segments
of the initial image. Also, the function processes each pixel and
writes the outputs in globally defined buffers (again with no overlap
across threads), so I am hoping that there are no race condition
issues; indeed, the results are as expected from the serialized
version. I am therefore puzzled as to why I suffer such a performance
degradation... Is it because each thread calls the same function? Or
because all threads have to access the same output buffer (albeit at
different positions) and therefore must wait for each other to finish?
Or am I completely off the mark here?&lt;BR /&gt;
&lt;BR /&gt;
6) I have seen that there are Threading Tools that could answer my
previous question offered by Intel, however they are currently only
available for Win platforms. Is any info on a future Linux release
available?&lt;BR /&gt;
&lt;BR /&gt;
That is all (quite a lot actually...). I would appreciate any and all answers or comments.&lt;BR /&gt;
&lt;BR /&gt;
Thank you,&lt;BR /&gt;
Andreas.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;&lt;/OMP.H&gt;&lt;/OMP.H&gt;</description>
      <pubDate>Fri, 07 Jul 2006 17:23:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/917996#M4857</guid>
      <dc:creator>eren</dc:creator>
      <dc:date>2006-07-07T17:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie in multi-threaded programming and OpenMP with a hand</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/917997#M4858</link>
      <description>&lt;P&gt;Hi Andreas,&lt;/P&gt;
&lt;P&gt;I can answer a few of your questions.&lt;/P&gt;
&lt;P&gt;1) installing an OpenMP-aware compiler&lt;/P&gt;
&lt;P&gt;OpenMP is an organization (and specification) that specifies a set of compiler directives as a set of #pragmas for C/C++ and comments for FORTRAN. So if you are not using an OpenMP aware compiler you are not by definition using OpenMP.&lt;/P&gt;
&lt;P&gt;My OpenMP environment is WindowsXP Pro and Intel Visual Fortran. The systems I run on are two Intel HT only systems and one dual processor/4 core AMDOpteron system. Initialy I had problems on the HT only systems were I observed a decrease in performance. Now I can see up to 30% improvement on the HT only systems. On the 4-core Opteron I can see about 300% over single core. Some sections of code experience ~400% improvementsome no improvement.&lt;/P&gt;
&lt;P&gt;2) How can I verify that my system indeed supports OpenMP after I have installed such a compiler?&lt;/P&gt;
&lt;P&gt;In your test program:&lt;/P&gt;
&lt;P&gt; #pragma omp parallel sections num_threads(4)&lt;BR /&gt;  {&lt;BR /&gt;   #pragma omp section&lt;BR /&gt;   f(0);&lt;BR /&gt;   #pragma omp section&lt;BR /&gt;   f(1);&lt;BR /&gt;   #pragma omp section&lt;BR /&gt;   f(2);&lt;BR /&gt;   #pragma omp section&lt;BR /&gt;   f(3);&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;Have the function f print the entry argument and print the OpenMP thread number.&lt;/P&gt;
&lt;P&gt;printf should be thread safe but if you have problems with multiple threads using printf then use the entry arg to f(int i) as an index into a global table (int fTable[4];) then store the thread number into the array&lt;/P&gt;&lt;B&gt;&lt;FONT face="Courier" size="2"&gt;
&lt;P align="left"&gt; fTable&lt;I&gt; = omp_get_thread_num();&lt;/I&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;
&lt;P&gt;Then after the close of the test section print out the contents of the fTable&lt;/P&gt;
&lt;P&gt;If you do not see four different threads then your code might not be running with OpenMP.&lt;/P&gt;
&lt;P&gt;You do realize that the C++ OpenMP ships with no-op stub routines that can be linked into the program in lieu of the OpenMP runtime system. Have you verified that you are using the OpenMP runtime system library instead of the no-op stub routines?&lt;/P&gt;
&lt;P&gt;3) On an OpenMP-aware compiler, is it enough to use the #pragma's or do I also need to add the -openmp option? If I get a message such as "OpenMP DEFINED SECTION WAS PARALLELIZED" during compilation, can I rest assured that the program will execute using mupltiple threads?&lt;/P&gt;
&lt;P&gt;Get your test example working with multiple threadswhile using -openmp. Then try without -openmp. As I do not use Intel C++ I cannot try this for you. There may be an issue as to what is pulled from the runtime library. i.e. without -openmp the no-op stubs get linked in. It may be that -openmp is required on main. You can experiment if/if not.&lt;/P&gt;
&lt;P&gt;4) --- I cannot help you here&lt;/P&gt;
&lt;P&gt;5) --- see answer for 2)&lt;/P&gt;
&lt;P&gt;6) - threading tools.&lt;/P&gt;
&lt;P&gt;As you stand now it is a case of "Are you running with parallel sections or not".&lt;/P&gt;
&lt;P&gt;For this, modify the test case such that your function f() takes 2 seconds
to run using1 processor. Make this a compute bound test. The program shouldrun 8 seconds with 4 serial calls to f(). If running configured for parallel it should be much less. &lt;/P&gt;
&lt;P&gt;Good luck&lt;/P&gt;
&lt;P&gt;I am quiet pleased with OpenMP in Intel Visual Fortran (on Windoz). I am sure you will be too once you get the test configuration working. I think you may have a linking problem (using no-op stubs).&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2006 23:35:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/917997#M4858</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2006-07-07T23:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie in multi-threaded programming and OpenMP with a hand</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/917998#M4859</link>
      <description>Hi Jim,&lt;BR /&gt;
&lt;BR /&gt;
first of all, thank you for your input. It seems that the code I
presented actually runs using 4 threads, as I get four different thread
IDs. If I ask for two threads, I can verify that each of them runs two
times (as there are still four parallel sections). So I seem to have
enabled multi-threaded compilation just fine. &lt;BR /&gt;
&lt;BR /&gt;
I am not sure what you mean by "You do realize that the C++ OpenMP ships with no-op stub routines that
can be linked into the program in lieu of the OpenMP runtime system.", though. Could you be a little bit more specific?&lt;BR /&gt;
&lt;BR /&gt;
As to why this doesn't speed things up, I still cannot tell. I was
thinking of moving the parallelization inside the function itself
instead of calling it four times, using a parallel for #pragma. I guess
this will be somewhat more complicated as I will have to be on the
lookout for private and shared variables, but, as they say, no pain, no
gain, right? I don't seem to getting anywhere if I just keep the code
as it is anyway...&lt;BR /&gt;
&lt;BR /&gt;
I will also try to install the newest gcc that seems to be OpenMP-aware
and see how that turns out, so I can at least still use KDevelop as my
IDE. Unless some good folks point out to me how I can setup KDevelop to
use Intel's compiler in the meantime...&lt;BR /&gt;
&lt;BR /&gt;
I don't quite get your answer on question 6, but I guess it means there
is no info on an upcoming Linux release of the Threading Tools?&lt;BR /&gt;
&lt;BR /&gt;
I will step back from my efforts at multi-threaded programming for a
few days, to complete my application using a single thread and then get
back in the OpenMP game. I will post any new findings I come across.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Andreas.&lt;BR /&gt;
&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jul 2006 16:49:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/917998#M4859</guid>
      <dc:creator>eren</dc:creator>
      <dc:date>2006-07-10T16:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie in multi-threaded programming and OpenMP with a hand</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/917999#M4860</link>
      <description>&lt;P&gt;The fact that you see four thread numbers is a good starting point.&lt;/P&gt;
&lt;P&gt;Part of the OpenMP specification requires that no-op stub routines be shipped such that they can be linked into the application when running in environments where multiple threads is detrimental. Example: you ship your application out in .OBJ (.LIB) format compiled with OpenMP but linked atcustomer descretion with or without OpenMP.&lt;/P&gt;
&lt;P&gt;If you are not seeing a speedup then either a) not much code is being executed in the f(n) or b)your application has multiple threads but your Operating System is restricting the application to one processor, or c) the code is saturating the memory bandwith.&lt;/P&gt;
&lt;P&gt;Your parallel section code should be fine. Make a simple f(n) function that is compute intensive as well as low-memory bandwidth (or high cache usage). Note, if f(n) is simply performing a memory population then the test is limited by memory bandwidth and each processor may be flushing the other processor's cache when performing writes.&lt;/P&gt;
&lt;P&gt;Below is a simple compute intensive application written in C that I found on the internet. &lt;/P&gt;
&lt;P&gt;Change main(... to your f(...) and appropriately edit the printf calls.&lt;/P&gt;
&lt;P&gt;--------- begin ------------&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier" size="2"&gt;/*--- pi.c PROGRAM RANPI&lt;BR /&gt; *&lt;BR /&gt; * Program to compute PI by probability.&lt;BR /&gt; * By Mark Riordan 24-DEC-1986; &lt;BR /&gt; * Original version apparently by Don Shull.&lt;BR /&gt; * To be used as a CPU benchmark.&lt;BR /&gt; * &lt;BR /&gt; * Translated to C from FORTRAN 20 Nov 1993&lt;BR /&gt; */&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;&lt;BR /&gt;void&lt;BR /&gt;myadd(float *sum,float *addend);&lt;BR /&gt;&lt;BR /&gt;int&lt;BR /&gt;main(int argc, char *argv[]) {&lt;BR /&gt; float ztot, yran, ymult, ymod, x, y, z, pi, prod;&lt;BR /&gt; long int low, ixran, itot, j, iprod;&lt;BR /&gt;&lt;BR /&gt; printf("Starting PI...
");&lt;BR /&gt; ztot = 0.0;&lt;BR /&gt; low = 1;&lt;BR /&gt; ixran = 1907;&lt;BR /&gt; yran = 5813.0;&lt;BR /&gt; ymult = 1307.0;&lt;BR /&gt; ymod = 5471.0;&lt;BR /&gt; itot = 1200000;&lt;BR /&gt;&lt;BR /&gt; for(j=1; j&amp;lt;=itot; j++) {&lt;BR /&gt;&lt;BR /&gt;/*&lt;BR /&gt;c X and Y are two uniform random numbers between 0 and 1.&lt;BR /&gt;c They are computed using two linear congruential generators.&lt;BR /&gt;c A mix of integer and real arithmetic is used to simulate a&lt;BR /&gt;c real program. Magnitudes are kept small to prevent 32-bit&lt;BR /&gt;c integer overflow and to allow full precision even with a 23-bit&lt;BR /&gt;c mantissa.&lt;BR /&gt;*/&lt;BR /&gt;&lt;BR /&gt; iprod = 27611 * ixran;&lt;BR /&gt; ixran = iprod - 74383*(long int)(iprod/74383);&lt;BR /&gt; x = (float)ixran / 74383.0;&lt;BR /&gt; prod = ymult * yran;&lt;BR /&gt; yran = (prod - ymod*(long int)(prod/ymod));&lt;BR /&gt; y = yran / ymod;&lt;BR /&gt; z = x*x + y*y;&lt;BR /&gt; myadd(&amp;amp;ztot,&amp;amp;z);&lt;BR /&gt; if ( z &amp;lt;= 1.0 ) {&lt;BR /&gt;&amp;amp;n
bsp; low = low + 1;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; printf(" x=%8.5f y=%8.5f low=%7d j=%7d
",x,y,low,j);&lt;BR /&gt; pi = 4.0 * (float)low/(float)itot;&lt;BR /&gt; printf("Pi = %9.6f ztot=%12.2f itot=%8d
",pi,ztot,itot);&lt;BR /&gt;&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void&lt;BR /&gt;myadd(float *sum,float *addend) {&lt;BR /&gt;&lt;BR /&gt;/*&lt;BR /&gt;c Simple adding subroutine thrown in to allow subroutine&lt;BR /&gt;c calls/returns to be factored in as part of the benchmark.&lt;BR /&gt;*/&lt;BR /&gt; *sum = *sum + *addend;&lt;BR /&gt;}&lt;BR /&gt;-------------------------- end --------------&lt;/STDIO.H&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier" size="2"&gt;If you see no speedup then you may be linking in the wrong library or the kernal is inhibiting the application from using the multiple processors.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier" size="2"&gt;Jim Dempsey&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2006 00:14:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/917999#M4860</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2006-07-11T00:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie in multi-threaded programming and OpenMP with a hand</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/918000#M4861</link>
      <description>Jim,&lt;BR /&gt;
&lt;BR /&gt;
once again I thank you. I will try it out some time this week and let you know of the outcome.&lt;BR /&gt;
&lt;BR /&gt;
Andreas.&lt;BR /&gt;
&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Jul 2006 15:25:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/918000#M4861</guid>
      <dc:creator>eren</dc:creator>
      <dc:date>2006-07-11T15:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie in multi-threaded programming and OpenMP with a hand</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/918001#M4862</link>
      <description>&lt;P&gt;&lt;FONT face="Arial"&gt;Andreas,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;Once you resolve the issue of running on multiple processors your next job is to determine how best to divide up your code using OpenMP. There are many ways to do this. The two predominant ways are&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;1) Parallel-ize the large inner loops&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;2) Parallel-ize the outer master control loop(s)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;For the code I work on (Finite Element Analysis of tension structures) I found number 2 works best. This is because I can setup each component to advance the state independently. Then at end of component state advancement I reconcile the component to component interaction. What this did for me was the reduce the number of transitions between serial sections and parallel sections. Starting and stopping threads does introduce overhead. The loop size must be large enough to overcome this overhead to yield some payback.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;Other applications (yours?) might do best by parallelizing the inner loops.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;The best method will depend on the application as well as the size of the data sets handled by the application. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;For my application when using coarse granulation (less nodes) method 2) works best. However, as I increase the number of nodes then at some point method 1) will work best. Eventualy, I expect this application to include both methods and todeterminefrom the input data set which isbest.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;To help optimize your code you should consider using a profiler. Intel has a product (for sale) called vTune. If you are on a tight budget you might consider looking at AMD Developer Center (join for free) then looking for a free tool called CodeAnalyst. This profiler is developed for AMD processors, I know you have Intel XEON processors. However, instead of refusing to work on Intel processors, CodeAnalyst simply disables the features it cannot use. What this means is you are left with a functional subset called Time Based Profiling TBP. With TBP you can locate the bottlenecks in your code which is usualy sufficient to help you tune your code. The features that don't work are those called Event Based Profiling which requires Processor Dependent Control Register access. This means you won't get reports as to where and why your application is experiencing memory latency problems.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;The TBP will get you 90% the way to optimized code, the EBP will get you a bit more. Ichose CodeAnalyst because my main simulation system uses AMD Opteron processors. My other two developement systems use Intel processors. I found runningCodeAnalyst on the Intel processors quite satisfactory.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;I use the Windows version, but the site also has a Linux version too.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;Jim Dempsey&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2006 20:59:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Newbie-in-multi-threaded-programming-and-OpenMP-with-a-handful/m-p/918001#M4862</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2006-07-11T20:59:28Z</dc:date>
    </item>
  </channel>
</rss>

