Category Archives: Software Engineering

Welcome to Herb Sutter’s Jungle

In an effort to keep posting something here until I’m in the right place mentally to write about things that probably interest you, my dear friends, family, and online diabetes peeps, here’s another computing performance excerpt and link. (Working on this stuff is the 9-5 part of your favorite international playboy’s life.)


A half-decade after Herb Sutter wrote that the “free lunch” of Moore’s Law is over, he’s back with his prophet’s wisdom about where we’re going in his January Dr. Dobbs article, “Welcome to the Jungle”. I’ll give you a moment to decide whether to get the Guns N’ Roses song out of your head or use it as a backdrop for this juicy quotation:

If hardware designers merely use Moore’s Law to deliver more big fat cores, on-device hardware parallelism will stay in double digits for the next decade, which is very roughly when Moore’s Law is due to sputter, give or take about a half decade. If hardware follows Niagara’s and MIC’s lead to go back to simpler cores, we’ll see a one-time jump and then stay in triple digits. If we all learn to leverage GPUs, we already have 1,500-way parallelism in modern graphics cards (I’ll say “cores” for convenience, though that word means something a little different on GPUs) and likely reach five digits in the decade timeframe.

But all of that is eclipsed by the scalability of the cloud, whose growth line is already steeper than Moore’s Law because we’re better at quickly deploying and using cost-effective networked machines than we’ve been at quickly jam-packing and harnessing cost-effective transistors. It’s hard to get data on the current largest cloud deployments because many projects are private, but the largest documented public cloud apps (which don’t use GPUs) are already harnessing over 30,000 cores for a single computation. I wouldn’t be surprised if some projects are exceeding 100,000 cores today. And that’s general-purpose cores; if you add GPU-capable nodes to the mix, add two more zeroes.

The big takeaway for software engineers like me is that we’d best be learning how to develop solutions using the emerging APIs so that we can harness all of those extra orders of magnitude of scalability. That involves figuring out how to . . .

  • Deal with the processor axis’ lower section [of Sutter's chart] by supporting compute cores with different performance (big/fast, slow/small).
  • Deal with the processor axis’ upper section by supporting language subsets, to allow for cores with different capabilities including that not all fully support mainstream language features.
  • Deal with the memory axis for computation, by providing distributed algorithms that can scale not just locally but also across a compute cloud.
  • Deal with the memory axis for data, by providing distributed data containers, which can be spread across many nodes.
  • Enable a unified programming model that can handle the entire [memory/locality/processor] chart with the same source code.

Perhaps our most difficult mental adjustment, however, will be to learn to think of the cloud as part of the mainstream machine — to view all these local and non-local cores as being equally part of the target machine that executes our application, where the network is just another bus that connects us to more cores. That is, in a few years we will write code for mainstream machines assuming that they have million-way parallelism, of which only thousand-way parallelism is guaranteed to always be available (when out of WiFi range). . . .

If you haven’t done so already, now is the time to take a hard look at the design of your applications, determine what existing features — or better still, what potential and currently unimaginable demanding new features — are CPU-sensitive now or are likely to become so soon, and identify how those places could benefit from local and distributed parallelism. Now is also the time for you and your team to grok the requirements, pitfalls, styles, and idioms of hetero-parallel (e.g., GPGPU) and cloud programming (e.g., Amazon Web Services, Microsoft Azure, Google App Engine).


p.s. — I can’t believe that it’s been almost four years since I took a course with Herb out in Washington. That was some hard-core learnin’.

Posted in Computing, Fodder for Techno-weenies, Software Engineering | Leave a comment

We Need a New Mindset

Guy Steele drops a truth bomb.

(From How to Think about Parallel Programming: Not!)

Posted in Computing, Fodder for Techno-weenies, Software Engineering | Leave a comment

Thinking Differently about Software Optimization

Yesterday morning while eating my “Free Wednesday Breakfast” chocolate croissant and fresh fruit with yoghurt, I watched an interview with John Nolan entitled “The State of Hardware Acceleration with GPUs/FPGAs, Parallel Algorithm Design.” In the spirit of giving back, I’m posting a few notes.

  • When optimizing code for GPU, FPGA, or CPU, definitely focus on pipelining and overall throughput, not just local optimizations.
  • There’s a trade-off between “faster” and “sooner.” It’s not always worth saving a few seconds (or even a few minutes) if the kernels take hours or days to compile. (Then again, sometimes it is.)
  • Try to reduce dependence on the language/compiler “stack” that removes inefficiencies. The optimizer does good work, but you can do things to help it. Think about the hardware or architecture format. It’s not a sin to reduce the amount of abstraction in the service of performance. Pay attention to things that affect processor pipelining and cache movement.
  • BTW, some languages and technologies exist to provide higher level programming that’s close to the hardware, but they’re proprietary, secret, or still in R&D.
  • Use algorithmic optimization techniques. Step back and find the shortest-time computation.
  • Avoid using if statements. The goto construct is considered harmful, but if is basically the same thing. Instead think about state machines and polymorphism. There’s no branch-prediction penalty to pay, since the system “just is” in the state it’s supposed to be in. The logic is clearer, because there are no switches, making it easier to test, too.
  • Don’t always assume that floating-point values are necessary. Integers can often be creatively used and are far faster for math than double-precision numbers.
  • Of course, there’s a compromise between speedy/efficient and readable/maintainable.
  • Aim to structure programs as “symbolic intent.” Mathematical descriptions are bad ways of expressing programs. Think about functional programming models instead of procedural.

If you want to know more, you should definitely watch the half-hour interview. And if your reaction was more along the lines of “Yes, yes; that’s all true, and it’s how I design my image processing code,” then I definitely hope you’ll consider applying for the GPU/multicore engineering position we have open.

Posted in Computing, Fodder for Techno-weenies, From the Yellow Notepad, Software Engineering | Leave a comment

Now Hiring Image Processing Software Engineers

My group at work—the Image Processing and Geospatial Computing Group at MathWorks—is hiring a couple of software engineers. One of them could be you.

We need someone with GPU and multicore programming skills. We’re looking for experience with CUDA, OpenCL, OpenMP, Intel’s Threading Building Blocks, or similar technologies. If you’re into making algorithms run wicked fast, you should definitely apply.

The other position focuses on image processing and code generation. If you like implementing image processing algorithms and converting MATLAB code to C code, then this is the job for you.

I’ve been at The MathWorks for almost fourteen years now, and it’s a really great company with an excellent corporate culture, competitive compensation, fantastic benefits, and lots of perks. Because everyone uses MATLAB and because we’ve made some very sensible business decisions over the last 28 years, it’s a very stable company to work for. (Did I mention that we’re putting up our fourth building in our Natick campus? And I think I also mentioned that the entire worldwide staff went on a cruise a few years ago.)

If image processing isn’t your thing, we have dozens of other positions open. Everything from web development to legal department work. Human resources to customer service. Technical writing to application engineering and consulting. Marketing to program management. QE, sales, usability, and more software development positions than you can shake a stick at.

Come, help us accelerate the pace of engineering and science worldwide. And if you do apply, tell them I sent you.

Posted in General, Software Engineering | Leave a comment

QCon SF 2011 Software Engineering Conference Notes

It’s sometimes possible to forget when reading all of the posts here about travel, diabetes, triathlon, and photography that they’re just a small part of my life. I have a job to which I devote a whole lot more time. I don’t talk about it much because (a) discussing what I’m working on putting into the Image Processing Toolbox isn’t appropriate or allowed, and even if it were (b) talking shop probably isn’t that interesting to most of the people here. But—believe it or not—the majority of traffic to my site lands on the pages that are technical, so I don’t feel so bad about posting the random “fodder for techno-weenies” post. (It’s a term of endearment, I promise! :^)

This is another one of those posts. Every year between Christmas and New Years Day, I try to use the quiet week to get stuff done and tie up loose ends. Last year, I cleared out a bunch of notes. This year, I’m looking at presentations and slides from the QCon SF 2011 conference (wrap-up). Its focus on software architecture and project management is about 75% of my job, so many of the presentations seemed tailor-made for me. Here’s some of what I learned.


Erik Doernenburg. “Software Quality: You Know It When You See It” has a really good slide deck that got me thinking about some projects I might want to set up. It’s full of practical, usable suggestions:

  • View the code at the 1,000 view, rather than ground-level or 30,000 feet.
  • Look at the test-to-code ratio, not just code coverage.
  • Graph the change of metrics between versions and revisions, compare across different parts of the code, and look at them relative to industry standards.
  • Measure the “toxicity” of code by rolling up various quality metrics about a bunch of modules into stacked bar charts.

We should pose these questions during design and code reviews:

  • Is the software/change of value to its users?
  • How appropriate is the design?
  • How easy is the code/design to understand and extend?
  • How maintainable is the software?

It was full of some really great links to things like Metrics tree maps (a.k.a., pretty heatmaps for source code) as well as a few tools: SourceMonitor, iPlasma, and using Moose to visualize quality.


Joshua Kerievsky. “Refactoring to Patterns” — some notes:

  • Refactoring is like algebra’s equivalence-preserving manipulations. “Design patterns are the word problems of the programming world; refactoring is its algebra.”
  • Understanding the refactoring thought process is more important than remembering individual techniques or tool support.
  • Code smells have multiple refactoring options and often benefit from composite refactorings.
  • Look for automatable refactorings first. Consider changing the client of smelly code before the smelly code itself.


Guilherme Silveira. “How To Stop Writing Next Year’s Unsustainable Piece Of Code” was pithy and thought-provoking.

  • There is no value for architecture or design without implementation. That’s just interpretation of the software.
  • “New language. New mindset. new idiomatic usage. Same mistakes.”
  • Complexity and composition are natural and good, but if they’re invisible, they’re evil.
  • Start with a mess and refactor right away. Starting “right” is hard (and misguided thinking). Refactor for better, not just prettier.
  • Make complexity easier to understand and see.
  • Hiding complexity in concision hurts testability, since no one knows the complexity is there. Furthermore, if it’s hard to test, it’s also hard to use correctly.
  • “Model rules. Do not model models.”


Michael Feathers. “Software Naturalism: Embracing The Real Behind The Ideal” is a presentation that I would like to see/hear, since the slides seemed full of information but weren’t self-explanatory. Here are two things I could glean: 80% of software defects in large projects were in 20% of the files. In general, the more churn in a file, the more complex it tends to be.


Panel: “Objects on Trial” was perhaps the most unusual presentation, since it was a mock-trial. I use objects all the time . . . some of them are good . . . some demonstrably so. Even so, I never latched onto the idea of object-oriented (OO) design versus objects as types. The four panelists, in one way or another, basically said, “That’s the problem.”

One of the panelists drew an extended analogy between the space program and OO. The space shuttle (which we all love) was fixated on reuse but basically was a waste of heavy lifting; people don’t reuse the right stuff. In software, object reuse is largely accomplished by cut-and-paste copying of boilerplate code that does close to what you want. Of course, the panelist acknowledged that we do reuse the ideas in OO via design patterns, and no one seems to have much of a problem with that. Ironically, having a rich pattern language means that software engineers are in a better place than ever before to use objects correctly.

A key problem with our approach to objects is that we’ve failed (generally in software engineering) to handle complexity well, which was supposed to be the point of OO design. A conflation of beauty and OO design makes things worse. Internally, software is ugly, and beauty shouldn’t be a goal. Making a fetish of beauty makes code inflexible because people don’t want to extend the beautiful thing that works.

For other panelists, objects weren’t the problem at all. For them it’s static typing in “OO languages,” such as C++, Java, and C#. We’re at a place now where all of the good things about OO have been lost in an attempt to make OO languages as fast as C. This runs counter to the goal of having “ordinary,” understandable code. Generic programming using strongly typed (possibly template heavy) languages just makes everything complicated.

For me, it’s moot. C++ is what I use, and I don’t have a large proprietary object system that I can tap into for reuse. I’m in the camp that uses C++ objects to generate new types for data hiding and aggregation, as well as (to a lesser extent) reuse. But some of these types are generic, template classes that are hard to understand. I plead “no contest.”

Posted in Computing, Fodder for Techno-weenies, From the Yellow Notepad, Software Engineering | Leave a comment

Things You Should Be Reading – August Edition

Hey everybody, I’m about a week late with the August edition of “Things You Should Be Reading.” There’s a little bit of something for everybody here.

Posted in Diabetes, General, Health Care, Software Engineering, Worthy Feeds | Leave a comment

Things You Should Be Reading

Hey, everybody. It’s that time again. The time to clean out a bunch of links that I’ve read and share them with you because I think you might find them interesting.

Posted in Computing, Cycling, Data-betes, Diabetes, Software Engineering, Worthy Feeds | 1 Comment

App Update

Today a bunch of my online peeps were in California visiting Medtronic. I wish I’d been invited to go to, but that was not the case. Had I been there, I would have squealed like a little schoolgirl at the pre-announcement that they’re rolling out support for uploading and using CareLink on a Mac next week.

Not only is that great for me when working with my own data, it will make developing my app easier. People may still need to take the extra step of downloading a CSV file containing their data, but at least they’ll be able to do it on their platform. Not perfect, but better.

In an ideal world — the one that I would have advocated for at pump/CGM HQ — third-party app developers (like me) would be able to ask the online CareLink database for a person’s diabetes data via an application programming interface (API). Mobile app developers could then hold on to that data for offline or mobile use without ever needing to talk directly to the medical devices themselves. Frankly, writing code to connect directly to a life-preserving medical device is quite risky and something I would like to avoid; it’s also the kind of thing that requires rigorous, time-consuming, expensive FDA approval. Not very appealing when all I want to be is a data consumer.

I’m hoping that Medtronic provides a mechanism to open up this data soon, because I’m getting close to being able to benefit from it. And when I say “this data,” I mean “our data” because it really is ours. We’re the ones who generated the data through our self-managment decisions, and we’re the ones who will benefit the most from using that data to make decisions. All I’m really asking for is a way to log in to CareLink without using a web browser and to retrieve data securely.

I’ve been working on my pump+CGM data visualizer a lot recently — most evenings in fact. On my Mac, I can extract events from a comma-separated value (CSV) file generated on the CareLink website, and I can pick out “interesting” events that are relevant for self-management. Now I’m working on being able to store those interesting events in a form that I can send to my iPod. (Then there are the tasks related to visualizing the data, but I’m starting small.)

It’s taking me longer than I expected to build this application. Objective-C isn’t hard, but learning the ins and outs of any new framework library is always a bit involved. (Turns out I’ve been using a lot more C++ than I had expected . . . not that there’s anything wrong with that.) And I realized that I actually need to build two applications: one part that sits on a “traditional computer” that can talk to CareLink and the other that visualizes the data on an iPhone, iPod, iPad.

Here’s a little example of the raw data that I will eventually use to generate graphs and an annotatable logbook:

3/30/11|16:20:00|GlucoseSensorData|AMOUNT=106, ISIG=10.2
3/30/11|16:25:00|GlucoseSensorData|AMOUNT=98, ISIG=9.71
3/30/11|16:30:00|GlucoseSensorData|AMOUNT=98, ISIG=10.59
3/30/11|16:35:00|GlucoseSensorData|AMOUNT=100, ISIG=10.66
3/30/11|16:40:00|GlucoseSensorData|AMOUNT=102, ISIG=10.94
3/30/11|16:45:00|GlucoseSensorData|AMOUNT=102, ISIG=10.6
3/30/11|16:50:00|GlucoseSensorData|AMOUNT=102, ISIG=10.56
. . .
3/30/11|18:14:01|BolusWizardBolusEstimate|BG_INPUT=195, BG_UNITS=mg dl,
  CARB_INPUT=0, CARB_UNITS=grams, CARB_RATIO=8, INSULIN_SENSITIVITY=50,
  BG_TARGET_LOW=110, BG_TARGET_HIGH=110, BOLUS_ESTIMATE=1.7,
  CORRECTION_ESTIMATE=1.7, FOOD_ESTIMATE=0, UNABSORBED_INSULIN_TOTAL=0,
  UNABSORBED_INSULIN_COUNT=2, ACTION_REQUESTOR=pump
3/30/11|18:14:01|BolusNormal|AMOUNT=1.7, CONCENTRATION=null,
  PROGRAMMED_AMOUNT=1.7
Posted in CGM, Data-betes, Diabetes, Fodder for Techno-weenies, Software Engineering | Leave a comment

Seriously Now. Let’s Start Coding.

Okay, I’ve picked up a smattering of Objective-C, learned about a few of the frameworks, and sketched some of the interface. I’ve contemplated the data model, and I’ve worked out a few of the interactions.

Isn’t it about time to put aside my “iPhone developer impostor” feelings and just start coding? Yes it is. I’m not going to build this app unless I start writing it.

ABC: Always Be Coding.

Posted in Data-betes, Life Lessons, Software Engineering | Leave a comment

Ready to Start Coding

It’s been a week since I announced that I was going to write an iPhone app. I’m still excited about it, even though someone told me that Medtronic is working on their own version of the same thing I proposed — a working prototype, she said. Well, I for one am glad that they seem some value in having a mobile app, but I plan to keep working on mine. Competition is good. We’ll see who can get their app out there first: the newbie picking up iPhone development skills or the large medical company who is going through FDA approval.

Since last Saturday I’ve learned a lot. I’ve picked up the syntax of Objective-C, which is causing this C++ programmer to “think differently.” I like what I’ve seen from it so far, but we’ll see what I think after building something real. I’ve made a couple “Hello, World!” applications, just enough to get a few basic skills using Xcode and Interface Builder.

Now the hard work begins.

I’ve made a list of requirements for the first couple of (internal) versions of the app; so I know what needs I plan to satisfy. I’ve picked an external library to plot the CGM data. And I’ve started working on the functional design, sketching a few different views that people will use to interact with their data. (I usually hate graphical user interface design, but something about the UIKit components seem to be amplifying my scanty abilities with interaction design.) I still have to figure out the data model — that is to say, the architecture — but I think that should follow from the views I create, which of course is supposed to visualize items in the pump/CGM data model.

Tomorrow I’ll try to put a few components together. Stay tuned!

Posted in CGM, Computing, Data-betes, Diabetes, Fodder for Techno-weenies, Software Engineering | 1 Comment

Total Diabetes Awareness, The App

I am terrible with personal software projects. At work, I have no problem getting things started and finished. But elsewhere, I’m just a bit too distracted by everything else in my life to engage in some casual programming.

But this morning, as I was putting on my socks — and checking my diabetic feet, of course — I struck upon a project that I would gladly spend at least a few evenings and weekends to get working.

Throughout the day I’ve been talking myself into writing an iPhone app to display all of the data from my pump and continuous glucose monitor. I’ve already learned a great deal from my CGM, but what I need now is a memory device that collects all (or at least most) of my diabetes data in one place, so that I can use what’s worked in the past (as well as what didn’t work so well) in order to make better decisions.

The idea behind the as-yet-unwritten software is to transfer all of the data and events from my part of Medtronic’s CareLink website — it stores my CGM sensor values, blood glucose readings, insulin boluses, temporary basals, infusion set changes, etc. — and store them on my iPod, where I can review and plot them graphically. (And if it works on my iPod Touch, it would run on an iPhone or iPad, too.)

Why do I want to do this? There are many situations that happen regularly but not quite frequently enough for me to remember what happened. What happened the last time I had Thai food? How much insulin did I give? What did I estimate the carbs to be? And what about the last time I went for a long bike ride? What temporary basal did I use? I could write all this down, but (as I’ve recently discovered) there’s a great deal of value in seeing the CGM trace surrounding the event.

So my app will be fairly small to begin with:

  • Import data from a CSV file that I can download from the CareLink site.
  • Plot the CGM graphs and display the insulin, BG, and pump events.
  • Display details about these events. What did I enter into the pump’s bolus wizard? What did I end up doing?

That’s a first version. That will let me carry around a self-updating logbook. Journaling is something we hate to do, so why not just aggregate the data that I already produce minute by minutes?

One or two improvements would make this app truly useful. The pump and CGM have a lot of data, but they lack context. I need to be able to add a tag or two and some notes to the handful of events that I want to highlight. That’s the first step; the next is to be able to search for those events and then look at what happened.

Once I’ve got that app working, who knows what could happen?

Of course, why do I want to make this app, when I’m usually so reluctant to write software away from the office? Plainly put, I need this application to improve my self-management. Observations of daily living are among the most powerful components of managing a chronic illness, but they are a complete pain in the ass to record manually.

Clearly this is something that Medtronic should be doing. It would greatly simplify things if I could sync directly from my pump to my iPod, and I’ve already tried without success to get them to tell me the data protocol of my pump. It’s my data after all, but they won’t talk. (Hell, it would be much better if I could download directly from CareLink to my iPod rather than doing a kind of crazy two step of saving a .csv file and uploading it to my iPod.) Perhaps Medtronic already is working on such an application, but I can’t count on it. Seeing the results of my actions is so useful that I will take one for the team and start writing this application.

My ultimate goal is to share the app and the code with the world. I would like very much to make this an open source project . . . the first salvo in a “test strip rebellion” where we people with diabetes take back the data stored on our medical devices. If the medical device manufacturers won’t make these apps, we must. If the FDA is going to make it difficult for commercial ventures to produce innovative solutions, we patients will have to turn the tables; it’s true that we’ll have to accept the risk for what we do, but at least we will have what we need to improve our health.

Oh! And I will need your help. I’ve never written an iOS application. If you have some skills, I might want to ask you a couple of qustions. First up: I need recommendations for newbies making their first forays into iPhone app development.

Posted in CGM, Data-betes, Diabetes, Software Engineering | 2 Comments

Early Ideas about Using Checklists in Software Engineering

Some months ago, I wrote a review of Atul Gawande’s Checklist Manifesto and about using checklists in software development.

I’m pleased to say that it looks like I might get a chance to follow-up on that idea more in the coming year. I’ll keep you updated. In the meantime, here are few ideas on the subject from one of my notebooks. (I appear to be going through these “historical documents” in a rather random chronological order.)

When are the pause points where we might use checklists?

  • Before starting to design
  • Before starting to code
  • Before code review
  • Before submitting changed files
  • Before QE-led testing

Who might be included in the check-off activities? The goal is to catch problems and communicate what’s happening.

  • Coder/Developer
  • Quality Engineer/Tester
  • Buildmasters
  • Doc Writer
  • Project Leader (?)

What’s so mindless that it’s taken for granted? (e.g., “build and run tests on every platform.”) Are these second nature? Or are they sometimes forgotten/overlooked/not done?

What goes onto a “pre-flight” checklist? What goes onto special circumstance (“OMG the plane is crashing!”) checklists? The idea is to have lots of small checklists.

What level of specificity is required for a checklist?

Posted in From the Yellow Notepad, Hoarding, Life Lessons, Software Engineering | Leave a comment

Requirements . . . again

It’s the week between Christmas and New Year’s Day . . . time to clean out the files at work. Actually, this year at the office I’m going through all of my yellow notepads — about 17 of them. As I find something interesting, I’ll post them here.

Today, requirements. I honestly can’t remember if I’ve written here about defining requirements in software projects. Getting them defined right is so important, I would be surprised if I hadn’t. Here are just a few more notes.

Questions to ask about your requirments:

  • Are they adequately motivated?
  • Are any missing?
  • Are there any included that aren’t really needed?
  • Are any solutions masquerading as requirements?
  • Are they testable?

These requirements are often overlooked:

  • Localization (L10N)
  • Robustness
  • Performance (speed, memory)
  • Backward compatibility

And remember, not all requirements have the same priority. Try to stage solutions to address different priority levels.

Update: It’s hilarious how many times I’ve already found names and telephone numbers for people who work at Medtronic Minimed.

Posted in From the Yellow Notepad, Hoarding, Software Engineering | Leave a comment

Performance Programming Links

Faithful readers: This dispatch falls into the bucket of “stuff that’s about work and not diabetes.” (Not that diabetes isn’t its own kind of work.) This is what I do for my 9-5. It’s the stuff I do between thinking about diabetes, my next bike outing, where I want to travel someday, and all those other things. Don’t worry, we’ll get back to all that “good stuff” soon enough; but this post is for the lurking coworkers and people searching on the Google.

Here are a few performance-related articles and presentations that I stumbled upon recently:

Igor Ostrovsky at Microsoft wrote a very useful description of various processor cache effects. Here are the notes I took while reading it:

  • Array access is slower than math
  • Data alignment can determine how many cache lines are touched
  • Keep modifications/accesses within the same cache level
  • Be aware of instruction level dependencies and parallelism opportunities
  • Avoid touching too many memory locations from the same cache line, causes contention
  • There’s a trade-off between the size of what you’re putting in the cache and the number of elements you touch in it. — What does that mean, Jeff? Not exactly sure, but cache assoc. is usually not a huge deal compared to other issues.
  • Because cores have their own caches and because memory needs to remain consistent, avoid letting two threads modify data on the same cache line.
  • Even when you think you know what you’re doing, there’s other crazy stuff going on.

Isn’t that last one the sad truth about performance optimization?

Igor also has an excellent article about branch prediction. Basically, if you structure your code so that if branches are predictably true (or predictably false) the CPU can start walking down that code path until it’s proved wrong. But if it’s close to random, you’ll see performance hits.

Joe Duffy, also at Microsoft, debunks the “premature optimization is evil” myth. Joe summarizes the article himself quite well, so I’ll just quote him.

In this short article, we’ll look at some important principles that are counter to what many people erroneously believe this [“avoid premature optimization”] statement to be saying. To save you time and suspense, I will summarize the main conclusions: I do not advocate contorting oneself in order to achieve a perceived minor performance gain. Even the best performance architects, when following their intuition, are wrong 9 times out of 10 about what matters. (Or maybe 97 times out of 100, based on Knuth’s numbers.) What I do advocate is thoughtful and intentional performance tradeoffs being made as every line of code is written. Always understand the order of magnitude that matters, why it matters, and where it matters. And measure regularly! I am a big believer in statistics, so if a programmer sitting in his or her office writing code thinks just a little bit more about the performance implications of every line of code that is written, he or she will save an entire team that time and then some down the road. Given the choice between two ways of writing a line of code, both with similar readability, writability, and maintainability properties, and yet interestingly different performance profiles, don’t be a bozo: choose the performant approach. Eschew redundant work, and poorly written code. And lastly, avoid gratuitously abstract, generalized, and allocation-heavy code, when slimmer, more precise code will do the trick.

Follow these suggestions and your code will just about always win in both maintainability and performance.

If you do anything that falls under the labels of “multicore,” “multithreaded,” or “multi-processor,” then you should definitely add Multicore Info and Intel’s software blogs to your RSS feed aggregator.

One recent Intel offering is a recording of “Introducing Intel Parallel Building Blocks”. The Intel folks discusses Intel Cilk Plus, Threading Building Blocks (TBB), and Array Building Blocks. Here are some notes from the 45 minute presentation:

  • Intel Cilk Plus is a lower-level way to expose parallelism and the potential for vectorization to C++ code. It currently only works with the Intel compiler.
  • TBB is awesome. That’s me saying that. I use it to easily exploit data parallelism in our existing codebase. (Because I use it already, I didn’t take many notes on it. Sorry.)
  • Array Building Block (ArBB) provide the highest level of abstraction presenting the ability to specify array data containers (1-D to N-D, including nested containers and [soon] sparse data) and then do vector operations on the data in the containers. Sounds familiar.
  • Cilk Plus includes reducers to prevent data races, has #pragma simd to empower the compiler to make vector assumptions, and has a mechanism for specifying a range of vector data.
  • Parallel Inspector and Parallel Amplifier are alleged to help squeeze performance out of code that uses TBB.
  • ArBB uses a two-part compilation process, one of which is a runtime JIT.
  • There are collisions between the schedulers in Intel MKL and Cilk (and TBB, etc.). Beware.

And finally, there’s a recording of a webinar about Intel Parallel Advisor that may be of interest. It’s next in my queue of things to watch.

Posted in Computing, Fodder for Techno-weenies, Software Engineering, Worthy Feeds | Leave a comment

An Invitation to Diabetes Researchers

I just finished reading Michael Bliss’s excellent The Discovery of Insulin about the amazing work at the University of Toronto in 1921-1923 by Banting, Best, Collip, and Macloed. For most readers, it’s surely a story about discovery and rivalry and collaboration in medicine, culminating in the first effective treatment of diabetes and (very quickly thereafter) the Nobel Prize for Medicine.

For me it was also a history of what I avoided by being diagnosed with type 1 diabetes after 1922. Bliss includes a small sample of the lives of some of the people afflicted with diabetes before the discovery of insulin. I was truly inspired by those who were fortunate enough to receive this “miracle drug,” but I was heartbroken by all of the people of that age who didn’t make it because the only treatment was to survive on a meager 500-or-so calories for intolerable months until slipping into the coma of ketoacidosis and then (eventually) death.

It’s been almost 89 years since the first successful clinical use of insulin, but we still don’t have a cure. At best, insulin is the key part of a hormone replacement therapy where people with diabetes try to mimic a pancreas. At worst, insulin is a fickle treatment that is difficult to use, expensive, and out of reach of millions of people worldwide.

While I’m so grateful for what I have — a treatment that gives life — what we need now is a cure . . . even if it’s only useful for people who are not yet sick or are newly diagnosed.

If you’re working on a cure or a new therapy for diabetes, the rest of this post is for you.

I will help you with any technical software aspects of your research that you need. If you have questions about MATLAB or C++, I will do my very best to answer them. If you need help with software design or object-oriented analysis/design, I can help you structure your solution. If you require some help with the non-development aspects of software development — such as project management or using tools — I will help you there, too.

My particular areas of expertise are MATLAB, C++, medical imaging formats (such as DICOM), some familiarity with image processing, and multithreaded programming using Intel’s TBB. I also know my fair share about life with diabetes. I can’t promise that I’ll have all of the answers to your particular question, but I’ll work with you as much as I can. And I’ll connect you with my coworkers as much as I can, if it comes down to that. Finding a cure that’s safe, effective, and universally accessible isn’t my day job, but moving into the third era of diabetes where no one dies from it and no one has to impersonate a pancreas is something I’d love to be a small (even anonymous) part of.

You can e-mail me at work or home, and you can hit me up on Twitter, too.

Posted in 101 in 1001, Book Notes, Diabetes, MATLAB, Software Engineering | Leave a comment