Deadlock avoidance in parallel programs with futures: why parallel tasks should not wait for strangers

Futures are an elegant approach to expressing parallelism in functional programs. However, combining futures with imperative programming (as in C++ or in Java) can lead to pernicious bugs in the form of data races and deadlocks, as a consequence of uncontrolled data flow through mutable shared memory. In this paper we introduce the Known Joins (KJ) property for parallel programs with futures, and relate it to the Deadlock Freedom (DF) and the Data-Race Freedom (DRF) properties. Our paper offers two key theoretical results: 1) DRF implies KJ, and 2) KJ implies DF. These results show that data-race freedom is sufficient to guarantee deadlock freedom in programs with futures that only manipulate unsynchronized shared variables. To the best of our knowledge, these are the first theoretical results to establish sufficient conditions for deadlock freedom in imperative parallel programs with futures, and to characterize the subset of data races that can trigger deadlocks (those that violate the KJ property). From result 2), we developed a tool that avoids deadlocks in linear time and space when KJ holds, i.e., when there are no data races among references to futures. When KJ fails, the tool reports the data race and optionally falls back to a standard deadlock avoidance algorithm by cycle detection. Our tool verified a dataset of ∼2,300 student’s homework solutions and found one deadlocked program. The performance results obtained from our tool are very encouraging: a maximum slowdown of 1.06× on a 16-core machine, always outperforming deadlock avoidance via cycle-detection. Proofs of the two main results were formalized using the Coq proof assistant.

[1]  Vivek Sarkar,et al.  A Composable Deadlock-Free Approach to Object-Based Isolation , 2015, Euro-Par.

[2]  MatternFriedemann,et al.  Detecting causal relationships in distributed computations , 1994 .

[3]  Vivek Sarkar,et al.  A Transformation Framework for Optimizing Task-Parallel Programs , 2013, TOPL.

[4]  Giuseppe F. Italiano,et al.  Trade-offs for fully dynamic transitive closure on DAGs: breaking through the O(n2 barrier , 2005, JACM.

[5]  Vivek Sarkar,et al.  Dynamic Determinacy Race Detection for Task Parallelism with Futures , 2016, RV.

[6]  Martin Schulz,et al.  MPI runtime error detection with MUST: Advances in deadlock detection , 2012, 2012 International Conference for High Performance Computing, Networking, Storage and Analysis.

[7]  Martin Schulz,et al.  A graph based approach for MPI deadlock detection , 2009, ICS '09.

[8]  Edsger W. Dijkstra,et al.  Cooperating sequential processes , 2002 .

[9]  Charles E. Leiserson,et al.  Space-efficient scheduling of multithreaded computations , 1993, SIAM J. Comput..

[10]  Vivek Sarkar,et al.  Efficient data race detection for async-finish parallelism , 2010, Formal Methods Syst. Des..

[11]  Vivek Sarkar,et al.  Habanero-Java library: a Java 8 framework for multicore programming , 2014, PPPJ.

[12]  Edith Schonberg,et al.  Detecting access anomalies in programs with critical sections , 1991, PADD '91.

[13]  Don Coppersmith,et al.  Matrix multiplication via arithmetic progressions , 1987, STOC.

[14]  Ok-Kyoon Ha,et al.  An Efficient Algorithm for On-the-Fly Data Race Detection Using an Epoch-Based Technique , 2015, Sci. Program..

[15]  Leslie Lamport,et al.  Time, clocks, and the ordering of events in a distributed system , 1978, CACM.

[16]  Peng Li,et al.  Deadlock avoidance for streaming computations with filtering , 2010, SPAA '10.

[17]  Xiangyu Zhang,et al.  Quasi-static scheduling for safe futures , 2008, PPoPP.

[18]  Ronald L. Rivest,et al.  Introduction to Algorithms, third edition , 2009 .

[19]  Sreekaanth S. Isloor,et al.  The Deadlock Problem: An Overview , 1980, Computer.

[20]  Vivek Sarkar,et al.  Habanero-Java: the new adventures of old X10 , 2011, PPPJ.

[21]  Friedemann Mattern,et al.  Detecting causal relationships in distributed computations: In search of the holy grail , 1994, Distributed Computing.

[22]  Manu Sridharan,et al.  Effective race detection for event-driven programs , 2013, OOPSLA.

[23]  Martin Schulz,et al.  MPI runtime error detection with MUST: Advances in deadlock detection , 2012, 2012 International Conference for High Performance Computing, Networking, Storage and Analysis.

[24]  Don Coppersmith,et al.  Matrix multiplication via arithmetic progressions , 1987, STOC.

[25]  Dawson R. Engler,et al.  RacerX: effective, static detection of race conditions and deadlocks , 2003, SOSP '03.

[26]  Carlos Baquero,et al.  Why Logical Clocks are Easy , 2016, ACM Queue.

[27]  Laurie Hendren,et al.  Soot: a Java bytecode optimization framework , 2010, CASCON.

[28]  Charles E. Leiserson,et al.  Efficient Detection of Determinacy Races in Cilk Programs , 1997, SPAA '97.

[29]  Konstantinos Sagonas,et al.  Dynamic deadlock avoidance in systems code using statically inferred effects , 2011, PLOS '11.

[30]  Michael D. Ernst,et al.  Static Deadlock Detection for Java Libraries , 2005, ECOOP.

[31]  Michael Burrows,et al.  Eraser: a dynamic data race detector for multithreaded programs , 1997, TOCS.

[32]  Zhiqiang Ma,et al.  A theory of data race detection , 2006, PADTAD '06.

[33]  J. Ian Munro,et al.  Efficient Determination of the Transitive Closure of a Directed Graph , 1971, Inf. Process. Lett..

[34]  Ganesh Gopalakrishnan,et al.  Scalable verification of MPI programs , 2010, 2010 IEEE International Symposium on Parallel & Distributed Processing, Workshops and Phd Forum (IPDPSW).

[35]  Stephen N. Freund,et al.  FastTrack: efficient and precise dynamic race detection , 2009, PLDI '09.

[36]  Jeremy Manson,et al.  The Java memory model , 2005, POPL '05.

[37]  Victor Khomenko,et al.  Algebra of Parameterised Graphs , 2012, 2012 12th International Conference on Application of Concurrency to System Design.

[38]  Friedemann Mattern,et al.  Virtual Time and Global States of Distributed Systems , 2002 .

[39]  Toshimi Minoura,et al.  Deadlock avoidance revisited , 1982, JACM.

[40]  Hua Chen,et al.  MPI‐CHECK: a tool for checking Fortran 90 MPI programs , 2003, Concurr. Comput. Pract. Exp..

[41]  Colin J. Fidge,et al.  Timestamps in Message-Passing Systems That Preserve the Partial Ordering , 1988 .

[42]  John Carter Date Approved: , 1997 .

[43]  Vivek Sarkar,et al.  Phasers: a unified deadlock-free construct for collective and point-to-point synchronization , 2008, ICS '08.

[44]  Mark Lawley,et al.  Polynomial-complexity deadlock avoidance policies for sequential resource allocation systems , 1997, IEEE Trans. Autom. Control..

[45]  Vivek Sarkar,et al.  X10: an object-oriented approach to non-uniform cluster computing , 2005, OOPSLA '05.

[46]  Gérard Boudol A Deadlock-Free Semantics for Shared Memory Concurrency , 2009, ICTAC.

[47]  Edgar Knapp,et al.  Deadlock detection in distributed databases , 1987, CSUR.

[48]  P. S. Almeida,et al.  Interval Tree Clocks , 2008, OPODIS.

[49]  Matthias S. Müller,et al.  MPI Correctness Checking with Marmot , 2008, Parallel Tools Workshop.

[50]  Martin C. Rinard,et al.  ACM Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), November 2002 Ownership Types for Safe Programming: Preventing Data Races and Deadlocks , 2022 .

[51]  Charles E. Leiserson,et al.  Space-Efficient Scheduling of Multithreaded Computations , 1998, SIAM J. Comput..

[52]  L.A. Smith,et al.  A Parallel Java Grande Benchmark Suite , 2001, ACM/IEEE SC 2001 Conference (SC'01).

[53]  Lieven Eeckhout,et al.  Statistically rigorous java performance evaluation , 2007, OOPSLA.

[54]  Nobuko Yoshida,et al.  Dynamic deadlock verification for general barrier synchronisation , 2015, PPoPP.

[55]  Robert H. Halstead,et al.  MULTILISP: a language for concurrent symbolic computation , 1985, TOPL.

[56]  John M. Mellor-Crummey,et al.  On-the-fly detection of data races for programs with nested fork-join parallelism , 1991, Proceedings of the 1991 ACM/IEEE Conference on Supercomputing (Supercomputing '91).

[57]  Suresh Jagannathan,et al.  Safe futures for Java , 2005, OOPSLA '05.

[58]  Samuel Thibault,et al.  Evaluation of OpenMP Dependent Tasks with the KASTORS Benchmark Suite , 2014, IWOMP.

[59]  Kenneth P. Birman,et al.  Reliable communication in the presence of failures , 1987, TOCS.