<< Chapter < Page Chapter >> Page >

Imagine a symphony orchestra where each musician plays without regard to the conductor or the other musicians. At the first tap of the conductor’s baton, each musician goes through all of his or her sheet music. Some finish far ahead of others, leave the stage, and go home. The cacophony wouldn’t resemble music (come to think of it, it would resemble experimental jazz) because it would be totally uncoordinated. Of course this isn’t how music is played. A computer program, like a musical piece, is woven on a fabric that unfolds in time (though perhaps woven more loosely). Certain things must happen before or along with others, and there is a rate to the whole process.

With computer programs, whenever event A must occur before event B can, we say that B is dependent on A. We call the relationship between them a dependency. Sometimes dependencies exist because of calculations or memory operations; we call these data dependencies . Other times, we are waiting for a branch or do-loop exit to take place; this is called a control dependency . Each is present in every program to varying degrees. The goal is to eliminate as many dependencies as possible. Rearranging a program so that two chunks of the computation are less dependent exposes parallelism , or opportunities to do several things at once.

Control dependencies

Just as variable assignments can depend on other assignments, a variable’s value can also depend on the flow of control within the program. For instance, an assignment within an if-statement can occur only if the conditional evaluates to true. The same can be said of an assignment within a loop. If the loop is never entered, no statements inside the loop are executed.

When calculations occur as a consequence of the flow of control, we say there is a control dependency , as in the code below and shown graphically in [link] . The assignment located inside the block-if may or may not be executed, depending on the outcome of the test X .NE. 0. In other words, the value of Y depends on the flow of control in the code around it. Again, this may sound to you like a concern for compiler designers, not programmers, and that’s mostly true. But there are times when you might want to move control-dependent instructions around to get expensive calculations out of the way (provided your compiler isn’t smart enough to do it for you). For example, say that [link] represents a little section of your program. Flow of control enters at the top and goes through two branch decisions. Furthermore, say that there is a square root operation at the entry point, and that the flow of control almost always goes from the top, down to the leg containing the statement A=0.0 . This means that the results of the calculation A=SQRT(B) are almost always discarded because A gets a new value of 0.0 each time through. A square root operation is always “expensive” because it takes a lot of time to execute. The trouble is that you can’t just get rid of it; occasionally it’s needed. However, you could move it out of the way and continue to observe the control dependencies by making two copies of the square root operation along the less traveled branches, as shown in [link] . This way the SQRT would execute only along those paths where it was actually needed.

Questions & Answers

what is economic integration
Mohamed Reply
why does it makes sense to let the sewage disposal company in your town have a monopoly?
Janice Reply
how might a monopoly affect price?
how might a monopoly affect prices?
The principle of Economic is one to be involved in any economic buying substance
Anastassiya Reply
reason of corporation
What is economic integration
what are the principle of economics?
oche Reply
What is (Qs)
Bigi Reply
What is (Qs) and (Qd)
Quantity of supply and Quantity of demand
Qs: Is quantity of supply and Qd: quantity of demand
give as me quantitys
among all the definition of economics which of the definition is generally acceptable?
i science that studies human behavior as a relationship between ends and scarcity that have alternative uses
what are the principle of economics?
what Make things scarce
Soudani Reply
why do we studied economic
for the stability and growth of any reign.
what is macro economics.?
which part of economics is interesting..
what is economic integration
can somebody defined economic stability
macroeconomic is the part of economic that deals the as whole or as a nations.
how does economics define me
clement Reply
what are the factors that determines the demand and supply
what are the importance of Economics
Betty Reply
tell me something very important about economics..
Fayaz Reply
how may I solve arithmetic mean ,,,all example
Cee Reply
what is agriculture
Itoe Reply
simple method of understanding cost concept
Oludare Reply
what is inflation
Christiana Reply
Inflation is a general increase in price levels
is the action of inflating something
inflation is the persistent increase in general price level of goods and services in an economy over a considerable period of time .
inflation is the general increase of a commodity in a particular period of time.
inflation is a general increase in price levels of commodities
what are the types of inflation?
inflation is the period of persistent rise in the general level of the price of goods services over time
we have creeping inflation, demand pull inflation ,cost push inflation, and galloping inflation .
I s Nigeria in any kind of in inflation? If yes which kind?
please can someone help me with the principles of economic?
and u
no discassion just question
what is science and art economic
how can a location of a firm create difference between producers
joy Reply
what is monetary policy
is a monetary from policy that's authorized of country encharces
What would you say about the the mobility of enterprise as a factor of production?
Cathryn Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, High performance computing. OpenStax CNX. Aug 25, 2010 Download for free at http://cnx.org/content/col11136/1.5
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'High performance computing' conversation and receive update notifications?