You can use openMP directives to parallelize your service code to be executed efficiently on SMP clusters.
1. Compiling your service code
Symphony service written in C++ and openMP can be compiled in Linux with latest ICC (Intel C++ Compiler). Make sure you specify compiler command correctly as follows in the Makefile for your service code.
To obtain the latest ICC, go to Intel C++ Compiler page.Code:CC = icc -cxxlib-gcc -gcc-version=343 -openmp_profile # for linux2.6-glibc2.3-x86 platforms (RHEL4, SLES9), set -gcc-version=343 # for linux2.4-glibc2.3-x86 platforms (RHEL3), set -gcc-version=323 # for linux2.4-glibc2.2-x86 platforms (RHEL2.1, SLES8), set -gcc-version=320
2. Simple example of openMP directives
Here is a very simple openMP directives to parallelize for loop in multiple threads. (Attached package contains full source)
The snippet code is used to estimate PI through Monte Carlo simulation. Note that you can create multiple threads through num_threads directives and let each thread compute the workload of the for loop.Code:#pragma omp parallel num_threads(2) { #pragma omp for for(i= 0; i<simulations; i++) { x = static_cast<double>(rand())/RAND_MAX;; y = static_cast<double>(rand())/RAND_MAX;; if (((x*x)+(y*y))<=1) hit++; } }
3. Running your service
Make sure all you compute host source the environment for openMP executable. Environment configuration file is usually under $INTEL_INSTALLATION_DIR/bin


LinkBack URL
About LinkBacks
Reply With Quote
