C/C++ and Fortran

power-server-operatingsystems.png

Operating Systems

The core of your mission-critical workloads: AIX, IBM i, and Enterprise Linux

power-ISV-Solutions1.png

ISV Solutions

Stay up to date with key capabilities running on POWER such as SAP

Business Continuity

Learn how to keep critical processes running and adapt quickly with PowerHA

power-infrastructure-security.png

Power Security

Protect your most sensitive data anywhere in your hybrid cloud

Virtualization

Check here for virtualization and management needs: HMC & CMC, PowerVC, and PowerVM

Open Source

Join our open source efforts within the IBM Power Systems portfolio

Enterprise Infrastructure as a Service

Achieve business growth with agility and flexibility with our enterprise IaaS in Power Virtual Server

Programming Languages

The hub for Programming Languages

Questions on C/C++ volatile from SC08 Tutorial S08: A Hands-on Introduction to OpenMP

By Archive User posted Mon November 17, 2008 01:35 PM

  

Originally posted by: Michael_Wong


On Sunday, I attended the OpenMP Tutorial hosted by some of my colleagues from the OpenMP committee, Tim Mattson and Larry Meadows. It was an excellent tutorial, full of features and pointing out the behavioral differences between OpenMP 2.5 and 3.0. Tim has been doing this tutorial for almost 20 years and Larry, as the OpenMP CEO has been involved in this for the same amount of time.

I must point out that IBM xl C/C++ 10.1 compiler for AIX and Linux both have support for OpenMP 3.0, in addiiton to the compilers mentioned during the tutorial. In fact, this compiler was one of the first to have support for OpenMP 3.0 in the industry since the ratification of the specification in May, 2008.

http://www-01.ibm.com/software/awdtools/xlcpp/aix/
http://www-01.ibm.com/software/awdtools/xlcpp/linux/

You can get a trial version from the link above.

There were a few C++ specific questions. During the discussion on OpenMP memory model, one questions involves how volatile in C/C++ is used in multithreaded program.

The C++ 0x Standard will clarify that the volatile keyword continues to have nothing to do with multithreading. It merely indicates that something from the environment may change the value. The role of an atomic variable will be used to indicate that another thread may change the value of this variable. It is possible to say that a variable is an atomic volatile to indicate that something from the environment AND another thread may change the value. The C standard, when it supports concurrency in C1x will likely adapt the same meaning.

So in short, C++ Volatile !=Jave volatile and C++ Volatile!= C++ atomic. During C++0x concurrency deliberations, we discussed at length and felt that there is too much history and presumed meanings involved with volatile. In fact, it may even have different meanings varying from compilers to platforms. So it was felt wiser to leave it alone, allowing implementers to retain whatever meaning they are used to, and adapt a new way of naming truly atomic types.

I hope this helps to answer one of the question regarding the role of volatile.

There was another question about how OpenMP 3.0 changed the role of what constructor (default, copy, assignment) is called by each of the private/threadprivate/first/lastprivate variable. Tim was right that we worked very hard to clarify this aspect, but the rules while somewhat intuitive is still fairly tedious to enumerate, given the many ways that C++ does initialization. I will clarify that in a subsequent post.
0 comments
0 views

Permalink