<< Chapter < Page Chapter >> Page >

If it were all that simple, you wouldn’t need this book. While compilers are extremely clever, there is still a lot of ways to improve the performance of your code without sacrificing its portability. Instead of converting the whole program to C and using a thread library, you can assist the compiler by adding compiler directives to our source code.

Compiler directives are typically inserted in the form of stylized FORTRAN comments. This is done so that a nonparallelizing compiler can ignore them and just look at the FORTRAN code, sans comments. This allows to you tune your code for parallel architectures without letting it run badly on a wide range of single-processor systems.

There are two categories of parallel-processing comments:

  • Assertions
  • Manual parallelization directives

Assertions tell the compiler certain things that you as the programmer know about the code that it might not guess by looking at the code. Through the assertions, you are attempting to assuage the compiler’s doubts about whether or not the loop is eligible for parallelization. When you use directives, you are taking full responsibility for the correct execution of the program. You are telling the compiler what to parallelize and how to do it. You take full responsibility for the output of the program. If the program produces meaningless results, you have no one to blame but yourself.

Assertions

In a previous example, we compiled a program and received the following output:


E6000: f77 -O3 -autopar -loopinfo -o dep dep.f dep.f:"dep.f", line 6: not parallelized, call may be unsafe "dep.f", line 8: not parallelized, unsafe dependence (a)E6000:

An uneducated programmer who has not read this book (or has not looked at the code) might exclaim, “What unsafe dependence, I never put one of those in my code!” and quickly add a no dependencies assertion. This is the essence of an assertion. Instead of telling the compiler to simply parallelize the loop, the programmer is telling the compiler that its conclusion that there is a dependence is incorrect. Usually the net result is that the compiler does indeed parallelize the loop.

We will briefly review the types of assertions that are typically supported by these compilers. An assertion is generally added to the code using a stylized comment.

No dependencies

A no dependencies or ignore dependencies directive tells the compiler that references don’t overlap. That is, it tells the compiler to generate code that may execute incorrectly if there are dependencies. You’re saying, “I know what I’m doing; it’s OK to overlap references.” A no dependencies directive might help the following loop:


DO I=1,N A(I) = A(I+K) * B(I)ENDDO

If you know that k is greater than -1 or less than -n , you can get the compiler to parallelize the loop:


C$ASSERT NO_DEPENDENCIES DO I=1,NA(I) = A(I+K) * B(I) ENDDO

Of course, blindly telling the compiler that there are no dependencies is a prescription for disaster. If k equals -1 , the example above becomes a recursive loop.

Relations

You will often see loops that contain some potential dependencies, making them bad candidates for a no dependencies directive. However, you may be able to supply some local facts about certain variables. This allows partial parallelization without compromising the results. In the code below, there are two potential dependencies because of subscripts involving k and j:

Questions & Answers

What is price elasticity of demand and its degrees. also explain factors determing price elasticity of demand?
Yutansh Reply
Price elasticity of demand (PED) is use to measure the degree of responsiveness of Quantity demanded for a given change on price of the good itself, certis paribus. The formula for PED = percentage change in quantity demanded/ percentage change in price of good A
GOH
its is necessarily negative due to the inverse relationship between price and Quantity demanded. since PED carries a negative sign most of the time, we will usually the absolute value of PED by dropping the negative sign.
GOH
PED > 1 means that the demand of the good is price elasticity and for a given increase in price there will be a more then proportionate decrease in quantity demanded.
GOH
PED < 1 means that the demand of the good is price inelasticity and for a given increase in price there will be a less then proportionate decrease in quantity demanded.
GOH
The factors that affects PES are: Avaliablilty of close substitutes, proportion of income spent on the good, Degree of necessity, Addiction and Time.
GOH
Calculate price elasticity of demand and comment on the shape of the demand curve of a good ,when its price rises by 20 percentage, quantity demanded falls from 150 units to 120 units.
Helen Reply
5 %fall in price of good x leads to a 10 % rise in its quantity demanded. A 20 % rise in price of good y leads to do a 10 % fall in its quantity demanded. calculate price elasticity of demand of good x and good y. Out of the two goods which one is more elastic.
Helen
what is labor
Grace Reply
labor is any physical or mental effort that helps in the production of goods and services
Kwabena
what is profit maximizing level of out put for above hypothetical firm TC = Q3 - 21Q2 + 600 + 1800 P = 600 MC = 3Q2 - 42Q + 600
Sosna Reply
consider two goods X and Y. When the price of Y changes from 10 to 20. The quantity demanded of X changes from 40 to 35. Calculate cross elasticity of demand for X.
Sosna
sorry it the mistake answer it is question
Sosna
consider two goods X and Y. When the price of Y changes from 10 to 20. The quantity demanded of X changes from 40 to 35. Calculate cross elasticity of demand for X.
Sosna
The formula for calculation income elasticity of demand is the percent change in quantity demanded divided by the percent change in income.
Sosna
what is labor productivity
Lizzy Reply
if the demand function is q=25-4p+p² 1.find elasticity of demand at the point p=5?
Puja Reply
what are some of the difference between monopoly and perfect competition market
Obeng Reply
n a perfectly competitive market, price equals marginal cost and firms earn an economic profit of zero. In a monopoly, the price is set above marginal cost and the firm earns a positive economic profit. Perfect competition produces an equilibrium in which the price and quantity of a good is economic
Naima
what are some characteristics of monopoly market
Obeng Reply
explicit cost is seen as a total experiences in the business or the salary (wages) that a firm pay to employee.
Idagu Reply
what is price elasticity
Fosua
...
krishna
it is the degree of responsiveness to a percentage change in the price of the commodity
Obeng
economics is known to be the field
John Reply
what is monopoly
Peter Reply
what is taxation
Peter
is the compulsory transfer of wealth from the private sector to the public sector
Jonna
why do monopoly make excess profit in both long run and short run
Adeola Reply
because monopoly have no competitor on the market and they are price makers,therefore,they can easily increase the princes and produce small quantity of goods but still consumers will still buy....
Kennedy
how to identify a perfect market graph
Adeola Reply
what is the investment
jimmy
investment is a money u used to the business
Mohamed
investment is the purchase of good that are not consumed today but are used in the future to create wealth.
Amina
investment is the good that are not consumed
Fosua
What is supply
Fosua
 Supply represents how much the market can offer.
Yusif
it is the quantity of commodity producers produces at the market
Obeng
what is the effect of scarce resources on producers
Phindu Reply
explain how government taxes and government producer subsidies affect supply
Chanda
what is economic
Charles Reply
what are the type of economic
Charles
macroeconomics,microeconomics,positive economics and negative economics
Gladys
what are the factors of production
Gladys
process of production
Mutia
Basically factors of production are four (4) namely: 1. Entrepreneur 2. Capital 3. Labour and; 4. Land but there has been a new argument to include an addition one to the the numbers to 5 which is "Technology"
Elisha
what is land as a factor of production
Gladys
what is Economic
Abu
economics is how individuals bussiness and governments make the best decisions to get what they want and how these choices interact in the market
Nandisha
Economics as a social science, which studies human behaviour as a relationship between ends and scarce means, which have alternative uses.
Yhaar
Economics is a science which study human behaviour as a relationship between ends and scarce means
John
Economics is a social sciences which studies human behavior as a relationship between ends and scarce mean, which have alternative uses.....
Pintu
A soccer field is a rectangle 130 meters wide and 110 meters long. The coach asks players to run from one corner to the other corner diagonally across. What is that distance, to the nearest tenths place.
Kimberly Reply
Jeannette has $5 and $10 bills in her wallet. The number of fives is three more than six times the number of tens. Let t represent the number of tens. Write an expression for the number of fives.
August Reply
What is the expressiin for seven less than four times the number of nickels
Leonardo Reply
How do i figure this problem out.
how do you translate this in Algebraic Expressions
linda Reply
why surface tension is zero at critical temperature
Shanjida
I think if critical temperature denote high temperature then a liquid stats boils that time the water stats to evaporate so some moles of h2o to up and due to high temp the bonding break they have low density so it can be a reason
s.
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
Crystal Reply
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
Chris 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?

Ask