skip to main content
10.1145/3460944.3464310acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article

Towards size-dependent types for array programming

Published: 18 June 2021 Publication History

Abstract

We present a type system for expressing size constraints on array types in an ML-style type system. The goal is to detect shape mismatches at compile-time, while being simpler than full dependent types. The main restrictions is that the only terms that can occur in types are array sizes, and syntactically they must be variables or constants. For those programs where this is not sufficient, we support a form of existential types, with the type system automatically managing the requisite book-keeping. We formalise a large subset of the type system in a small core language, which we prove sound. We also present an integration of the type system in the high-performance parallel functional language Futhark, and show on a collection of 44 representative programs that the restrictions in the type system are not too problematic in practice.

References

[1]
Christian Andreetta, Vivien Bégot, Jost Berthold, Martin Elsman, Fritz Henglein, Troels Henriksen, Maj-Britt Nordfang, and Cosmin E. Oancea. 2016. FinPar: A Parallel Financial Benchmark. ACM Trans. Archit. Code Optim., 13, 2 (2016), Article 18, June, 27 pages. issn:1544-3566 https://doi.org/10.1145/2898354
[2]
Andrew W. Appel and David McAllester. 2001. An Indexed Model of Recursive Types for Foundational Proof-Carrying Code. ACM Trans. Program. Lang. Syst., 23, 5 (2001), Sept., 657–683. issn:0164-0925 https://doi.org/10.1145/504709.504712
[3]
Manuel M.T. Chakravarty, Gabriele Keller, Sean Lee, Trevor L. McDonell, and Vinod Grover. 2011. Accelerating Haskell Array Codes with Multicore GPUs. In Proceedings of the Sixth Workshop on Declarative Aspects of Multicore Programming (DAMP ’11). Association for Computing Machinery, New York, NY, USA. 3–14. isbn:9781450304863 https://doi.org/10.1145/1926354.1926358
[4]
S. Che, M. Boyer, J. Meng, D. Tarjan, J. W. Sheaffer, S. H. Lee, and K. Skadron. 2009. Rodinia: A benchmark suite for heterogeneous computing. In Workload Characterization, 2009. IISWC 2009. IEEE International Symposium on. 44–54. https://doi.org/10.1109/IISWC.2009.5306797
[5]
Kevin Donnelly and Hongwei Xi. 2007. A Formalization of Strong Normalization for Simply-Typed Lambda-Calculus and System F. Electronic Notes in Theoretical Computer Science, 174, 5 (2007), 109–125. issn:1571-0661 https://doi.org/10.1016/j.entcs.2007.01.021 Proceedings of the First International Workshop on Logical Frameworks and Meta-Languages: Theory and Practice (LFMTP 2006).
[6]
D. Dreyer, A. Ahmed, and L. Birkedal. 2009. Logical Step-Indexed Logical Relations. In 2009 24th Annual IEEE Symposium on Logic In Computer Science. 71–80. https://doi.org/10.1109/LICS.2009.34
[7]
Martin Elsman and Martin Dybdal. 2014. Compiling a Subset of APL Into a Typed Intermediate Language. In Proceedings of ACM SIGPLAN International Workshop on Libraries, Languages, and Compilers for Array Programming (ARRAY’14). Association for Computing Machinery, New York, NY, USA. 101–106. isbn:9781450329378 https://doi.org/10.1145/2627373.2627390
[8]
Martin Elsman, Troels Henriksen, Danil Annenkov, and Cosmin E. Oancea. 2018. Static Interpretation of Higher-Order Modules in Futhark: Functional GPU Programming in the Large. Proc. ACM Program. Lang., 2, ICFP (2018), Article 97, July, 30 pages. https://doi.org/10.1145/3236792
[9]
Jeremy Gibbons. 2016. APLicative Programming with Naperian Functors (Extended Abstract). In Proceedings of the 1st International Workshop on Type-Driven Development (TyDe 2016). Association for Computing Machinery, New York, NY, USA. 13–14. isbn:9781450344357 https://doi.org/10.1145/2976022.2976023
[10]
Jean Yves Girard. 1971. Interpretation Fonctionnelle et Elimination des Coupures de l’Arithmetique d’Ordre Superieur. In Proceedings of the Second Scandinavian Logic Symposium. North-Holland, 63–92.
[11]
Troels Henriksen, Martin Dybdal, Henrik Urms, Anna Sofie Kiehn, Daniel Gavin, Hjalte Abelskov, Martin Elsman, and Cosmin Oancea. 2016. APL on GPUs: A TAIL from the Past, Scribbled in Futhark. In Proceedings of the 5th International Workshop on Functional High-Performance Computing (FHPC 2016). Association for Computing Machinery, New York, NY, USA. 38–43. isbn:9781450344333 https://doi.org/10.1145/2975991.2975997
[12]
Troels Henriksen, Martin Elsman, and Cosmin E. Oancea. 2014. Size Slicing: A Hybrid Approach to Size Inference in Futhark. In Proceedings of the 3rd ACM SIGPLAN Workshop on Functional High-performance Computing (FHPC ’14). ACM, New York, NY, USA. 31–42. isbn:978-1-4503-3040-4 https://doi.org/10.1145/2636228.2636238
[13]
Troels Henriksen, Niels G. W. Serup, Martin Elsman, Fritz Henglein, and Cosmin E. Oancea. 2017. Futhark: Purely Functional GPU-programming with Nested Parallelism and In-place Array Updates. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2017). ACM, New York, NY, USA. 556–571. isbn:978-1-4503-4988-8 https://doi.org/10.1145/3062341.3062354
[14]
Anders Kiel Hovgaard, Troels Henriksen, and Martin Elsman. 2018. High-performance defunctionalization in Futhark. In Symposium on Trends in Functional Programming (TFP’18). Springer-Verlag.
[15]
C.B. Jay. 1999. Denotational Semantics of Shape:: Past, Present and Future. Electronic Notes in Theoretical Computer Science, 20 (1999), 320–333. issn:1571-0661 https://doi.org/10.1016/S1571-0661(04)80081-1 MFPS XV, Mathematical Foundations of Progamming Semantics, Fifteenth Conference.
[16]
C. Barry Jay. 1995. A Semantics for Shape. Science of Computer Programming, 25 (1995), 25–251.
[17]
C. Barry Jay and Milan Sekanina. 1997. Shape Checking of Array Programs. In Computing: the Australasian Theory Seminar, Proceedings.
[18]
Xavier Leroy. 1992. Unboxed Objects and Polymorphic Typing. In Proceedings of the 19th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’92). Association for Computing Machinery, New York, NY, USA. 177–188. isbn:0897914538 https://doi.org/10.1145/143165.143205
[19]
Dougal Maclaurin, Alexey Radul, Matthew J. Johnson, and Dimitrios Vytiniotis. 2019. Dex: array programming with typed indices. In Poster session at Workshop on Program Transformations for Machine Learning. Associated with NeurIPS ’2019.
[20]
Lenore Mullin. 1988. A mathematics of arrays. School of Computer and Information Science, Syracuse University.
[21]
Amr Sabry and Matthias Felleisen. 1993. Reasoning about Programs in Continuation-Passing Style. In LISP AND SYMBOLIC COMPUTATION. 288–298.
[22]
Sven-Bodo Scholz. 1994. Single Assignment C - Functional Programming Using Imperative Style. In In John Glauert (Ed.): Proceedings of the 6th International Workshop on the Implementation of Functional Languages. University of East Anglia.
[23]
Justin Slepak, Olin Shivers, and Panagiotis Manolios. 2014. An Array-Oriented Language with Static Rank Polymorphism. In Programming Languages and Systems, Zhong Shao (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg. 27–46. isbn:978-3-642-54833-8
[24]
John A Stratton, Christopher Rodrigues, I-Jui Sung, Nady Obeid, Li-Wen Chang, Nasser Anssari, Geng Daniel Liu, and Wen-mei W Hwu. 2012. Parboil: A revised benchmark suite for scientific and commercial throughput computing. Center for Reliable and High-Performance Computing, 127 (2012).
[25]
William W. Tait. 1967. Intensional interpretations of functionals of finite type. Journal of symbolic logic, 32 (1967), 198–212.
[26]
Kai Trojahner and Clemens Grelck. 2009. Dependently typed array programs don’t go wrong. J. Log. Algebr. Program., 78 (2009), 08, 643–664. https://doi.org/10.1016/j.jlap.2009.03.002
[27]
Hongwei Xi and Frank Pfenning. 1998. Eliminating Array Bound Checking through Dependent Types. In Proceedings of the ACM SIGPLAN 1998 Conference on Programming Language Design and Implementation (PLDI ’98). Association for Computing Machinery, New York, NY, USA. 249–257. isbn:0897919874 https://doi.org/10.1145/277650.277732

Cited By

View all
  • (2024)AUTOMAP: Inferring Rank-Polymorphic Function Applications with Integer Linear ProgrammingProceedings of the ACM on Programming Languages10.1145/36897748:OOPSLA2(1787-1813)Online publication date: 8-Oct-2024
  • (2024)A Safe Low-Level Language for Computer Algebra and Its Formally Verified CompilerProceedings of the ACM on Programming Languages10.1145/36746298:ICFP(121-146)Online publication date: 15-Aug-2024
  • (2023)Rank-Polymorphism for Shape-Guided BlockingProceedings of the 11th ACM SIGPLAN International Workshop on Functional High-Performance and Numerical Computing10.1145/3609024.3609410(1-14)Online publication date: 30-Aug-2023
  • Show More Cited By

Index Terms

  1. Towards size-dependent types for array programming

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    ARRAY 2021: Proceedings of the 7th ACM SIGPLAN International Workshop on Libraries, Languages and Compilers for Array Programming
    June 2021
    50 pages
    ISBN:9781450384667
    DOI:10.1145/3460944
    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: 18 June 2021

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. functional programming
    2. parallel programming
    3. type systems

    Qualifiers

    • Research-article

    Conference

    PLDI '21
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 17 of 25 submissions, 68%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)34
    • Downloads (Last 6 weeks)18
    Reflects downloads up to 20 Jan 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)AUTOMAP: Inferring Rank-Polymorphic Function Applications with Integer Linear ProgrammingProceedings of the ACM on Programming Languages10.1145/36897748:OOPSLA2(1787-1813)Online publication date: 8-Oct-2024
    • (2024)A Safe Low-Level Language for Computer Algebra and Its Formally Verified CompilerProceedings of the ACM on Programming Languages10.1145/36746298:ICFP(121-146)Online publication date: 15-Aug-2024
    • (2023)Rank-Polymorphism for Shape-Guided BlockingProceedings of the 11th ACM SIGPLAN International Workshop on Functional High-Performance and Numerical Computing10.1145/3609024.3609410(1-14)Online publication date: 30-Aug-2023
    • (2023)Typing Composable Coroutines2023 12th International Conference on Computer Technologies and Development (TechDev)10.1109/TechDev61156.2023.00011(16-23)Online publication date: 14-Oct-2023
    • (2022)ReftyProceedings of the 44th International Conference on Software Engineering10.1145/3510003.3510077(1843-1855)Online publication date: 21-May-2022

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media