code generation for reduction

General OpenMP discussion

code generation for reduction

Postby spkim » Tue Jan 29, 2008 12:09 pm


I'm wondering if there's any article or any published material that overviews code generation for OMP reduction (add or mul or other ops). Or if there's none available, can anyone briefly explain the code generation (compiler) technque for reductions? Thanks.

soohong p kim

Re: code generation for reduction

Postby lfm » Tue Jan 29, 2008 3:33 pm

Google might help with finding published material. Basically, the compiler creates a private copy of the reduction variable for each thread and initializes it to the identity. Each thread then does the accumulation into the private variable. This is pretty universal. Then, at the barrier, all the private copies are combined and the result is assigned to the original shared reduction variable.

The tricks happen in the combine; the obvious way to do it is with a critical section, but some runtimes use a tree structure or hardware assistance (like atomic operations or special combining networks). Also, there are issues with the nowait clause on barriers.

Have fun.

-- Larry
Posts: 135
Joined: Sun Oct 21, 2007 4:58 pm
Location: OpenMP ARB

Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 3 guests