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.
Building Low Latency Applications with C++ by Sourav Ghosh(2934)
Fusion 360 for Makers by Lydia Sloan Cline(1987)
Networking A Beginner's Guide by Bruce Hallberg(1933)
But How Do It Know? by J. Clark Scott(1817)
Computers For Seniors For Dummies by Nancy C. Muir(1769)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1755)
Hands-On Linux for Architects by Denis Salamanca(1738)
Hack and HHVM by Owen Yamauchi(1676)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1665)
MicroPython Projects by Jacob Beningo(1473)
PrestaShop Recipes by Arnaldo Pérez Castaño(1467)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1456)
Hands-On Internet of Things with MQTT by Tim Pulver(1417)
Raspberry Pi Electronics Projects for the Evil Genius (Tab) by Norris Donald & Norris Donald(1384)
Getting Started with Soldering: A Hands-On Guide to Making Electrical and Mechanical Connections by Vinck Marc de(1379)
Embedded Systems Architecture by Daniele Lacamera(1377)
Healthcare Information Security and Privacy (All-In-One) by Sean Murphy(1370)
Shaping the Fourth Industrial Revolution by Klaus Schwab & Nicholas Davis & Satya Nadella(1358)
Mastering Kubernetes by Gigi Sayfan(1349)