Wednesday Sep 03, 2014

New Articles for Oracle Solaris Developers

Even though it was over 10 years ago, I still remember my side of the conversation with Jerry Jackson:

"Tuple? WTF is a Tuple?"

Jerry had just finished writing a language for building online insurance applications, and he was filling me in some of the gaps in my street urchin understanding of computer science. What I remember about Jerry's answer all these years later I can only paraphrase as:

"A tuple is like a grocery list. Except when it's not."

Although I've been focusing on content for sysadmins for the last few years, developers hold a special place in my heart. And Darryl Gove is one of the most generous with his knowledge. Not too long ago he teamed up with Steve Clamage to write several articles for OTN. Here are three of them:

Using the New C++ Array and Tuple Containers

by Darryl Gove and Steve Clamage

An array is equivalent to a traditional fixed length array in C++, but is accessible through standard container methods. A tuple is an ordered set of related elements of different types, such as one person's name, age, height, and so on. Both are new container types introduced in the C++11 Standard. Darryl and Steve explain what they are and how to use them.

How to Use Lambda Expressions in C++ 11

by Steve Clamage and Darryl Gove

Lambda expressions let you treat functions as objects, which means you can use them when you write a function that requires another function as one of its parameters. According to the authors, Lambdas are one of the defining features of the recent C++11 standard, and in this article they describe their syntax, how to pass them as pointers, and more.

Understanding the New Set and Map Containers in the C++ 11 Standard Library

by Darryl Gove and Steve Clamage

Map and set templates have been part of the C++ Standard Library since C++03. The C++11 Standard Library now includes templates for unordered maps and unordered sets. In some situations, the unordered versions can provide faster lookups than their ordered counterparts. Darryl and Steve explain.

About the Photograph

That's JimBob and El Jefe, two of my close riding buddies catching a little warmth from the sun outside of El Paso, Texas, during the now famous Durango Blizzard Ride of 2006. Will have to blog about that some day. They are tuple if there ever was one.

Follow Rick on:
Personal Blog | Personal Twitter | Oracle Community Profile
  Follow OTN Garage on:
Web | Facebook | Twitter | YouTube

Wednesday Jun 25, 2014

Helping Your Compiler Handle the Size of Your Constants

by Darryl Gove

When I use a constant in the following code, I get a warning:

On the other hand if I wrote:

Then then compiler will quite happily handle the constant.

The problem with the first bit of code is that it treats the value as a signed integer, and a signed integer can only hold 31 bits of precision plus a sign bit.

So how does the compiler decide how to represent a constant? The answer is interesting.

The compiler will attempt to fit a constant into the smallest value that it can. So it will try to fit the value into these types, in order: into an int, a long int, and then a long long int.

In the above code sample, the compiler will find that 1 and 31 both fit very nicely into signed ints. There's a shift left operation (<<) in the expression that produces a result of the same type as the left operand. So the whole expression (1<<31) has type signed int, which leads to the the warning.

To avoid the warning we can tell the compiler that this is an unsigned value. Either by typecasting the 1 to be unsigned in this manner:

or by declaring it as an unsigned value, like this:

More About Oracle Solaris Studio

Oracle Solaris Studio is a C, C++ and Fortran development tool suite, with compiler optimizations, multithread performance, and analysis tools for application development on Oracle Solaris, Oracle Linux, and Red Hat Enterprise Linux operating systems. Find out more about the Oracle Solaris Studio 12.4 Beta program here.

About the Photograph

Photograph of Zion National Park, Utah taken by Rick Ramsey in May 2014 on The Ride to the Sun Reunion.

- Darryl

Follow Darryl on:
Oracle Blog | Twitter
  Follow OTN Garage on:
Web | Facebook | Twitter | YouTube

Monday Feb 24, 2014

If Your Processor Stalls From a Read After Writer Operation ...

... rewrite your code. Better yet, write code that avoids this problem in the first place. The problem can occur when an application wants to load a value that it has just stored in memory. Read After Write (RAW) operations are common, so most chips are designed with hardware that makes that happen fast. But in some cases, you can write code that stumps the hardware. And so it stalls.

And you tumble to earth in horror, screaming for your life and clawing at the controls.

And you smack into the a pile of rocks. Or, to the horror of young mothers in minivans, the freeway during rush-hour traffic. Or worse, the middle of the ocean, so that if you somehow survive the impact, you drown. And nobody finds your body. And your loved ones can never move on.

Unless you're wearing a parachute. Like the one we just published from Darryl Gove.

Tech Article: Avoid Performance Loss (And a Fiery Death) from RAW Hazards

by Darryl Gove

Darryl explains exactly how a processor can stall from a bad RAW operation, and the common situations that cause this problem. Then he shows you how to identify, fix, and avoid writing that kind of code. Examples included. Help your loved ones move on. Read Darryl's article.

About the Author

Darryl Gove is a senior principal software engineer in the Oracle Solaris Studio team, working on optimizing applications and benchmarks for current and future processors. He is also the author of the books Multicore Application Programming, Solaris Application Programming, and The Developer's Edge.

Read Darryl Gove's blog on blogs.oracle.com/d.

Picture of radial engine taken by Rick Ramsey at Bay Area Aerospace Museum

- Rick

Follow me on:
Blog | Facebook | Twitter | YouTube | The Great Peruvian Novel

About

Contributors:
Rick Ramsey
Kemer Thomson
and members of the OTN community

Search

Archives
« August 2015
SunMonTueWedThuFriSat
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
     
Today
Blogs We Like