Shared Memory Application Programming by Alessandrini Victor;
Author:Alessandrini, Victor; [Alessandrini, Victor]
Language: eng
Format: epub
Publisher: Elsevier Science
Published: 2015-11-07T00:00:00+00:00
Comments on data-sharing clauses
Consider first the shared clause: as stated above variables tagged as shared behave as global variables for the duration of the construct. It looks as if OpenMP was promoting a private local variable in the parent task to a global status. In fact, this is not really needed, because shared does not necessarily means global: shared only means that all worker threads have been granted access the original local variable sitting in the parent thread stack. For this to happen, it is sufficient that the parent thread publishes its local data by passing to other threads a pointer to it. Therefore, when a shared variable occurs in a task code block, the compiler is really implementing a pointer or a reference to the parent task local data. This explains a statement often found in the literature: local data items in the parent task tagged as firstprivate are captured by value, and those tagged shared are captured by reference.
Consider next the reduction clause. Listing 10.5 shows how it operates. Let us assume that partial results computed by the worker threads need to be accumulated. This was often done this in the past by asking the worker threads to accumulate their partial results in a mutex-protected global variable. OpenMP can perform the required reduction directly, as shown.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Linux Device Driver Development Cookbook by Rodolfo Giometti(3932)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3576)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3512)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3340)
TinyML Cookbook by Gian Marco Iodice(3286)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2837)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2601)
Fusion 360 for Makers by Lydia Sloan Cline(2219)
Networking A Beginner's Guide by Bruce Hallberg(2208)
Hands-On Linux for Architects by Denis Salamanca(2051)
But How Do It Know? by J. Clark Scott(2030)
Computers For Seniors For Dummies by Nancy C. Muir(1995)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1949)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1947)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1897)
Hack and HHVM by Owen Yamauchi(1884)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1858)
MicroPython Projects by Jacob Beningo(1728)
Hands-On Internet of Things with MQTT by Tim Pulver(1702)
