Skip to main content

Parallel Assembly Synthesis

  • Conference paper
  • First Online:
Logic-Based Program Synthesis and Transformation (LOPSTR 2024)

Abstract

Program synthesis offers an attractive alternative to the intricate and tedious process of writing assembly programs manually. Assembly program synthesis automatically generates implementations, given a high-level formal specification and a machine description. However, its limited scalability prevents widespread adoption. Automatic parallelization improves program synthesis in general, but parallelizing assembly synthesis is nontrivial as the realities that data are untyped and all state is global lead to an enormous search space and prevent straightforward decomposition into separable sub-problems that can be run in parallel. We present PASSES, a Parallel Assembly Synthesis System Exploiting Subspaces. PASSES uses five heuristics to transform an original assembly synthesis problem into a set of sub-problems; it runs multiple synthesis sub-problems in parallel and constructs the final result by combining them. We evaluate PASSES on 26 general bit manipulation assembly programming problems and 140 machine-dependent use cases from two operating systems. Compared to an existing assembly synthesis tool and a state-of-the-art parallel SMT solver, all five heuristics in PASSES significantly improve assembly synthesis scalability.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    The conditional execution feature in ARM does not affect the corresponding types.

References

  1. Alur, R., et al.: Syntax-guided synthesis. In: Proceedings of the 2013 Formal Methods in Computer-Aided Design, FMCAD 2013, pp. 1–8. IEEE, Portland, OR, USA (10 2013). https://doi.org/10.1109/FMCAD.2013.6679385

  2. Alur, R., Černý, P., Radhakrishna, A.: Synthesis through unification. In: Kroening, D., Păsăreanu, C.S. (eds.) CAV 2015. LNCS, vol. 9207, pp. 163–179. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-21668-3_10

    Chapter  Google Scholar 

  3. Alur, R., Radhakrishna, A., Udupa, A.: Scaling enumerative program synthesis via divide and conquer. In: Legay, A., Margaria, T. (eds.) TACAS 2017. LNCS, vol. 10205, pp. 319–336. Springer, Heidelberg (2017). https://doi.org/10.1007/978-3-662-54577-5_18

    Chapter  Google Scholar 

  4. Barman, S., Bodik, R., Chandra, S., Torlak, E., Bhattacharya, A., Culler, D.: Toward tool support for interactive synthesis. In: 2015 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software (Onward!), Onward! 2015, pp. 121–136. Association for Computing Machinery, New York, NY, USA (2015). https://doi.org/10.1145/2814228.2814235

  5. Basin, D., Deville, Y., Flener, P., Hamfelt, A., Fischer Nilsson, J.: Synthesis of programs in computational logic. In: Bruynooghe, M., Lau, K.-K. (eds.) Program Development in Computational Logic. LNCS, vol. 3049, pp. 30–65. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-25951-0_2

    Chapter  Google Scholar 

  6. Baumann, A., et al.: The multikernel: a new OS architecture for scalable multicore systems. In: Proceedings of the ACM SIGOPS 22nd Symposium on Operating Systems Principles, SOSP 2009, pp. 29–44. Association for Computing Machinery, New York, NY, USA (2009). https://doi.org/10.1145/1629575.1629579

  7. Brummayer, R., Biere, A.: Boolector: an efficient SMT solver for bit-vectors and arrays. In: Kowalewski, S., Philippou, A. (eds.) TACAS 2009. LNCS, vol. 5505, pp. 174–177. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-00768-2_16

    Chapter  Google Scholar 

  8. Buchi, J.R., Landweber, L.H.: Solving sequential conditions by finite-state strategies. Trans. Am. Math. Soc. 138, 295–311 (1969)

    Article  MathSciNet  Google Scholar 

  9. Cempron, J.P., Salinas, C.S., Uy, R.L.: Assembly program performance analysis metrics: instructions performed and program latency exemplified on loop unroll. Philippine J. Sci. 147(3), 441–452 (2018)

    Google Scholar 

  10. Chennupati, G., Azad, R.M.A., Ryan, C., Eidenbenz, S., Santhi, N.: Synthesis of parallel programs on multi-cores. In: Ryan, C., O’Neill, M., Collins, J.J. (eds.) Handbook of Grammatical Evolution, pp. 289–315. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-78717-6_12

    Chapter  Google Scholar 

  11. Cypher, A.: Eager: programming repetitive tasks by example. In: Proceedings of the SIGCHI Conference on Human Factors in Computing Systems, CHI 1991, pp. 33–39. Association for Computing Machinery, New York, NY, USA (1991). https://doi.org/10.1145/108844.108850

  12. David, C., Kroening, D.: Program synthesis: challenges and opportunities. Philos. Trans. Roy. Soc. A Math. Phys. Eng. Sci. 375(2104), 20150403 (2017)

    Article  Google Scholar 

  13. Farzan, A., Nicolet, V.: Phased synthesis of divide and conquer programs. In: Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, PLDI 2021, pp. 974–986. Association for Computing Machinery, New York, NY, USA (2021)

    Google Scholar 

  14. Flener, P., Partridge, D.: Inductive programming. Autom. Softw. Eng. 2, 131–137 (2001). https://doi.org/10.1023/A:1008797606116

    Article  Google Scholar 

  15. Gulwani, S.: Programming by examples. Dependable Softw. Syst. Eng. 45(137), 3–15 (2016)

    Google Scholar 

  16. Gulwani, S., Jha, S., Tiwari, A., Venkatesan, R.: Synthesis of loop-free programs. In: Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2011, pp. 62–73. Association for Computing Machinery, New York, NY, USA (2011). https://doi.org/10.1145/1993498.1993506

  17. Gulwani, S., Polozov, O., Singh, R.: Program synthesis. In: Foundations and Trends in Programming Languages, vol. 4, pp. 1–119. NOW, Hanover, MA, USA, August 2017

    Google Scholar 

  18. Hamadi, Y., Jabbour, S., Sais, L.: ManySAT: solver description. Technical report, MSR-TR-2008-83, May 2008. https://www.microsoft.com/en-us/research/publication/manysat-solver-description/

  19. Hamadi, Y., Jabbour, S., Sais, L.: ManySAT: a parallel SAT solver. J. Satisfiability Boolean Modeling Comput 6(4), 245–262 (2010)

    Article  Google Scholar 

  20. Holland, D.A., Hu, J., Kawaguchi, M., Lu, E., Chong, S., Seltzer, M.I.: Aquarium: Cassiopea and Alewife languages (2022). https://arxiv.org/abs/1908.00093

  21. Holland, D.A., Lim, A.T., Seltzer, M.I.: A new instructional operating system. In: Proceedings of the 33rd SIGCSE Technical Symposium on Computer Science Education, SIGCSE 2002, pp. 111–115. Association for Computing Machinery, New York, NY, USA (2002). https://doi.org/10.1145/563340.563383

  22. Hu, J., Lu, E., Holland, D.A., Kawaguchi, M., Chong, S., Seltzer, M.: Towards porting operating systems with program synthesis. ACM Trans. Program. Lang. Syst. 45(1) (2023). https://doi.org/10.1145/3563943

  23. Hu, J., Lu, E., Holland, D.A., Kawaguchi, M., Chong, S., Seltzer, M.I.: Trials and tribulations in synthesizing operating systems. In: Proceedings of the 10th Workshop on Programming Languages and Operating Systems, PLOS 2019, pp. 67–73. Association for Computing Machinery, New York, NY, USA (2019). https://doi.org/10.1145/3365137.3365401

  24. Hu, J., Vaithilingam, P., Chong, S., Seltzer, M., Glassman, E.L.: Assuage: assembly synthesis using a guided exploration. In: The 34th Annual ACM Symposium on User Interface Software and Technology, pp. 134–148. Association for Computing Machinery, New York, NY, USA (2021)

    Google Scholar 

  25. Jeon, J., Qiu, X., Solar-Lezama, A., Foster, J.S.: Adaptive concretization for parallel program synthesis. In: Kroening, D., Păsăreanu, C.S. (eds.) CAV 2015. LNCS, vol. 9207, pp. 377–394. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-21668-3_22

    Chapter  Google Scholar 

  26. Jeon, J., Qiu, X., Solar-Lezama, A., Foster, J.S.: An empirical study of adaptive concretization for parallel program synthesis. Form. Methods Syst. Des. 50(1), 75–95 (2017). https://doi.org/10.1007/s10703-017-0269-8

    Article  Google Scholar 

  27. Jha, S., Seshia, S.A.: A theory of formal synthesis via inductive learning. Acta Inf. 54(7), 693–726 (2017). https://doi.org/10.1007/s00236-017-0294-5

    Article  MathSciNet  Google Scholar 

  28. Le Frioux, L., Baarir, S., Sopena, J., Kordon, F.: PaInleSS: a framework for parallel SAT solving. In: Gaspers, S., Walsh, T. (eds.) SAT 2017. LNCS, vol. 10491, pp. 233–250. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-66263-3_15

    Chapter  Google Scholar 

  29. Le Frioux, L., Baarir, S., Sopena, J., Kordon, F.: Modular and efficient divide-and-conquer SAT solver on top of the painless framework. In: Vojnar, T., Zhang, L. (eds.) TACAS 2019. LNCS, vol. 11427, pp. 135–151. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-17462-0_8

    Chapter  Google Scholar 

  30. Manna, Z., Waldinger, R.: A deductive approach to program synthesis. ACM Trans. Program. Lang. Syst. 2(1), 90–121 (1980). https://doi.org/10.1145/357084.357090

  31. Massalin, H.: Superoptimizer: a look at the smallest program. In: Proceedings of the Second International Conference on Architectual Support for Programming Languages and Operating Systems, ASPLOS II, pp. 122–126. IEEE Computer Society Press, Washington, DC, USA (1987). https://doi.org/10.1145/36206.36194

  32. Mohr, E., Kranz, D., Halstead, R.: Lazy task creation: a technique for increasing the granularity of parallel programs. IEEE Trans. Parallel Distrib. Syst. 2(3), 264–280 (1991). https://doi.org/10.1109/71.86103

    Article  Google Scholar 

  33. Myers, B.A.: Creating user interfaces using programming by example, visual programming, and constraints. ACM Trans. Program. Lang. Syst. 12(2), 143–177 (1990). https://doi.org/10.1145/78942.78943

    Article  Google Scholar 

  34. Partridge, D.: The case for inductive programming. Computer 30(1), 36–41 (1997). https://doi.org/10.1109/2.562924

    Article  Google Scholar 

  35. Polozov, O., Gulwani, S.: FlashMeta: a framework for inductive program synthesis. In: Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2015, pp. 107–126. Association for Computing Machinery, New York, NY, USA (2015). https://doi.org/10.1145/2814270.2814310

  36. Reddy, M.: Chapter 7 - performance. In: Reddy, M. (ed.) API Design for C++, pp. 209–240. Morgan Kaufmann, Boston (2011). https://doi.org/10.1016/B978-0-12-385003-4.00007-5

  37. Reisenberger, C.: PBoolector: a parallel SMT solver for QF_BV by combining bit-blasting with look-ahead. Ph.D. thesis, Master’s thesis, Johannes Kepler Univesität Linz, Linz, Austria (2014)

    Google Scholar 

  38. Rodgers, D.P.: Improvements in multiprocessor system design. In: Proceedings of the 12th Annual International Symposium on Computer Architecture, ISCA 1985, pp. 225–231. IEEE Computer Society Press, Washington, DC, USA (1985)

    Google Scholar 

  39. Schkufza, E., Sharma, R., Aiken, A.: Stochastic superoptimization. In: Proceedings of the Eighteenth International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS 2013, pp. 305–316. Association for Computing Machinery, New York, NY, USA (2013). https://doi.org/10.1145/2451116.2451150

  40. Smith, D.R.: The design of divide and conquer algorithms. Sci. Comput. Programm. 5, 37–58 (1985). https://doi.org/10.1016/0167-6423(85)90003-6

    Article  MathSciNet  Google Scholar 

  41. Smith, D.R.: Top-down synthesis of divide-and-conquer algorithms. Artif. Intell. 27(1), 43–96 (1985). https://doi.org/10.1016/0004-3702(85)90083-9

    Article  MathSciNet  Google Scholar 

  42. Solar-Lezama, A.: The sketching approach to program synthesis. In: Hu, Z. (ed.) APLAS 2009. LNCS, vol. 5904, pp. 4–13. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-10672-9_3

    Chapter  Google Scholar 

  43. Solar-Lezama, A., Jones, C.G., Bodik, R.: Sketching concurrent data structures. In: Proceedings of the 29th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2008, pp. 136–148. ACM, New York, NY, USA (2008). https://doi.org/10.1145/1375581.1375599

  44. Solar-Lezama, A., Tancau, L., Bodik, R., Seshia, S., Saraswat, V.: Combinatorial sketching for finite programs. In: Proceedings of the 12th International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS 2006, pp. 404–415. Association for Computing Machinery, New York, NY, USA (2006). https://doi.org/10.1145/1168857.1168907

  45. Srinivasan, V., Reps, T.: Synthesis of machine code from semantics. In: Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2015, pp. 596–607. Association for Computing Machinery, New York, NY, USA (2015). https://doi.org/10.1145/2737924.2737960

  46. Srinivasan, V., Sharma, T., Reps, T.: Speeding up machine-code synthesis. In: Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2016, pp. 165–180. Association for Computing Machinery, New York, NY, USA (2016). https://doi.org/10.1145/2983990.2984006

  47. Warren, H.S.: Hacker’s Delight, 2nd edn. Addison-Wesley Professional, Boston, MA, USA (2012)

    Google Scholar 

  48. Wintersteiger, C.M., Hamadi, Y., de Moura, L.: A concurrent portfolio approach to SMT solving. In: Bouajjani, A., Maler, O. (eds.) CAV 2009. LNCS, vol. 5643, pp. 715–720. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-02658-4_60

    Chapter  Google Scholar 

  49. Zhang, J., et al.: PyDex: repairing bugs in introductory python assignments using LLMs. Proc. ACM Program. Lang. 8(OOPSLA1) (2024). https://doi.org/10.1145/3649850

  50. Zhang, J., Li, D., Kolesar, J.C., Shi, H., Piskac, R.: Automated feedback generation for competition-level code. In: Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering, ASE 2022. Association for Computing Machinery, New York, NY, USA (2023). https://doi.org/10.1145/3551349.3560425

  51. Zhang, J., Piskac, R., Zhai, E., Xu, T.: Static detection of silent misconfigurations with deep interaction analysis. Proc. ACM Program. Lang. 5(OOPSLA) (2021). https://doi.org/10.1145/3485517

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Jingmei Hu .

Editor information

Editors and Affiliations

Appendices

A PASSES Heuristic Algorithms

1.1 A.1 PASSES Algorithm

Algorithm 1 shows pseudo code for PASSES. It first initializes the list of instances with different heuristics in line 4 and then parallelizes the synthesis for each instance in line 5, by invoking multiple individual synthesizers. Given the specification, a machine model, and a list of constraints, in function synth_instance (lines 9–15), Synthesizer either successfully generates a target program prog in line 12 or gets a synthesis failure in line 13. Depending on the heuristic, PASSES handles the failure differently as shown in line 15. PASSES executes all running instances in parallel, and if one of them successfully produces a program, it returns the first result in line 7; otherwise, it waits until all instances finish with a synthesis failure in line 8.

figure a

1.2 A.2 Constraint-SC Algorithm

Algorithm 2 shows the pseudo code for the instance initialization in Constraint-SC. In this code example, we initialize synthesis instances by forcing the first instruction in the target program to be different types (lines 3–4); one could imagine creating more detailed subspaces with constraints on other instruction locations, which further prunes the search space, expediting synthesis. In Sect. 5, we first apply instruction type constraints on the first instruction location. Since different instruction types can contain different numbers of instructions, and there are six categories of instruction types, to enable parallelism with more synthesis sub-problems and encourage subspace size equality, we take the cross product of the types of the first two instructions to produce \(6^2 = 36\) groups, and merge parts of them to create groups with roughly equal sizes.

figure b

1.3 A.3 Simpl-SC Basic Algorithm

Algorithm 3 shows the pseudo code for the instance initialization in Simpl-SC. We first divide the given complete machine model, complete-model, into a list of models with smaller instruction sets, sub-models, in line 2; each sub-model represents a subspace of the search space of the original synthesis problem;. We discuss model division in more detail later in this section. We refer to the synthesis problems for these sub-models as sub-model instances in line 4.

figure c

To preserve collective exhaustivity, Simpl-SC also adds a single synthesis instance with the complete-model, referred to as the complete-model instance (line 6), which allows the synthesizer to explore other available search spaces in the original problem. In other words, this guarantees that all subspaces explored by the complete-model and sub-model instances, exhaustively cover the entire search space. To avoid duplicate searches, we generate a set of mutually exclusive constraints (line 5) and apply them to the complete-model instance; those constraints force the synthesizer to produce a program with one or more instructions outside all possible sub-models. With those constraints, the complete-model instance precludes all subspaces searched by the sub-model instances and minimizes overlaps in the search spaces. Note that the complete-model instance preserves mutual exclusivity from all other sub-model instances, while those sub-model instances may not be mutually exclusive from each other.

1.4 A.4 Inc-SC Algorithm

Algorithm 4 shows the pseudo code for the function synth_instance in Inc-SC with synthesis failure handling shown in lines 5–10. Inc-SC first enlarges the machine model used in the failed instance into a list of new models (line 7) and then creates new instances with enlarged models and mutually exclusive constraints (lines 8–10). The model enlargement extends the given model with at least one more different instruction type from the complete machine model; in other words, whenever there is an instance with a x-type (\(x \ge 2\)) model failure, Inc-SC enlarges this x-type model into several \((x+1)\)-type models and launches the corresponding sub-model instances in parallel. The mutually exclusive constraints (line 9) guarantee that the target program cannot be synthesized with only x instruction types, i.e., the target program must include all \((x+1)\) types in its enlarged model; they utilize mutual exclusivity to assure that the search space explored by previously failed instances will not be reconsidered. Compared with the original complete-model, these enlarged models are still relatively smaller and their sub-model instances are easier to be evaluated by the synthesizer. Note that though Inc-SC does not preserve collective exhaustivity at the beginning, given that there may exist multiple programs that satisfy the specification, incremental model enlargement ensures that the solution will be eventually found.

figure d
Fig. 4.
figure 4

Bit manipulation benchmark examples (26 in total).

B Bit Manipulation Benchmark Examples

Figure 4 describes all the examples we used. The examples, numbered P1a – P14b, are grouped by similarity. Some examples include signed or unsigned comparisons, such as P11a and P14a, while others involve shifting with 0-fill (logical shift) or sign-fill (arithmetic shift), such as P8a and P12a. We mark the type over each comparison and shift symbol.

Table 5 reports the number of instructions in each synthesized implementation by Aquarium, indicating the minimum length requirement for each benchmark.

Table 5. Size of the bit manipulation benchmarks with MIPS implementations (lines of code).

Rights and permissions

Reprints and permissions

Copyright information

© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Hu, J., Chong, S., Seltzer, M. (2024). Parallel Assembly Synthesis. In: Bowles, J., Søndergaard, H. (eds) Logic-Based Program Synthesis and Transformation. LOPSTR 2024. Lecture Notes in Computer Science, vol 14919. Springer, Cham. https://doi.org/10.1007/978-3-031-71294-4_1

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-71294-4_1

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-71293-7

  • Online ISBN: 978-3-031-71294-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics