Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Octocat-spinner-32 CMakeLists.txt Initial commit October 19, 2012
Octocat-spinner-32 LICENSE Initial commit October 19, 2012
Octocat-spinner-32 README.md Initial commit October 19, 2012
Octocat-spinner-32 generate-xcode-iphone.py Initial commit October 19, 2012
Octocat-spinner-32 iOS.cmake Initial commit October 19, 2012
Octocat-spinner-32 main.cpp Initial commit October 19, 2012
Octocat-spinner-32 randomdelay.cpp Initial commit October 19, 2012
Octocat-spinner-32 randomdelay.h Initial commit October 19, 2012
README.md

AcquireRelease

AcquireRelease is a sample application which complements the blog post, This Is Why They Call It a Weakly-Ordered CPU.

It demonstrates the kind of memory reordering which only happens on weakly-ordered CPUs, assuming no compiler reordering takes place.

Requirements

CMake 2.8.9 or later. It might work using earlier versions of CMake if you edit CMakeLists.txt, but I didn't test this. The CMake executable must be available in your path.

A compiler toolchain which supports C++11 threads and atomics. I tested it using Xcode 4.5.1 on OSX Mountain Lion 10.8.2, and Visual Studio 2012 on Windows 7.

If you're targeting iOS, your device must be running iOS 5.0 or later. You must also have your developer certificate and provisioning profiles already set up. If you're able to build and run sample applications, you should be good to go.

How to Build and Run on iOS Devices

Run generate-xcode-iphone.py.

Open build/AcquireRelease.xcodeproj.

Select AcquireRelease as the target scheme using the drop-down list available by clicking the Scheme box.

Click Run.

Notes:

  • The Xcode project is generated using a slightly modified version of this CMake toolchain file. Specifically, I modified it to additionally search for the iOS Developer folder under /Applications/Xcode.app/Contents/, which is where it was for me after installing Xcode via the App Store on Mountain Lion.
  • When using the resulting generated Xcode project, you won't be able to set source-level breakpoints. Assembly-level breakpoints still work, though.

How to Build on Other Platforms

Make a build subdirectory, run cmake -G "<generator>" .. in that subdirectory, then use the resulting solution, project or makefile. To see a list of available generators, run cmake by itself. For example, for Visual Studio 2012, I used the following command line:

cmake -G "Visual Studio 11" ..
Something went wrong with that request. Please try again.