skip to main content
10.1145/2627373.2627390acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
tutorial

Compiling a Subset of APL Into a Typed Intermediate Language

Published: 09 June 2014 Publication History

Abstract

We present a compiler and a typed intermediate language for a subset of APL. The intermediate language treats all numeric data as multi-dimensional arrays and the type system makes explicit the ranks of arrays. Primitive operators are polymorphic in rank and in the type of the underlying data operated on.
The frontend of the APL compiler deals with much of the gory details of the APL language, including infix resolution, resolution of identity items for reduce operations, resolution of default element values for empty arrays, scalar extensions, and resolution of certain kinds of overloading.
We demonstrate the usefulness of the intermediate language by showing that it can be compiled efficiently, using known techniques, such as delayed arrays, into a C-like language. We also demonstrate that the language is sufficiently expressive that some primitive operators, such as APL's inner product operator, which works on arrays of arbitrary dimensions, can be compiled using more primitive operators.

References

[1]
Robert Bernecky. APEX: The APL parallel executor. Master's thesis, Graduate Department of Computer Science University of Toronto, 1997.
[2]
Robert Bernecky and Stephen B. Jaffe. ACORN: APL to C on real numbers. In ACM SIGAPL Quote Quad, pages 40--49, 1990.
[3]
Chris Burke and Roger Hui. J for the apl programmer. SIGAPL APL Quote Quad, 27(1):11--17, September 1996.
[4]
Manuel M.T. Chakravarty, Gabriele Keller, Sean Lee, Trevor L. McDonell, and Vinod Grover. Accelerating Haskell array codes with multicore GPUs. In Proceedings of the Sixth Workshop on Declarative Aspects of Multicore Programming, DAMP'11, pages 3--14. ACM, 2011.
[5]
Koen Claessen, Mary Sheeran, and Joel Svensson. Expressive array constructs in an embedded GPU kernel programming language. In Proceedings of the 7th workshop on Declarative aspects and applications of multicore programming, DAMP'12. ACM, 2012.
[6]
Conal Elliott. Functional images. In The Fun of Programming, "Cornerstones of Computing" series. Palgrave, March 2003.
[7]
Clemens Grelck and Sven-Bodo Scholz. Accelerating APL programs with SAC. In Proceedings of the Conference on APL '99: On Track to the 21st Century, APL'99, pages 50--57. ACM, 1999.
[8]
Leo J. Guibas and Douglas K. Wyatt. Compilation and delayed evaluation in APL. In Proceedings of the 5th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, POPL'78, pages 1--8. ACM, 1978.
[9]
Troels Henriksen and Cosmin E. Oancea. A T2 graph-reduction approach to fusion. In 2nd ACM SIGPLAN Workshop on Functional High-Performance Computing, September 2013.
[10]
Troels Henriksen and Cosmin E. Oancea. Bounds checking: An instance of hybrid analysis. In Proceedings of the 1st ACM SIGPLAN International Workshop on Libraries, Languages and Compilers for Array Programming, ARRAY'14. ACM, 2014.
[11]
Kenneth E. Iverson. A Programming Language. John Wiley and Sons, Inc, May 1962.
[12]
Gabriele Keller, Manuel M. T. Chakravarty, Roman Leshchinskiy, and Simon Peyton Jones. Regular, shape-polymorphic, parallel arrays in Haskell. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP'2010, September 2010.
[13]
Bernard Legrand. Mastering Dyalog APL. Dyalog Limited, November 2009.
[14]
Geoffrey Mainland and Greg Morrisett. Nikola: Embedding compiled GPU functions in Haskell. In Proceedings of the Third ACM Haskell Symposium on Haskell, Haskell'10, pages 67--78. ACM, 2010.
[15]
Greg Morrisett. Compiling with Types. PhD thesis, School of Computer Science, Carnegie Mellon University, USA, December 1995.
[16]
Justin Slepak, Olin Shivers, and Panagiotis Manolios. An array-oriented language with static rank polymorphism. In Programming Languages and Systems, volume 8410 of Lecture Notes in Computer Science, pages 27--46. Springer-Verlag, 2014.
[17]
Peter Thiemann and Manuel M. T. Chakravarty. Agda meets accelerate. In Proceedings of the 24th Symposium on Implementation and Application of Functional Languages, IFL'2012, 2013. Revised Papers, Springer-Verlag, LNCS 8241.
[18]
Kai Trojahner and Clemens Grelck. Dependently typed array programs don't go wrong. The Journal of Logic and Algebraic Programming, 78(7):643--664, 2009. The 19th Nordic Workshop on Programming Theory (NWPT'2007).
[19]
Kai Trojahner and Clemens Grelck. Descriptor-free representation of arrays with dependent types. In Proceedings of the 20th International Conference on Implementation and Application of Functional Languages, IFL'08, pages 100--117. Springer-Verlag, 2011.
[20]
Arthur Whitney. K. The Journal of the British APL Association, 10(1):74--79, July 1993.

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
  • (2023)Shape-Constrained Array Programming with Size-Dependent TypesProceedings of the 11th ACM SIGPLAN International Workshop on Functional High-Performance and Numerical Computing10.1145/3609024.3609412(29-41)Online publication date: 30-Aug-2023
  • (2021)Towards size-dependent types for array programmingProceedings of the 7th ACM SIGPLAN International Workshop on Libraries, Languages and Compilers for Array Programming10.1145/3460944.3464310(1-14)Online publication date: 17-Jun-2021
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
ARRAY'14: Proceedings of ACM SIGPLAN International Workshop on Libraries, Languages, and Compilers for Array Programming
June 2014
112 pages
ISBN:9781450329378
DOI:10.1145/2627373
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 ACM 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: 09 June 2014

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. APL
  2. Compilation
  3. Fusion
  4. Lambda Calculus
  5. Optimization

Qualifiers

  • Tutorial
  • Research
  • Refereed limited

Conference

PLDI '14
Sponsor:

Acceptance Rates

ARRAY'14 Paper Acceptance Rate 17 of 25 submissions, 68%;
Overall Acceptance Rate 17 of 25 submissions, 68%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)11
  • Downloads (Last 6 weeks)0
Reflects downloads up to 20 Feb 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
  • (2023)Shape-Constrained Array Programming with Size-Dependent TypesProceedings of the 11th ACM SIGPLAN International Workshop on Functional High-Performance and Numerical Computing10.1145/3609024.3609412(29-41)Online publication date: 30-Aug-2023
  • (2021)Towards size-dependent types for array programmingProceedings of the 7th ACM SIGPLAN International Workshop on Libraries, Languages and Compilers for Array Programming10.1145/3460944.3464310(1-14)Online publication date: 17-Jun-2021
  • (2019)TeIL: a type-safe imperative tensor intermediate languageProceedings of the 6th ACM SIGPLAN International Workshop on Libraries, Languages and Compilers for Array Programming10.1145/3315454.3329959(57-68)Online publication date: 8-Jun-2019
  • (2018)Static interpretation of higher-order modules in Futhark: functional GPU programming in the largeProceedings of the ACM on Programming Languages10.1145/32367922:ICFP(1-30)Online publication date: 30-Jul-2018
  • (2018)Rank polymorphism viewed as a constraint problemProceedings of the 5th ACM SIGPLAN International Workshop on Libraries, Languages, and Compilers for Array Programming10.1145/3219753.3219758(34-41)Online publication date: 19-Jun-2018
  • (2018)A Rosetta Stone for array languagesProceedings of the 5th ACM SIGPLAN International Workshop on Libraries, Languages, and Compilers for Array Programming10.1145/3219753.3219754(1-10)Online publication date: 19-Jun-2018
  • (2017)Futhark: purely functional GPU-programming with nested parallelism and in-place array updatesACM SIGPLAN Notices10.1145/3140587.306235452:6(556-571)Online publication date: 14-Jun-2017
  • (2017)Futhark: purely functional GPU-programming with nested parallelism and in-place array updatesProceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation10.1145/3062341.3062354(556-571)Online publication date: 14-Jun-2017
  • (2017)APLicative Programming with Naperian FunctorsProgramming Languages and Systems10.1007/978-3-662-54434-1_21(556-583)Online publication date: 19-Mar-2017
  • 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