text:
Improving Data Dependence Analysis
In the data dependence problems considered so far, memory was accessed through a single variable. In general, however, compilers must be aware of complications that arise due to aliasing the situation where the same memory locations can be accessed through multiple variables. This situation is best illustrated with the following example:
Due to pointer arithmetic in C, the pointer variables
p and
q can be associated with identical or partially overlapping memory regions. This potential aliasing allows for data dependences in all directions, illustrated as follows with three different invocations of the function:
Because compilers make conservative assumptions about the possibility of such forms of aliasing in a program, usually inaccurate data dependence information results. The inaccuracy due to assumed data dependences can be remedied, however, with one or all of the following methods: compiler hints, aliasing analysis, and dynamic data dependence analysis.
Compiler Hints for Data Dependences
As an example of the first method, many compilers support the keyword
restrict that can be used to assert that a pointer variable provides exclusive access to its associated memory region. If function
copy() is only applied to distinct arrays, for example, this non-aliasing information can be conveyed to the compiler as follows. Note that using such a language extension may require an additional compiler switch, like
Even though compiler hints can improve the performance of a program in a relatively simple manner, hints must always be used with care since incorrect usage may ultimately cause an undesired change in semantics.
Aliasing Analysis
State-of-the-art compilers perform intraprocedural (within a single function) and interprocedural (between several or all functions in a program) aliasing analysis to gather information on all variables that could potentially provide access to the same memory locations. Simple approaches are based on the observation that only a variable whose address is taken can be associated with a pointer variable.
In the function
copy(), for instance, neither
n nor
i can be modified through pointer variables
p or
q, because the address of these local variables is never taken. More advanced approaches also analyze the way addresses propagate through the whole program. For example, if all calls to
copy() associate addresses of disjoint data structures to the formal arguments
p and
q, the compiler can safely discard the possibility of aliasing in this function.
Some programming languages pose further restrictions on aliasing. The Fortran standard, for example, states that as long as an actual argument is associated with more than one formal argument, no modifications to the actual argument may occur. This implies that potential data dependences between array accesses that use different formal array arguments can be safely discarded. Incorporating such language-specific restrictions in the alias analysis substantially improves the accuracy of the data dependences that are eventually reported. (A detailed presentation of aliasing analysis can be found in Muchnick's textbook Advanced Compiler Design and Implementation, Chapter 10)
Dynamic Data Dependence Analysis
In situations where the previous methods fail to resolve assumed data dependences, the compiler can resort to dynamic data dependence analysis, where the outcome of a run-time test decides between a data dependent and a data independent version of the same code, each of which is subsequently optimized accordingly. A simple overlap test is based on the observation that for two half open intervals
a,b,c,d ∈ ⊄ with
a < b and
c < d, the property
A∩ B ≠ ø ⇔ a < d ∧ c < b
defines a necessary and sufficient condition for overlap between
A and
B. This observation gives rise to the following method to resolve assumed data dependences in a well-behaved loop. First, for every memory reference in the loop, an approximated address interval of the accessed memory locations is constructed. Some sample address intervals for memory references through pointer
s32 *r in a well-behaved loop with index
i and upper bound
U are shown in Table 2.
Table 2: Sample address intervals for memory references.
Subsequently, for every pair of memory references in the loop that may cause a data dependence, the compiler generates code that tests overlap between the corresponding address intervals using the property described in the previous paragraph. The outcome of these run-time tests determines whether a data dependent or data independent version of the loop is executed.
For the function
copy() discussed earlier, for example, the assumed data dependences between
*p and
*q in the
i-loop can be resolved as follows.
Short-circuit evaluation of the condition ensures that the second loop is executed as soon as data independence has been proven. The compiler can eventually optimize this loop under the safe assumption of data independence. Although generating this kind of multi-version code can be very effective, a potential drawback of dynamic data dependence analysis is that the performance gains obtained by better optimization are outweighed by introducing testing overhead, since potentially every left-hand side memory reference has to be tested against every left-hand and right-hand side memory reference. Therefore, in general it is best to restrict dynamic data dependence analysis to loops with only a few memory references. Furthermore, even though the overlap test provides a convenient way to resolve assumed data dependences for memory references with simple subscripts, other sorts of run-time tests may be required to deal with more complicated situations, where approximated address intervals become too conservative.
Some programming languages pose restrictions on aliasing that can be exploited in the run-time tests. For example, because in Java programming language, reference variables which effectively are the same as pointer variables in C are either associated with disjoint or identical memory regions, an overlap test between two pointer variables can simply be done by testing equivalence of the two pointers, as exploited in some Java JIT compilers. The loop in function
copy() could even be vectorized unconditionally in Java, because the memory regions are either disjoint (
p != q) or equivalent (
p == q,) where the latter case gives rise only to the harmless loop-independent self-data-dependence:
As can be seen, the more developers are aware of data dependence in code that is executed often or needs optimal performance, the better the results will be.
Aart J.C. Bik is currently a Senior Staff Engineer at Intel Corporation, working on development of high performance Intel C++ and Fortran compilers. He received an Intel Achievement Award (the highest company award available) for his work in making Intel's Streaming SIMD Extensions 2 (SSE2) easier to use through automatic vectorization.
This article is based on material in Bik's book, The Software Vectorization Handbook, and it was edited by Andrew Binstock.


text:
I also got my Easter Bunnies finished and delivered to their recipients. I used this pattern and added my own twist to them. :)
And on a totally unrelated note, I have to share some of my critter pics. Last fall we had a dead tree that needed cutting. So my husband cut off the top of it, and turned it into a bird feeder. This made it high enough that the deer couldn't clean out the feeders each night. He also built a squirrel feeder for the squirrels. The first picture is from a few months ago. The squirrels found the feeder, but they apparently didn't realize it had food in it and they used it as a chair to sit on while eating out of the bird feeders. It took them a while, but as you can see in the 2nd pic, they finally figured out there was some good food in that chair of theirs. Then last week I glanced out the window and thought to myself "Wow, that is a big squirrel!". Upon closer inspection, I realized it was one of the neighborhood cats. She may have been bird hunting, but if so, she needs to work better at camouflaging herself, cause not one bird would come near the feeder the whole time she sat there. :)

subset: commoncrawl


text:
Some background... this is my second week in java and so far its going great in my comp sci class, but some of the eIMACS labs are killing me.
In the following code segment, a and b are non-negative doubles. Write code that assigns to b the result of rounding a to one decimal place.
// Enter a value to test here
double a = ;
double b;
// Enter your code here
I have tried to use Math.round(a,1); to round to one decimal place, its not working and i have no idea how to do it any other way, any help will be great.


text:
From the title alone, you can probably guess that John Rosemond's new book, "Parent-Babble: How Parents Can Recover from Fifty Years of Bad Expert Advice" (Andrews McMeel Publishing), isn't going to bring deafening cheers from the psychological community.
He doesn't care; he's more interested in getting a message out.
"I've been somewhat of an iconoclast for some time now," said Rosemond, who has been a licensed family psychologist for 40 years but these days devotes his time to writing, lecturing and generally stirring things up.
Rosemond believes that the changing society of the 1960s, when old methods were challenged and often rejected, led to a breakdown in parenting.
As a result, kids today, Rosemond says, are ill-behaved, impolite, beset with emotional problems and not as happy as kids were back in the 1950s. They're a mess.
"I realized in the late '70s, early '80s that a, psychological teaching was inadequate to explain human behavior, and b, a lot of theories proposed at that time were unsupported by research," he said recently from California, where he was speaking to several parents groups.
Rosemond's solution is a return to the child-raising strategies of 50 years ago. That's not what the authors of hundreds of contemporary "how to raise your kids" books might have in mind.
"Parenting books are a tremendously lucrative enterprise for publishers because of these neuroses that have been instilled in female parents," Rosemond said. "These books continuously raise the bar for parents."
He said that tried-and-true parenting methods are the answer. Society's willingness to try something new and unproven has failed, as evidenced in what he said is the unraveling of longtime values.
"Times always change with every generation," Rosemond said. "Every generation has brought innovation into civilization. The argument that we have to change is specious. ... when we became a fully fledged postmodern progressive culture, all that changed, in the 1960s."
What went wrong? And can 21st century society turn back the clock to 1955?
"You have to separate wheat from the chaff, which we didn't do," Rosemond said. "We embraced everything. We bought into the notion that we had to completely change the way to raise our children. No culture had ever done that before. People need to hold onto proven child-rearing principles in changing times.
"What I say in the book is we are not better off. These fundamental principles work — it doesn't matter if you use a cellphone or a landline, or if you drive the latest high-tech car or a 1960 Volkswagen. These principles work."
Two questions for John Rosemond
Q: New parents are always looking for answers. Where do they find them? Talking to others? Reading books?
A: Today's parents, moms especially, have become thoroughly confused by all the reading they do. Most of the mainstream parenting advice is contradictory, confusing and in many if not most cases, just downright bad. I think the best sources of advice are other parents who seem to be getting good results and older folks who possess the wisdom of experience.
Q: Are there one or two books you'd recommend for parents?
A: The only other author I recommend is Kevin Leman. Although he's a psychologist, he's a very practical guy with both feet on the ground.


text:
Charlie Sheen is formally handing over the keys to his warlock mansion to The Big Bang Theory actor Simon Helberg and his wife Jocelyn Towne. The couple reportedly scooped up Sheen's winning crib, located in the Los Feliz 'hood in Los Angeles, for an estimated $2.9 million.
The swanky mansion where Sheen undoubtedly hosted many a goddess measures 4,179 square feet and boasts 4 bedrooms, 4.5 bathrooms, wood-beamed ceilings, a raised library, a variety of outdoor entertainment terraces, and of course, no goddess mansion would be complete without a luxe swimming pool. Sheen bought this house in 2007 aka his pre-tiger-blood days for $2.575 million.
U.S. & World
Helberg, who plays Howard on The Big Bang Theory, is seriously upgrading his digs. Just last week, he listed his lovely, anything-but-eye-catching craftsman for $849,000. For Helberg's sake, let's hope Sheen remembered to pack up all of his warlock, goddess and tiger blood contraband.
Copyright LXTVN - LXTV


text:
Baseball Capsules
NEW YORK (AP) — Jacob deGrom had a tiebreaking single and again shut down the Marlins with seven impressive innings, David Wright doubled twice and drove in two runs, and the New York Mets completed a three-game sweep of Miami with a 9-1 victory on Sunday.
Wright, Curtis Granderson and Juan Lagares each had RBI doubles, and Chris Young added a sacrifice fly for New York in its eighth win on a 10-game homestand heading into the All-Star break.
New York jumped over the Marlins, losers of four straight, and into third place in the NL East at 45-50.
DeGrom (3-5), who pitched seven innings in Miami for his first big league victory on June 21, struck out eight and allowing five hits and a run.
DeGrom got his first big league RBI after Brad Hand (0-2) intentionally walked Ruben Tejada to face the lanky former college shortstop. DeGrom lined a single to center for a 2-1 lead.
PHILADELPHIA (AP) — Jayson Werth homered and drove in four runs, and Tanner Roark pitched seven strong innings to lead Washington over Philadelphia.
Ryan Zimmerman also went deep and had two RBIs, Ian Desmond knocked in two runs, and Anthony Rendon had three hits and an RBI for Washington, which won the last two games of the series and stayed tied with Atlanta atop the NL East entering the All-Star break.
Philadelphia scored two unearned runs off Aaron Barrett in the ninth to end with three runs or fewer for the 49th time this season.
Roark (8-6) allowed a run and four hits. He struck out six and walked none.
The Phillies dropped to 8-41 overall and 2-29 in their last 31 games when failing to score four runs. Cody Asche had two doubles and an RBI for Philadelphia, which fell 10 games behind Washington.
It was the second straight defeat for Philadelphia after a five-game winning streak.
Kyle Kendrick (4-9) continued his pattern of struggling badly in the first inning and then pitching well. The Nationals' first three batters scored on Werth's homer.
CHICAGO (AP) — Chris Johnson had three hits, including his third homer in two days, and Atlanta beat the Chicago Cubs to stay in a virtual tie with Washington for first place in the NL East.
Although even in terms of games back, the Braves are one percentage point behind the Nationals. Atlanta (52-43) has won three of four since a four-game losing streak.
Johnson hit a long drive to straightaway center field for a three-run shot in a four-run third inning against Travis Wood (7-8).
Atlanta played without struggling second baseman Dan Uggla, who was suspended by the team for the final game before the All-Star break.
Arismendy Alcantara and Chris Coghlan each hit a two-run homer off All-Star Julio Teheran (9-6) for the last-place Cubs, who have lost eight of 10.
HOUSTON (AP) — Clay Buchholz allowed three hits and struck out a career-high 12 in his fifth career shutout in Boston's rout of Houston.
Brock Holt had a career-best five hits, including a leadoff homer, to help the Red Sox to their fourth victory in five games heading into the All-Star break.
All of the hits Buchholz (4-5) allowed were singles, and he didn't walk a batter in his first shutout since June 2, 2013, against the Yankees.
Chris Carter extended his career-high hitting streak to nine games with a single with one out in the fourth. Buchholz sailed through the rest of the game, retiring his last 17 batters.
Holt, who played at Rice, launched a 92 mph fastball from Brad Peacock (3-6) into the seats in right field to give Boston an early lead.
Peacock couldn't locate his pitches and was done after getting just one out, forcing Houston to use five relievers to finish the game.
Rookie Christian Vazquez had two hits and two RBIs to help the Red Sox score a season-high 11 runs.
CLEVELAND (AP) — Yan Gomes' two-run homer in the eighth inning gave Cleveland a win over the Chicago White Sox.
Gomes drove in all three Cleveland runs. His home run to right off Javy Guerra (0-2) came after the White Sox scored two runs in top of the inning to take a 2-1 lead.
Nick Swisher led off with a single before Gomes, who also had an RBI single in the second, hit a 1-1 pitch into Chicago's bullpen.
Bryan Shaw (4-1) allowed two runs in the top of the eighth. Cody Allen pitched the ninth for his 12th save, striking out the final two hitters.
Trevor Bauer struck out a career-high 10 in 6 2-3 scoreless innings for Cleveland.
ST. PETERSBURG, Fla. (AP) — All-Star David Price scattered five hits in eight-plus innings to win his fourth consecutive start and Tampa Bay beat Toronto.
Price (9-7), who had his start pushed back one day because of a stomach virus, struck out five and walked one. The left-hander was pulled after giving up a leadoff single in the ninth to Melky Cabrera.
Because Price pitched on Sunday, he is ineligible to play in the All-Star game Tuesday night in Minnesota.
The Rays, who have won 11 of 15, got RBI singles from Logan Forsythe and Jose Molina. Jake McGee got three outs for his seventh save.
R.A. Dickey (7-9) gave up two runs and five hits over six innings. Toronto has not won a road series against Tampa Bay since April 2007, a span of 22 sets.
Toronto has lost eight of 10 overall.
KANSAS CITY, Mo. (AP) — Eric Hosmer's RBI double capped a five-run seventh inning and Kansas City avoided a four-game sweep with a victory over Detroit.
Four of the runs were charged to Justin Verlander (8-8), who started the inning with a two-hit shutout but loaded the bases on three straight singles.
The come-from-behind win still leaves the second-place Royals 6½ games behind the Tigers in the AL Central.
Since June 18 when K.C. beat the Tigers for their 10th straight win and went a season-best seven games over .500, the Royals have gone 9-14 while the Tigers went 17-6.
Verlander gave up six hits in 6 1/3 innings, struck out three and walked one.
Yordano Ventura (7-7) pitched 1 2/3 innings in his first career relief appearance and got the win. Greg Holland pitched a perfect ninth for his 25th save in 26 opportunities.
ARLINGTON, Texas (AP) — Mike Trout doubled twice and drove in four runs as the Los Angeles Angels beat Texas and took a five-game winning streak into the All-Star break.
Texas (38-57) lost its eighth in a row and has the worst record in the majors.
Trout, who will start the All-Star game in the AL outfield, sent three runs home by blooping a two-out double in the second inning. He broke a 4-all tie with a double in the fourth.
The Angels, a major league-best 26-9 since June 6, swept a four-game series against Texas for the first time in their history.
Tyler Skaggs (5-5) left after giving up two singles to start the sixth.
Joe Smith pitched a perfect ninth inning for his 15th save in 19 opportunities. He set an Angels record with his 10th consecutive appearance of at least an inning without allowing a hit.
Scott Baker (0-3) lost in his fourth start for Texas. Alex Rios drove in three runs.
CINCINNATI (AP) — Kris Negron hit his first career home run, and All-Star Todd Frazier added a two-run shot as Cincinnati rolled into the break with a win against Pittsburgh.
Negron, called up from Triple-A Louisville on Thursday for his first appearance in the majors since playing four games in 2012, celebrated his first major league start with a three-run homer off Francisco Liriano (1-7) in the second inning. The RBIs were also the first of his career, and the hit was his second.
Frazier homered on the first pitch from Vance Worley in the sixth to send the Pirates to a 2-5 mark on their trip.
The Reds went 8-3 on their 11-game homestand against Milwaukee, the Chicago Cubs and Pittsburgh to finish the first half 10-0-1 in series against those Central Division-opponents.
Johnny Cueto (10-6), another Reds All-Star, overcame Neil Walker's home run and a 56-minute rain delay in the fifth to last six innings. Aroldis Chapman struck out the side in the ninth for his 21st save. Chapman has struck out a batter in 41 straight appearances.
MILWAUKEE (AP) — Elian Herrera got five hits while filling in for mourning shortstop Jean Segura, and Milwaukee ended a seven-game losing streak by routing St. Louis.
The Brewers tied a season high with 19 hits and took a one-game lead over St. Louis in the NL Central at the All-Star break.
Herrera was called up from the minors Saturday when Segura was put on the bereavement list after the death of his 9-month-old son. Herrera went 5 for 5 with a double and scored three runs.
Wily Peralta (10-6) tossed seven strong innings for the win. A frustrated Carlos Martinez (2-4) allowed four runs in four innings.
Peralta allowed just three singles and gave up his only run after Kolten Wong reached first on a passed ball despite striking out.
Martinez, making his seventh career start, gave up three walks and a balk and hit Carlos Gomez with a pitch in the fourth.
The Brewers are in first place at the break for the fourth time in franchise history.
SAN FRANCISCO (AP) — Madison Bumgarner became the first pitcher in 48 years to hit two grand slams in a season, and Buster Posey also hit a slam that boosted San Francisco over Arizona.
Posey and Bumgarner became the first batterymates in major league history to hit grand slams in the same game.
A double by Bumgarner helped set up Posey's slam in the fifth. Bumgarner homered the next inning — he also hit a slam on April 11 against Colorado.
The last pitcher to launch two slams in a season was Tony Cloninger, who hit both in the same game for Atlanta on July 3, 1966, against the Giants.
Bumgarner (10-7) threw 6 1-3 innings to end his three-game losing streak. Vidal Nuno (0-1) allowed four runs and six hits in five innings during his second start with Arizona.
The Giants finished the first half by winning five of nine. That followed a stretch of 18 losses in 23 games that cost them their lead in the NL West.
Cody Ross hit a two-run homer for the Diamondbacks, 5-8 in their past 13 games.
SEATTLE (AP) — Sonny Gray limited Seattle to six hits and one unearned run in Oakland's victory.
Gray (10-3) earned his 10th victory and Sean Doolittle recorded the final four outs for his 14th save.
After managing just one hit off Seattle starter Chris Young through four innings, the Athletics broke through in the fifth. Brandon Moss hit his 21st home run to extend the A's lead to 3-1 in the sixth.
Young (8-6) allowed three runs and five hits with just one walk and two strikeouts for Seattle.
Nick Punto added a solo homer off Joe Beimel in the ninth for the Athletics.
LOS ANGELES (AP) — Hyun-Jin Ryu struck out 10 and outpitched first-time All-Star Tyson Ross, and Yasiel Puig singled home the only run in the Los Angeles Dodgers' win over San Diego.
A day after beating the Padres 1-0, the Dodgers did it again and took a one-game lead over San Francisco in the NL West into the All-Star break.
Puig struck out his first two times up, then singled home Dee Gordon in the sixth inning.
Ryu (10-5) gave up two hits in six innings without a walk.
Kenley Jansen struggled to get his 27th save, striking out Jake Goebbert and pinch-hitter Seth Smith with runners at the corners.
Ross (7-10) gave up six hits in seven innings, striking out nine and walking one.
DENVER (AP) — Brian Dozier cranked up for the Home Run Derby at the All-Star game with two homers, and Minnesota beat Colorado.
Dozier hit a solo homer in the eighth and added a three-run shot an inning later for his first career multihomer game.
Late fill-in Chris Parmelee ignited a five-run first inning for the Twins with a two-run single. He replaced outfielder Oswaldo Arcia, who was scratched with the flu.
Hughes (10-5) earned his 10th win despite allowing five runs and 10 hits in five innings.
Brett Anderson (0-3) was rusty in his first outing since April as he allowed six runs — five earned — in five innings.
BALTIMORE (AP) — Chris Davis hit a two-run homer to back a strong pitching effort by Kevin Gausman, and the Baltimore Orioles beat the New York Yankees in a game called by rain after 4 1/2 innings.
The Orioles scored all their runs in the fourth inning and Gausman (4-2) got three straight outs in the fifth. After Steve Pearce drew a walk in the bottom half, the rain came. The game was finally called after a delay of 2 hours, 22 minutes.
Gausman allowed four hits, struck out two and walked none in his first major league complete game.
Brett Gardner hit a leadoff homer for New York, but the Yankees didn't get a runner past first base the rest of the way. New York starter Chase Whitley (4-3) gave up three runs and five hits in 3 2-3 innings.