Verifying Fence Elimination Optimisations

  • Viktor Vafeiadis
  • Francesco Zappa Nardelli
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6887)

Abstract

We consider simple compiler optimisations for removing redundant memory fences in programs running on top of the x86-TSO relaxed memory model. While the optimisations are performed using standard thread-local control flow analyses, their correctness is subtle and relies on a non-standard global simulation argument. The implementation and the proof of correctness are programmed in Coq as part of CompCertTSO, a fully-fledged certified compiler from a concurrent extension of a C-like language to x86 assembler. In this article, we describe the soundness proof of the optimisations and evaluate their effectiveness.

Keywords

Memory Model Execution Path Simulation Relation Measured Simulation Sequentially Consistent 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Abadi, M., Lamport, L.: The existence of refinement mappings. Theor. Comput. Sci., 253–284 (1991)Google Scholar
  2. 2.
    Alglave, J.: A shared memory poetics. Ph.D. thesis, Université Paris 7 (2010)Google Scholar
  3. 3.
    Becker, P.: Working draft, standard for programming language C++, n3090=10-0080 (March 2010)Google Scholar
  4. 4.
    Blazy, S., Leroy, X.: Mechanized semantics for the Clight subset of the C language. J. Autom. Reasoning 43(3), 263–288 (2009)MathSciNetCrossRefMATHGoogle Scholar
  5. 5.
    Burckhardt, S., Alur, R., Martin, M.M.K.: CheckFence: checking consistency of concurrent data types on relaxed memory models. In: PLDI (2007)Google Scholar
  6. 6.
    Burckhardt, S., Musuvathi, M., Singh, V.: Verifying local transformations on relaxed memory models. In: Gupta, R. (ed.) CC 2010. LNCS, vol. 6011, pp. 104–123. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  7. 7.
    Cao Minh, C., Chung, J., Kozyrakis, C., Olukotun, K.: STAMP: Stanford transactional applications for multi-processing. In: IISWC (2008)Google Scholar
  8. 8.
    The Compcert verified compiler, v. 1.5 (August 2009), http://compcert.inria.fr/release/compcert-1.5.tgz
  9. 9.
  10. 10.
    Dice, D., Shalev, O., Shavit, N.N.: Transactional locking II. In: Dolev, S. (ed.) DISC 2006. LNCS, vol. 4167, pp. 194–208. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  11. 11.
    Eide, E., Regehr, J.: Volatiles are miscompiled, and what to do about it. In: EMSOFT (2008)Google Scholar
  12. 12.
    Fraser, K.: Practical Lock Freedom. Ph.D. thesis, University of Cambridge, also available as Tech. Report UCAM-CL-TR-639 (2003)Google Scholar
  13. 13.
    Huynh, T.Q., Roychoudhury, A.: Memory model sensitive bytecode verification. Form. Methods Syst. Des. 31, 281–305 (2007)CrossRefMATHGoogle Scholar
  14. 14.
    Kuperstein, M., Vechev, M., Yahav, E.: Automatic inference of memory fences. In: FMCAD (2010)Google Scholar
  15. 15.
    Lee, J., Padua, D.A.: Hiding relaxed memory consistency with a compiler. IEEE Trans. Comput. 50, 824–833 (2001)CrossRefGoogle Scholar
  16. 16.
    Leroy, X.: A formally verified compiler back-end. Journal of Automated Reasoning 43(4), 363–446 (2009), http://gallium.inria.fr/~xleroy/publi/compcert-backend.pdf MathSciNetCrossRefMATHGoogle Scholar
  17. 17.
    Lynch, N., Vaandrager, F.: Forward and backward simulations I: untimed systems. Inf. Comput. 121, 214–233 (1995)MathSciNetCrossRefMATHGoogle Scholar
  18. 18.
    Manson, J., Pugh, W., Adve, S.: The Java memory model. In: POPL (2005)Google Scholar
  19. 19.
    Morel, E., Renvoise, C.: Global optimization by suppression of partial redundancies. Commun. ACM 22, 96–103 (1979)MathSciNetCrossRefMATHGoogle Scholar
  20. 20.
    Owens, S., Sarkar, S., Sewell, P.: A better x86 memory model: x86-TSO. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) TPHOLs 2009. LNCS, vol. 5674, pp. 391–407. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  21. 21.
    Sarkar, S., Sewell, P., Alglave, J., Maranget, L., Williams, D.: Understanding POWER multiprocessors. In: PLDI (2011)Google Scholar
  22. 22.
    Ševčík, J., Aspinall, D.: On validity of program transformations in the java memory model. In: Ryan, M. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 27–51. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  23. 23.
    Ševčik, J.: Safe optimisations for shared-memory concurrent programs. In: PLDI (2011)Google Scholar
  24. 24.
    Ševčik, J., Vafeiadis, V., Zappa Nardelli, F., Jagannathan, S., Sewell, P.: Relaxed-memory concurrency and verified compilation. In: POPL (2011)Google Scholar
  25. 25.
    Sewell, P., Sarkar, S., Owens, S., Zappa Nardelli, F., Myreen, M.O.: x86-TSO: a rigorous and usable programmer’s model for x86 multiprocessors. Commun. ACM 53(7), 89–97 (2010)CrossRefGoogle Scholar
  26. 26.
    Shasha, D., Snir, M.: Efficient and correct execution of parallel programs that share memory. ACM Trans. Program. Lang. Syst. 10, 282–312 (1988)CrossRefGoogle Scholar
  27. 27.
    Sura, Z., Fang, X., Wong, C.-L., Midkiff, S.P., Lee, J., Padua, D.: Compiler techniques for high performance sequentially consistent Java programs. In: PPoPP (2005)Google Scholar
  28. 28.
    Terekhov, A.: Brief tentative example x86 implementation for C/C++ memory model. cpp-threads mailing list (2008), http://www.decadent.org.uk/pipermail/cpp-threads/2008-December/001933.html
  29. 29.
    Treiber, R.K.: Systems programming: Coping with parallelism. Tech. rep. (1986)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Viktor Vafeiadis
    • 1
  • Francesco Zappa Nardelli
    • 2
  1. 1.MPI-SWSGermany
  2. 2.INRIAFrance

Personalised recommendations