Compiler (GCC) support to parallelism


Testing parallel std-algorithms

std::random_shuffle does not work for OMP_NUM_THREADS=1 bug submitted. see report

gcc 4.3.1 include parallel version of many std algorithms. I tested some of them with this trivial program (stdsort.cpp)

  std::vector<int> v(1000000,1);

where each call is actually enclosed in a "high precision real-time clock".

Once discovered that random_shuffle seems to be buggy for one thread results make a bit more sense....

Algo Real Time (Mticks)
c++ -02 2 Thread 4 Threads 8 Threads
alloc,fill,sum 9.8 12.0 13.0 16.0
shuffle 78 51 27 18
sort 237 124 62 44
stable-sort 316 151 77 53

a simple "HPC" multi-thread program: prime numbers

The training organized by OpenLab proposed the simple exercise of compiling the list of the first N prime numbers using a brute force approach.

The original version (ompPrimes.cpp) uses OpenMP and compile just fine with gcc 4.3.1. I also developed two alternative solutions: the first (psxPrimes.cpp) uses standard posix threads (actually boost::thread), the second (stdPrimes.cpp) uses parallel gcc.

The results listed below has been obtained on a 2x4core machine Intel Xeon E5410 2.33GHz

Method Real Time (s)
1 Thread 4 Threads 8 Threads
posix 4.04 1.06 0.58
omp 3.98 1.04 0.54
std 4.00 1.06 0.56


multicore tests

can be found in /afs/

compiling with gcc 4.3.1

gcc 4.3.1 has support for omp and parallel-stl

I use this simple script to set up my development environment

setenv Boost135 /afs/
setenv LD_LIBRARY_PATH /afs/${Boost135}/../../lib/:${LD_LIBRARY_PATH} 
alias c43 /afs/ -O2 -D_GLIBCXX_PARALLEL -fopenmp  -pthread -I${Boost135} -L${Boost135}/../../lib/ -lboost_thread-gcc43-mt

setenv OMP_NUM_THREADS 1 can be used to switch to a sequential processing in a single thread

-- VincenzoInnocente - 02-Mar-2011

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2011-03-25 - VincenzoInnocente
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    LCG All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback