# Presentation: 207448

## Fermilab’s C++0X Work

- Walter E. Brown
*Computing Division*
*Fermi National Accelerator Laboratory*
- 2006-08-08

## Today’s talk

- Recap of our goals in contributing to C++0X
- Examples of our impact on HEP code
- Benefits of disseminating our library code
- Proposals at a critical juncture

## Our goals (recap from 2006-04-18)

- To facilitate C++ programming:
- In Fermilab’s HEP problem domain, and
- In the general scientific user community in which Fermilab plays a significant part
- To provide programming features that canbe used safely and efficiently:
- In both the C++ core language and the accompanying standard library ...
- So that we and our colleagues can focus on coding physics applications

## Example: impact of N1737 and N1913

*// N1737:  ... Multi-declarator  *auto* Declarations*
*// N1913:  ... Improv[ing]  *const_iterator* Use ...*

*// today’s code:  wordy, hard-to-read, repetitious,*
*//**	**involves a type conversion:*
- for( std::vector<sometype>::const_iterator
- 		it  =  v.begin(),  end  =  v.end();  ...

*// C++0X code:  compact, straightforward,*
*//**	**repetition-free, conversion-free:*
- for( auto  it  =  v.cbegin(),  end  =  v.cend();  ...

## Example: generating random numbers in C++0X

*// want Poisson-distributed sample*
- std::ranlux48  e;
- std::poisson_distribution  d;
- int  sample[100];
- for( int  i = 0 ;  i != 100;  ++i )
-     sample[i]  =  d(e);

## Why contribute our hep_random library?

- Demonstrate our competence
- Obtain benefits of peer review
- Generally improve our credibility
- Demonstrate willingness to work with other knowledgable software specialists
- Obtain increased recognition for FNAL as doing good work for the community
- Improve our code for our own use

## Critical juncture

- Committee deadlines approaching
- Likely to need completed proposals this year to give Committee time to polish
- Proof-of-concept implementations needed this year for library, next year for language core
- We’ve been focussing on random numbers to the near-exclusion of our other proposals

## What’s left: 1 of 6

- Reflection
- Of supreme importance to HEP community
- Needs attention by someone who can devote significant resources to developing the proposal and a reference implementation, and who will shepherd the proposal
- Recent opportunity:  J. Siek, research professor, UC—Boulder
- How to support him?

## What’s left: 2 of 6

- Mathematical special functions
- Proposal is complete (and code is even being shipped by one vendor) and is part of TR1
- Unlikely to be adopted without a publicly-available reference implementation—viewed by vendors as too much work to benefit a small customer base

## What’s left: 3 of 6

- Optimization opportunities
- Summary: call-site improvement for “pure” functions (no side effects)
- Potential for huge payoff in improved run time
- A form of the feature is already experimentally implemented by gcc (and others?); no known experiential reports, however
- Offer of assistance from head of UK delegation to co-author a paper by mid-September
- Is there enough time?

## What’s left: 4 of 6

- Template aliasing
- Summary: extend typedef to templates
- Accepted in principle
- Head of French delegation plans to provide wording in the direction we wanted by October
- Reference implementation likely to be in g++

## What’s left: 5 of 6

- Opaque typedefs
- Summary: permits distinctions among otherwise-identical types
- “We would have used this a half-dozen times in CMS code if the feature existed today.”
- Conceptual details worked out and already written
- Needs precise wording for text of C++0X
- Will need reference implementation
- Reasonable likelihood of adoption—badly wanted

## What’s left: 6 of 6

- Implicitly-callable functions
- Summary: let niladic functions stand in for variables; has numerous applications
- Solid theoretical basis
- Some recent public discussion on **comp.std.c++**
- Needs considerable work to rise to active proposal

## Fermilab’s C++0X Work

- Walter E. Brown
*Computing Division*
*Fermi National Accelerator Laboratory*
- 2006-08-08