Date: Wed, 01 Feb 2012 16:29:59 -0800 From: Dennis Glatting <freebsd@pki2.com> To: Anton Shterenlikht <mexas@bristol.ac.uk> Cc: freebsd-questions@freebsd.org Subject: Re: OpenMP on FreeBSD Message-ID: <1328142599.53835.6.camel@btw.pki2.com> In-Reply-To: <20120202000947.GA71405@mech-cluster241.men.bris.ac.uk> References: <20120202000947.GA71405@mech-cluster241.men.bris.ac.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 2012-02-02 at 00:09 +0000, Anton Shterenlikht wrote: > I'm new to OpenMP. I wonder > if there are any special considerations > when running OpenMP on FreeBSD? > I run OpenMP. No special consideration. Here's a chunk from my Makefile: TARG=ecc.enc ecc.dec $TARG: *.cc *.h Makefile g++ -Wall -fopenmp -g -O ${INCL} ${LIBS} -o ecc.enc *.cc g++ -Wall -fopenmp -g -O ${INCL} ${LIBS} -o ecc.dec *.cc > For example, I have this OMP parallelised > fortran program, nested do loops, compiled > with gfortran46. When I run it with 2 threads > on a 2-cpu box, I see in top(1): > > PID UID PRI NICE SIZE RES STATE C TIME CPU COMMAND > 63995 1001 89 0 57048K 34272K CPU1 1 1:06 55.08% dummy.sx{dummy.sx} > 63995 1001 87 0 57048K 34272K RUN 1 1:02 52.39% dummy.sx{dummy.sx} > 11 0 155 ki31 0K 32K RUN 0 376:58 51.46% idle{idle: cpu0} > 11 0 155 ki31 0K 32K RUN 1 368:18 45.36% idle{idle: cpu1} > > I wonder why, even after a minute of run time, > I still have nearly a whole cpu idle? > What is the program doing? I/O can significantly limit OMP value. Also, you need to make sure you code your loops properly or else you have a single-threaded application, without warning. > As a result the run time with 2 threads > is nearly identical to run time with 1 thread. > > It's likely that I'm not using OMP correctly, > but I wanted to check if there are any > special FreeBSD related issues to bear > in mind when coding with OMP. > As an example, this is one of my key sections of code in C++. It works. I can't say for Fortran. #pragma omp parallel { #pragma omp for for( size_t i = 0; i < bq.size(); ++i ) { Block& b = bq[ i ]; // Adjust any padding. // if( b.size() != b.szSYMS ) { eofPad = ( b.szSYMS - b.size()); for( ssize_t j = b.size(); j < b.szSYMS; ++j ) b.syms()[ j ] = eofPad; if( verbose ) fprintf( stderr, "Padding: read=%ld, pad=%d\n", b.size(), eofPad ); b.size( b.szSYMS ); } // Encode the buffer. // encode_rs_8( b.syms(), b.parity(), 0 ); // Set it to its new size. // (the encoder is an outside routine.) // b.size( b.szBLOCK ); // Interleave the buffer. // add_interleave( b.buf()); } /* for */ } /* pragma */ > Thanks >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1328142599.53835.6.camel>