skip to main content
10.1145/3387514.3405852acmconferencesArticle/Chapter ViewAbstractPublication PagescommConference Proceedingsconference-collections
research-article

Switch Code Generation Using Program Synthesis

Published: 30 July 2020 Publication History

Abstract

Writing packet-processing programs for programmable switch pipelines is challenging because of their all-or-nothing nature: a program either runs at line rate if it can fit within pipeline resources, or does not run at all. It is the compiler's responsibility to fit programs into pipeline resources. However, switch compilers, which use rewrite rules to generate switch machine code, often reject programs because the rules fail to transform programs into a form that can be mapped to a pipeline's limited resources---even if a mapping actually exists.
This paper presents a compiler, Chipmunk, which formulates code generation as a program synthesis problem. Chipmunk uses a program synthesis engine, SKETCH, to transform high-level programs down to switch machine code. However, naively formulating code generation as program synthesis can lead to long compile times. Hence, we develop a new domain-specific synthesis technique, slicing, which reduces compile times by 1-387x and 51x on average.
Using a switch hardware simulator, we show that Chipmunk compiles many programs that a previous rule-based compiler, Domino, rejects. Chipmunk also produces machine code with fewer pipeline stages than Domino. A Chipmunk backend for the Tofino programmable switch shows that program synthesis can produce machine code for high-speed switches.

Supplementary Material

MP4 File (3387514.3405852.mp4)
This video presents our project Chipmunk, which leverages program synthesis to do code generation for programmable switches. In this video, we show high-level background of programmable substrates, program synthesis concept, domain-specific speeding up algorithm slicing and experiment result in two backend. We believe the promising result can help provide the chip vendor with some improvement direction for their compiler design.

References

[1]
A machine model for line-rate programmable switches. https://github.com/packet-transactions/banzai.
[2]
Amazon EC2 Spot Instances Pricing. https://aws.amazon.com/ec2/spot/pricing/.
[3]
Announcing Amazon EC2 per second billing. https://aws.amazon.com/about-aws/whats-new/2017/10/announcing-amazon-ec2-per-second-billing/.
[4]
Concurrency Model for P4. https://github.com/p4lang/p4-spec/issues/48.
[5]
DepQBF Solver. http://lonsing.github.io/depqbf/.
[6]
Domino Compiler. https://github.com/chipmunk-project/domino-compiler.
[7]
High-Capacity StrataXGS Trident 4 Ethernet Switch Series. https://www.broadcom.com/products/ethernet-connectivity/switching/strataxgs/bcm56880-series.
[8]
Intel FlexPipe. http://www.intel.com/content/dam/www/public/us/en/documents/product-briefs/ethernet-switch-fm6000-series-brief.pdf.
[9]
Jinja - Jinja Documentation (2.10.x). https://jinja.palletsprojects.com/en/2.10.x/.
[10]
lcc, A Retargetable Compiler for ANSI C. https://sites.google.com/site/lccretargetablecompiler/.
[11]
LLVM Link Time Optimization: Design and Implementation. https://llvm.org/docs/LinkTimeOptimization.html.
[12]
MarkusRabe/cadet: A fast and certifying solver for quantified Boolean formulas. https://github.com/MarkusRabe/cadet.
[13]
Mellanox Innova-2 Flex Open Programmable SmartNIC. https://www.mellanox.com/page/products_dyn?product_family=276&mtag=programmable_adapter_cards_innova2flex&ssn=7j4vr3u5elh91qnkb9ubjsdlo4.
[14]
Mellanox Products: Spectrum 2 Ethernet Switch ASIC. https://www.mellanox.com/page/products_dyn?product_family=277&mtag=spectrum2_ic.
[15]
NPL Specification. https://github.com/nplang/NPL-Spec.
[16]
P4-16 language specification. https://p4.org/p4-spec/docs/P4-16-v1.1.0-spec.html.
[17]
P4 Compiler. https://github.com/p4lang/p4c.
[18]
P4 Extern Types. https://p4.org/p4-spec/docs/P4-16-v1.0.0-spec.html#sec_extern.
[19]
P4 Studio | Barefoot. https://www.barefootnetworks.com/products/brief-p4-studio/.
[20]
P4 Tutorial. https://github.com/p4lang/tutorials.
[21]
P4_16 language specification. https://p4.org/p4-spec/docs/P4-16-v1.1.0-spec.html.
[22]
p4lang/switch: Consolidated switch repo (API, SAI and Nettlink). https://github.com/p4lang/switch.
[23]
Product Brief Tofino Page | Barefoot. https://barefootnetworks.com/products/brief-tofino/.
[24]
Programming the Forwarding Plane - Nick McKeown. https://forum.stanford.edu/events/2016/slides/plenary/Nick.pdf.
[25]
Quantified Boolean Formula. https://en.wikipedia.org/wiki/True_quantified_Boolean_formula.
[26]
[Sketchusers] Strange error for large integer constants. https://lists.csail.mit.edu/pipermail/sketchusers/2019-July/000094.html.
[27]
The P4 Language Specification. https://p4.org/p4-spec/p4-14/v1.0.5/tex/p4.pdf.
[28]
The reference P4 software switch. https://github.com/p4lang/behavioral-model.
[29]
The Z3 Theorem Prover. https://github.com/Z3Prover/z3.
[30]
Alessandro Abate, Cristina David, Pascal Kesseli, Daniel Kroening, and Elizabeth Polgreen. Counterexample Guided Inductive Synthesis Modulo Theories. In Computer Aided Verification, 2018.
[31]
Alfred V. Aho, Monica S. Lam, Ravi Sethi, and Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools (2nd Edition). Addison-Wesley Longman Publishing Co., Inc., USA, 2006.
[32]
Mohammad Alizadeh, Tom Edsall, Sarang Dharmapurikar, Ramanan Vaidyanathan, Kevin Chu, Andy Fingerhut, Vinh The Lam, Francis Matus, Rong Pan, Navindra Yadav, and George Varghese. CONGA: Distributed Congestion-aware Load Balancing for Datacenters. In SIGCOMM, 2014.
[33]
Jesus M. Almendros-Jimenez, Josep Silva, and Salvador Tamarit. XQuery Optimization Based on Program Slicing. In CIKM, 2011.
[34]
Mina Tahmasbi Arashloo, Yaron Koral, Michael Greenberg, Jennifer Rexford, and David Walker. SNAP: Stateful network-wide abstractions for packet processing. In SIGCOMM, 2016.
[35]
Sorav Bansal and Alex Aiken. Automatic Generation of Peephole Superoptimizers. In ASPLOS, 2006.
[36]
Leyla Bilge, Engin Kirda, Christopher Kruegel, and Marco Balduzzi. EXPOSURE: Finding Malicious Domains Using Passive DNS Analysis. In NDSS, 2011.
[37]
Rudiger Birkner, Dana Drachsler Cohen, Laurent Vanbever, and Martin Vechev. Config2Spec: Mining Network Specifications from Network Configurations. In NSDI, 2020.
[38]
Pat Bosshart, Dan Daly, Glen Gibb, Martin Izzard, Nick McKeown, Jennifer Rexford, Cole Schlesinger, Dan Talayco, Amin Vahdat, George Varghese, and David Walker. P4: Programming Protocol-independent Packet Processors. SIGCOMM CCR, 2014.
[39]
Pat Bosshart, Glen Gibb, Hun-Seok Kim, George Varghese, Nick McKeown, Martin Izzard, Fernando Mujica, and Mark Horowitz. Forwarding Metamorphosis: Fast Programmable Match-action Processing in Hardware for SDN. In SIGCOMM, 2013.
[40]
Sharad Chole, Andy Fingerhut, Sha Ma, Anirudh Sivaraman, Shay Vargaftik, Alon Berger, Gal Mendelson, Mohammad Alizadeh, Shang-Tse Chuang, Isaac Keslassy, Ariel Orda, and Tom Edsall. dRMT: Disaggregated Programmable Switching. In SIGCOMM, 2017.
[41]
Jack W. Davidson and Christopher W. Fraser. The Design and Application of a Retargetable Peephole Optimizer. TOPLAS, 1980.
[42]
Ahmed El-Hassany, Petar Tsankov, Laurent Vanbever, and Martin Vechev. Net-Complete: Practical Network-Wide Configuration Synthesis with Autocompletion. In NSDI, 2018.
[43]
Grigory Fedyukovich, Maaz Bin Safeer Ahmad, and Rastislav Bodik. Gradual Synthesis for Static Parallelization of Single-pass Array-processing Programs. In PLDI, 2017.
[44]
Wu-chang Feng, Kang G. Shin, Dilip D. Kandlur, and Debanjan Saha. The BLUE Active Queue Management Algorithms. IEEE/ACM Transactions on Networking, 2002.
[45]
Jiaqi Gao, Ennan Zhai, Hongqiang Harry Liu, Rui Miao, Yu Zhou, Bingchuan Tian, Chen Sun, Dennis Cai, Ming Zhang, and Minlan Yu. Lyra: A Cross-Platform Language and Compiler for Data Plane Programming on Heterogeneous ASICs. In SIGCOMM, 2020.
[46]
Xiangyu Gao, Taegyun Kim, Aatish Kishan Varma, Anirudh Sivaraman, and Srinivas Narayana. Autogenerating Fast Packet-Processing Code Using Program Synthesis. In HotNets, 2019.
[47]
Pawan Goyal, Harrick M. Vin, and Haichen Chen. Start-time Fair Queueing: A Scheduling Algorithm for Integrated Services Packet Switching Networks. In SIGCOMM, 1996.
[48]
Sumit Gulwani, Susmit Jha, Ashish Tiwari, and Ramarathnam Venkatesan. Synthesis of Loop-Free Programs. In PLDI, 2011.
[49]
Gary D. Hachtel and Fabio Somenzi. Logic synthesis and verification algorithms. Springer, 2006.
[50]
Qinheping Hu, Jason Breck, John Cyphert, Loris D'Antoni, and Thomas Reps. Proving Unrealizability for Syntax-Guided Synthesis. In CAV, 2019.
[51]
Stephen Ibanez, Gordon Brebner, Nick McKeown, and Noa Zilberman. The P4->NetFPGA Workflow for Line-Rate Packet Processing. In FPGA, 2019.
[52]
Stephen Ibanez, Muhammad Shahbaz, and Nick McKeown. The Case for a Network Fast Path to the CPU. In HotNets, 2019.
[53]
Jinseong Jeon, Xiaokang Qiu, Armando Solar-Lezama, and Jeffrey S. Foster. Adaptive Concretization for Parallel Program Synthesis. In CAV, 2015.
[54]
Xin Jin, Xiaozhou Li, Haoyu Zhang, Nate Foster, Jeongkeun Lee, Robert Soulé, Changhoon Kim, and Ion Stoica. NetChain: Scale-Free Sub-RTT Coordination. In NSDI, 2018.
[55]
Xin Jin, Xiaozhou Li, Haoyu Zhang, Robert Soulé, Jeongkeun Lee, Nate Foster, Changhoon Kim, and Ion Stoica. NetCache: Balancing Key-Value Stores with Fast In-Network Caching. In SOSP, 2017.
[56]
Lavanya Jose, Lisa Yan, George Varghese, and Nick McKeown. Compiling Packet Programs to Reconfigurable Switches. In NSDI, 2015.
[57]
Shoaib Kamil, Alvin Cheung, Shachar Itzhaky, and Armando Solar-Lezama. Verified Lifting of Stencil Computations. In PLDI, 2016.
[58]
Anirudh Sivaraman Kaushalram. Designing Fast and Programmable Routers. PhD thesis, EECS Department, Massachusetts Institute of Technology, September 2017.
[59]
Srinivas Narayana, Anirudh Sivaraman, Vikram Nathan, Prateesh Goyal, Venkat Arun, Mohammad Alizadeh, Vimalkumar Jeyakumar, and Changhoon Kim. Language-Directed Hardware Design for Network Performance Monitoring. In SIGCOMM, 2017.
[60]
U.S. Bureau of Labor Statistics. Occupational Employment and Wages, May 2018, Software developers, Systems software. https://www.bls.gov/oes/current/oes151133.htm.
[61]
Aurojit Panda, Ori Lahav, Katerina Argyraki, Mooly Sagiv, and Scott Shenker. Verifying Reachability in Networks with Mutable Datapaths. In NSDI, 2017.
[62]
Phitchaya Mangpo Phothilimthana, Archibald Samuel Elliott, An Wang, Abhinav Jangda, Bastian Hagedorn, Henrik Barthels, Samuel J. Kaufman, Vinod Grover, Emina Torlak, and Rastislav Bodik. Swizzle Inventor: Data Movement Synthesis for GPU Kernels. In ASPLOS, 2019.
[63]
Phitchaya Mangpo Phothilimthana, Aditya Thakur, Rastislav Bodik, and Dinakar Dhurjati. Scaling Up Superoptimization. In ASPLOS, 2016.
[64]
Gordon D. Plotkin, Nikolaj Bjørner, Nuno P. Lopes, Andrey Rybalchenko, and George Varghese. Scaling Network Verification Using Symmetry and Surgery. In POPL, 2016.
[65]
Regehr, John. Synthesizing Constants. https://blog.regehr.org/archives/1636.
[66]
Shambwaditya Saha, Santhosh Prabhu, and P. Madhusudan. NetGen: Synthesizing Data-plane Configurations for Network Policies. In SOSR, 2015.
[67]
Eric Schkufza, Rahul Sharma, and Alex Aiken. Stochastic Superoptimization. In ASPLOS, 2013.
[68]
Shan Sinha, Srikanth Kandula, and Dina Katabi. Harnessing TCPs Burstiness using Flowlet Switching. In HotNets, 2004.
[69]
Anirudh Sivaraman, Alvin Cheung, Mihai Budiu, Changhoon Kim, Mohammad Alizadeh, Hari Balakrishnan, George Varghese, Nick McKeown, and Steve Licking. Packet Transactions: High-Level Programming for Line-Rate Switches. In SIGCOMM, 2016.
[70]
Armando Solar Lezama. Program Synthesis By Sketching. PhD thesis, EECS Department, University of California, Berkeley, Dec 2008.
[71]
Armando Solar-Lezama, Christopher Grant Jones, and Rastislav Bodik. Sketching Concurrent Data Structures. In PLDI, 2008.
[72]
Armando Solar-Lezama, Liviu Tancau, Rastislav Bodik, Sanjit Seshia, and Vijay Saraswat. Combinatorial Sketching for Finite Programs. In ASPLOS, 2006.
[73]
Haoyu Song. Protocol-oblivious Forwarding: Unleash the Power of SDN Through a Future-proof Forwarding Plane. In HotSDN, 2013.
[74]
Kausik Subramanian, Loris D'Antoni, and Aditya Akella. Genesis: Synthesizing Forwarding Tables in Multi-tenant Networks. In POPL, 2017.
[75]
Kausik Subramanian, Loris D'Antoni, and Aditya Akella. Synthesis of Fault-Tolerant Distributed Router Configurations. In SIGMETRICS, 2018.
[76]
C.H. Tai, J. Zhu, and N. Dukkipati. Making Large Scale Deployment of RCP Practical for Real Networks. In INFOCOM, 2008.
[77]
Mark Weiser. Program Slicing. In ICSE, 1981.
[78]
Michael D. Wong, Aatish Kishan Varma, and Anirudh Sivaraman. Testing compilers for programmable switches through switch hardware simulation. ArXiv, abs/2005.02310, 2020.

Cited By

View all
  • (2025)Altair: Resource-efficient optimization and deployment for data plane programsComputer Networks10.1016/j.comnet.2024.110917257(110917)Online publication date: Feb-2025
  • (2024)SiriusProceedings of the 21st USENIX Symposium on Networked Systems Design and Implementation10.5555/3691825.3691852(477-490)Online publication date: 16-Apr-2024
  • (2024)Lightweight Automated Reasoning for Network ArchitecturesProceedings of the 23rd ACM Workshop on Hot Topics in Networks10.1145/3696348.3696865(237-245)Online publication date: 18-Nov-2024
  • Show More Cited By

Index Terms

  1. Switch Code Generation Using Program Synthesis

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    SIGCOMM '20: Proceedings of the Annual conference of the ACM Special Interest Group on Data Communication on the applications, technologies, architectures, and protocols for computer communication
    July 2020
    814 pages
    ISBN:9781450379557
    DOI:10.1145/3387514
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 30 July 2020

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Programmable switches
    2. code generation
    3. packet processing pipelines
    4. program synthesis
    5. slicing

    Qualifiers

    • Research-article
    • Research
    • Refereed limited

    Conference

    SIGCOMM '20
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 462 of 3,389 submissions, 14%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)137
    • Downloads (Last 6 weeks)8
    Reflects downloads up to 13 Feb 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2025)Altair: Resource-efficient optimization and deployment for data plane programsComputer Networks10.1016/j.comnet.2024.110917257(110917)Online publication date: Feb-2025
    • (2024)SiriusProceedings of the 21st USENIX Symposium on Networked Systems Design and Implementation10.5555/3691825.3691852(477-490)Online publication date: 16-Apr-2024
    • (2024)Lightweight Automated Reasoning for Network ArchitecturesProceedings of the 23rd ACM Workshop on Hot Topics in Networks10.1145/3696348.3696865(237-245)Online publication date: 18-Nov-2024
    • (2024)Cross-Platform Transpilation of Packet-Processing Programs using Program SynthesisProceedings of the 8th Asia-Pacific Workshop on Networking10.1145/3663408.3663419(74-80)Online publication date: 3-Aug-2024
    • (2024)Eagle: Toward Scalable and Near-Optimal Network-Wide Sketch Deployment in Network MeasurementProceedings of the ACM SIGCOMM 2024 Conference10.1145/3651890.3672244(291-310)Online publication date: 4-Aug-2024
    • (2024)P4runpro: Enabling Runtime Programmability for RMT Programmable SwitchesProceedings of the ACM SIGCOMM 2024 Conference10.1145/3651890.3672230(921-937)Online publication date: 4-Aug-2024
    • (2024)Exploring Dynamic Rule Caching Under Dependency Constraints for Programmable Switches: Theory, Algorithm, and ImplementationIEEE Transactions on Network and Service Management10.1109/TNSM.2024.342209221:4(4830-4843)Online publication date: Aug-2024
    • (2024)Charting the Complexity Landscape of Compiling Packet Programs to Reconfigurable SwitchesIEEE/ACM Transactions on Networking10.1109/TNET.2024.342433732:5(4519-4534)Online publication date: Oct-2024
    • (2024)Resource-Efficient and Timely Packet Header Vector (PHV) Encoding on Programmable SwitchesIEEE/ACM Transactions on Networking10.1109/TNET.2024.341353032:5(4191-4206)Online publication date: Oct-2024
    • (2024)Optimizing Quantum Fourier Transformation (QFT) Kernels for Modern NISQ and FT ArchitecturesProceedings of the International Conference for High Performance Computing, Networking, Storage, and Analysis10.1109/SC41406.2024.00074(1-15)Online publication date: 17-Nov-2024
    • Show More Cited By

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Figures

    Tables

    Media

    Share

    Share

    Share this Publication link

    Share on social media