Mgradman1.Pdf

Total Page:16

File Type:pdf, Size:1020Kb

Mgradman1.Pdf Gradman - 1 Literate Programming by Mike Gradman Introduction Computer programming has often seen its share of code that is hard to understand and read due to poor documentation and style. Unfortunately, this not so straightforward code is found in most programs. Frequently, programmers write code that only they can understand, not considering others who may work with the code or read through it. Even if the programmer tries to clearly explain what he is doing through writing comments in the code or uses good style, others may not be able to make sense out of the code. Nasty bugs might pop up that would be hard to fix or a developer might need to know what is going on inside a particular piece of code. He might have to nag the original programmer to clarify points about the program if he is even reachable at all. Also, in the software development process, either management, the designers, or programmers have to keep up with many different kinds of documents, or artifacts throughout the lifecycle. For example, something in the requirements for the application might either be misunderstood or totally overlooked in the code as the developers have to refer to a separate document to see what needs to be implemented. Similar inconsistencies can occur due to the myriad of documents that are produced in the software life cycle. Most of these problems occur due to a lack of proper understanding of the application being developed or used or the code written for that application. A paradigm called “literate programming” helps developers, teachers, and students in the process of solving various problems and understanding their solutions, especially if they have to build on or otherwise comprehend other people’s work. Programming Languages: Conventional Attempts at Understanding Programs Before Programming Languages In the early years of the Computer Age, programmers had to use machine language to instruct the computers what they wanted them to do, which involved commands such as moving values into registers, manipulating memory, or handling control flow in a complicated manner. At that time, there was no essence of entities or other abstractions that could give the layperson or even expert programmers a true understanding of the problem at hand. FORTRAN Then, in the 1950’s, the first attempts to develop high-level programming languages were made with the aim to allow the programmer to think more in terms of what the program needed to do and how to do it. One of these first languages was FORTRAN, with abstractions such as data types and control structures in the form of simple English language (such as the DO-loop and the IF-THEN statement) which represented common idioms that the programmer could grasp [Mac87]1. For example, if 1 Using a documentation style used in many IEEE journals … take first three letters of last name of first author listed concatenated with the year of publication … article by Edward Jones and Robert Smith from 1998 would be listed as [Jon98]. References list uses this shorthand followed by the citation in MLA format. Gradman - 2 the programmer wanted to double the value of each element of a ten-element array A, he would write: DO 100 I=1, 10 A(I) = A(I) * 2 100 CONTINUE Also, the IF-statement could clearly express limited forms of control such as taking the absolute value of a variable named VALUE: IF (VALUE.LT.0) VALUE = -VALUE Structures like these allowed the developer to state what he wanted to do in a clear and concise fashion by 1950’s standards. Also, the developer could break up his work and design pieces of the application at a time by using subroutines [Mac87] and either try to understand each small part of the program and how it fits in the whole (bottom-up design) or get the general idea of what the program needs to do and then handle more specific matters as he develops the application (top-down design). However, the control structures in FORTRAN were primitive and produced code that was hard to follow (thanks to GOTO’s) along with and difficult to comprehend [Mac87]. COBOL Another attempt in the late 1950’s was COBOL. This language’s main goal was to produce code that resembled the English language in a natural-seeming form. COBOL was meant to be a self-documenting language, code that made it clear on its own what was being done in the program and thus easy to understand. However, the syntax was very verbose which made it hard to program in the first place, especially due to certain divisions of the code. An example of the verbosity of COBOL’s “natural language” is a program that reads customer records and computes average sales, that is sales per call [Bel89]. Several pieces stand out. First, about ten lines of code spell out how the input file is formatted. The file itself is a simple chart that has the customer information and total sales and number of sales calls. More heinous though is the output file, which is another simple chart. This chart summarizes the customer information and has the average sales per call listed. It looks something like: CUSTOMER LIST CUSTOMER CUST. NAME ADDRESS CITY STATE ZIP AVG. SALES/CALL 00001 John Doe 1 Here St. Houston TX 77333 0931.11 00002 Mary Suarez 2 2nd Ave. New York NY 01931 4943.32 However, even this easy output chart takes over thirty lines of code to describe. Here is just a small snippet from the code that describes the format of the output chart: Gradman - 3 01 DETAIL-LINE. 05 FILLER PIC X(2) VALUE SPACES. 05 CUSTOMER-NUMBER PIC 9(5) VALUE ZEROS. 05 FILLER PIC X(3) VALUESPACES. 05 CUSTOMER-NAME PIC X(30) VALUE ZEROS. [some more code … snipped for space] 05 CUSTOMER-SALES PIC 9999.99 VALUE ZEROS. 05 FILLER PIC X(11) VALUE SPACES. [Bel89]. This code describes the formatting for each row of the table and must be specified correctly in order for the chart to properly appear. Also from this same example, the code to populate a line of the table looks like: FORMAT-DETAIL-LINE-MODULE MOVE I-CUSTOMER-NUMBER TO CUSTOMER-NUMBER. MOVE I-CUSTOMER-NAME TO CUSTOMER-NAME. [same for rest of fields of table] DIVIDE I-TOTAL-SALES BY I-SALES-CALLS GIVING AVERAGE-SALES. MOVE AVERAGE-SALES TO CUSTOMER-SALES. MOVE DETAIL-LINE TO 0-PRINTER-RECORD. MOVE 1 TO LINE-SPACING. PREFORM PRINTING-MODULE. [Bel89]. Again, the syntax is very verbose and must be written exactly for the program to work. In other languages, such as C or Pascal, this routine would be much clearer by the use of mathematical notation and assignment statements (In C, the division would be done by a statement like “average_sales = i_total_sales / i_sales_calls”). From the customer sales example, one can see that COBOL’s “natural language” was really hard to understand and use instead of the program being self-documenting and easy to comprehend. Thus, even though the ideals established for COBOL were in the direction of making code easier to understand, the realization of that goal fell well short of its expectations. Procedural Programming Over the next twenty to thirty years, other languages appeared which made code easier to understand and work with. Algol provided more intuitive control structures such as the FOR and WHILE loops and the IF-ELSE statement, eliminating the need for the GOTO’s which would have made code harder to follow. Pascal and Ada added Gradman - 4 facilities to declare abstract data types (ADT’s) [Mac87], adding yet another way to make applications easier to design and understand. For example, in Pascal a programmer can declare new data types using the “type” keyword: {Example taken from [Mac87] and modified with comments} type { a person type } person = record name: string; age: 16..100; {age can be from 16 to 100} salary: 10000..100000; {salary in dollars} sex: (male, female); {an employee is either male or female} birthdate: date; {date is also an ADT} hiredate: date; end; string = packed array [1..30] of char; { a date type } date = record mon: month; {month is an ADT} day: 1..31; year: 1900..2000; end; {months of the year} month = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec); The programmer can declare variables of these types and give them values they understand like this: var newhire: person; {newhire is a person} begin {new person is a female of age 25 and was hired on June 1, 2000} {which is easy to see from the code below} newhire.age = 25; newhire.sex = female; newhire.hiredate.mon = Jun; newhire.hiredate.day = 1; newhire.hiredate.day = 2000; end. Gradman - 5 These languages are classified as “procedural”, which encourages the use of procedures and functions to implement common tasks which must be done repeatedly in the code. Procedural programming also encourages both top-down and bottom-up design. Like with COBOL, the aim was clear, self-documenting code. However, with more complex problems, the ability to comprehend the code declined sharply. Numerous procedure or function calls could make the code resemble FORTRAN to an extent as control would jump all over the place: {this is “pseudocode”, code that doesn’t necessary follow the syntax of any } {programming language, but is used to convey ideas to the reader } program jumps; {A, B, C, and D are procedures} procedure A; begin if (some condition is true) then C; {procedure C is called} else if (something else is true) then B; else if (yet another thing is true) then D; else writeln(“We’re done!”); end; procedure B; begin if (proposition is true) then D; else C; end; procedure C; begin if (case is true) then set values such no conditions in procedure A will be satisfied; A; else D; end; Gradman - 6 procedure D; begin if (some situation did occur) then do some processing; B; {things may have changed … so let’s call B again} end; { main program } begin A; end.
Recommended publications
  • Create a Program Which Will Accept the Price of a Number of Items. • You Must State the Number of Items in the Basket
    PROBLEM: Create a program which will accept the price of a number of items. • You must state the number of items in the basket. • The program will then accept the unit price and the quantity for each item. • It must then calculate the item prices and the total price. • The program must also calculate and add a 5% tax. • If the total price exceeds $450, a discount of $15 is given to the customer; else he/she pays the full amount. • Display the total price, tax, discounted total if applicable, as well as the total number of items bought. • A thank you message must appear at the bottom. SOLUTION First establish your inputs and your outputs, and then develop your IPO chart. Remember: this phase is called - Analysis Of The Problem. So what are your inputs & output? : Variable names: Number of items (input & output) Num (Assume there are 4 items) Unit price of each item (input) Price1, Price2, Price3, Price4 Quantity of each item (Input) Quan1, Quan2, Quan3, Quan4 Total price (output) TotPrice Tax amount (output) Tax Discounted total price (output) DiscTotPrice In your IPO chart, you will describe the logical steps to move from your inputs to your outputs. INPUT PROCESSING OUTPUT Price1, Price2, 1. Get the number of items TotPrice, Tax, Price3, Price4, 2. Get the price and quantity of the each item DiscTaxedTotal, Num 3. Calculate a sub-total for each item TaxedTotal Quan1, Quan2, 4. Calculate the overall total Num Quan3, Quan4 5. Calculate the tax payable {5% of total} 6. If TaxedTotal > 450 then Apply discount {Total minus 15} Display: TotPrice, Tax, DiscTaxedTotal, TaxedTotal, Num Else TaxedTotal is paid Display: TotPrice, Tax, TaxedTotal, Num Note that there are some variables that are neither input nor output.
    [Show full text]
  • Knuthweb.Pdf
    Literate Programming Donald E. Knuth Computer Science Department, Stanford University, Stanford, CA 94305, USA The author and his associates have been experimenting for the past several years with a program- ming language and documentation system called WEB. This paper presents WEB by example, and discusses why the new system appears to be an improvement over previous ones. I would ordinarily have assigned to student research A. INTRODUCTION assistants; and why? Because it seems to me that at last I’m able to write programs as they should be written. The past ten years have witnessed substantial improve- My programs are not only explained better than ever ments in programming methodology. This advance, before; they also are better programs, because the new carried out under the banner of “structured program- methodology encourages me to do a better job. For ming,” has led to programs that are more reliable and these reasons I am compelled to write this paper, in easier to comprehend; yet the results are not entirely hopes that my experiences will prove to be relevant to satisfactory. My purpose in the present paper is to others. propose another motto that may be appropriate for the I must confess that there may also be a bit of mal- next decade, as we attempt to make further progress ice in my choice of a title. During the 1970s I was in the state of the art. I believe that the time is ripe coerced like everybody else into adopting the ideas of for significantly better documentation of programs, and structured programming, because I couldn’t bear to be that we can best achieve this by considering programs found guilty of writing unstructured programs.
    [Show full text]
  • Programming Pearls: a Literate Program
    by jot1 Be~~tley programming with Special Guest Oysters Don Knuth and Doug McIlroy pearls A LITERATE PROGRAM Last month‘s column introduced Don Knuth’s style of frequency; or there might not even be as many as k “Literate Programming” and his WEB system for building words. Let’s be more precise: The most common programs that are works of literature. This column pre- words are to be printed in order of decreasing fre- sents a literate program by Knuth (its origins are sketched quency, with words of equal frequency listed in al- in last month‘s column) and, as befits literature, a review. phabetic order. Printing should stop after k words So without further ado, here is Knuth’s program, have been output, if more than k words are present. retypeset in Communications style. -Jon Bentley 2. The input file is assumed to contain the given Common Words Section text. If it begins with a positive decimal number Introduction.. , . , , . , . , . , , . 1 (preceded by optional blanks), that number will be Strategic considerations . , a the value of k; otherwise we shall assume that Basic input routines . , , . 9 k = 100. Answers will be sent to the output file. Dictionary lookup . , . , . , .17 define default-k = 100 (use this value if k isn’t The frequency counts . .32 otherwise specified) Sortingatrie . ...36 Theendgame................................41 3. Besides solving the given problem, this program is Index . ...42 supposed to be an example of the WEB system, for people who know some Pascal but who have never 1. Introduction. The purpose of this program is to seen WEB before.
    [Show full text]
  • Teaching Foundations of Computation and Deduction Through Literate Functional Programming and Type Theory Formalization
    Teaching Foundations of Computation and Deduction Through Literate Functional Programming and Type Theory Formalization Gérard Huet Inria Paris Laboratory, France Abstract We describe experiments in teaching fundamental informatics notions around mathematical struc- tures for formal concepts, and effective algorithms to manipulate them. The major themes of lambda-calculus and type theory served as guides for the effective implementation of functional programming languages and higher-order proof assistants, appropriate for reflecting the theor- etical material into effective tools to represent constructively the concepts and formally certify the proofs of their properties. Progressively, a literate programming and proving style replaced informal mathematics in the presentation of the material as executable course notes. The talk will evoke the various stages of (in)completion of the corresponding set of notes along the years (see [1, 2, 14, 5, 6, 10, 12, 16, 7, 15, 17, 9, 3, 13, 11, 4, 8]), and tell how their elaboration proved to be essential to the discovery of fundamental results. 1998 ACM Subject Classification F.3.1 Specifying and Verifying Programs, F.4.1 Mathematical Logic and G.4 Mathematical Software Keywords and phrases Foundations, Computation, Deduction, Programming, Proofs Digital Object Identifier 10.4230/LIPIcs.FSCD.2016.3 Category Invited Talk References 1 Gérard Huet. Initiation à la logique mathématique. Notes de cours du DEA d’Informatique, Université Paris-Sud, 1977. 2 Gérard Huet. Démonstration automatique en logique de premier ordre et programmation en clauses de horn. Notes de cours du DEA d’Informatique, Université Paris-Sud, 1978. 3 Gérard Huet. Confluent reductions: Abstract properties and applications to term rewriting systems.
    [Show full text]
  • Typeset MMIX Programs with TEX Udo Wermuth Abstract a TEX Macro
    TUGboat, Volume 35 (2014), No. 3 297 Typeset MMIX programs with TEX Example: In section 9 the lines \See also sec- tion 10." and \This code is used in section 24." are given. Udo Wermuth No such line appears in section 10 as it only ex- tends the replacement code of section 9. (Note that Abstract section 10 has in its headline the number 9.) In section 24 the reference to section 9 stands for all of ATEX macro package is presented as a literate pro- the eight code lines stated in sections 9 and 10. gram. It can be included in programs written in the If a section is not used in any other section then languages MMIX or MMIXAL without affecting the it is a root and during the extraction of the code a assembler. Such an instrumented file can be pro- file is created that has the name of the root. This file cessed by TEX to get nicely formatted output. Only collects all the code in the sequence of the referenced a new first line and a new last line must be entered. sections from the code part. The collection process And for each end-of-line comment a flag is set to for all root sections is called tangle. A second pro- indicate that the comment is written in TEX. cess is called weave. It outputs the documentation and the code parts as a TEX document. How to read the following program Example: The following program has only one The text that starts in the next chapter is a literate root that is defined in section 4 with the headline program [2, 1] written in a style similar to noweb [7].
    [Show full text]
  • Constructing Algorithms and Pseudocoding This Document Was Originally Developed by Professor John P
    Constructing Algorithms and Pseudocoding This document was originally developed by Professor John P. Russo Purpose: # Describe the method for constructing algorithms. # Describe an informal language for writing PSEUDOCODE. # Provide you with sample algorithms. Constructing Algorithms 1) Understand the problem A common mistake is to start writing an algorithm before the problem to be solved is fully understood. Among other things, understanding the problem involves knowing the answers to the following questions. a) What is the input list, i.e. what information will be required by the algorithm? b) What is the desired output or result? c) What are the initial conditions? 2) Devise a Plan The first step in devising a plan is to solve the problem yourself. Arm yourself with paper and pencil and try to determine precisely what steps are used when you solve the problem "by hand". Force yourself to perform the task slowly and methodically -- think about <<what>> you are doing. Do not use your own memory -- introduce variables when you need to remember information used by the algorithm. Using the information gleaned from solving the problem by hand, devise an explicit step-by-step method of solving the problem. These steps can be written down in an informal outline form -- it is not necessary at this point to use pseudo-code. 3) Refine the Plan and Translate into Pseudo-Code The plan devised in step 2) needs to be translated into pseudo-code. This refinement may be trivial or it may take several "passes". 4) Test the Design Using appropriate test data, test the algorithm by going through it step by step.
    [Show full text]
  • Statistical Software
    Statistical Software A. Grant Schissler1;2;∗ Hung Nguyen1;3 Tin Nguyen1;3 Juli Petereit1;4 Vincent Gardeux5 Keywords: statistical software, open source, Big Data, visualization, parallel computing, machine learning, Bayesian modeling Abstract Abstract: This article discusses selected statistical software, aiming to help readers find the right tool for their needs. We categorize software into three classes: Statisti- cal Packages, Analysis Packages with Statistical Libraries, and General Programming Languages with Statistical Libraries. Statistical and analysis packages often provide interactive, easy-to-use workflows while general programming languages are built for speed and optimization. We emphasize each software's defining characteristics and discuss trends in popularity. The concluding sections muse on the future of statistical software including the impact of Big Data and the advantages of open-source languages. This article discusses selected statistical software, aiming to help readers find the right tool for their needs (not provide an exhaustive list). Also, we acknowledge our experiences bias the discussion towards software employed in scholarly work. Throughout, we emphasize the software's capacity to analyze large, complex data sets (\Big Data"). The concluding sections muse on the future of statistical software. To aid in the discussion, we classify software into three groups: (1) Statistical Packages, (2) Analysis Packages with Statistical Libraries, and (3) General Programming Languages with Statistical Libraries. This structure
    [Show full text]
  • Introduction to Computer Science CSCI 109
    Introduction to Computer Science CSCI 109 China – Tianhe-2 Readings Andrew Goodney Fall 2019 St. Amant, Ch. 5 Lecture 7: Compilers and Programming 10/14, 2019 Reminders u Quiz 3 today – at the end u Midterm 10/28 u HW #2 due tomorrow u HW #3 not out until next week 1 Where are we? 2 Side Note u Two things funny/note worthy about this cartoon u #1 is COBOL (we’ll talk about that later) u #2 is ?? 3 “Y2k Bug” u Y2K bug?? u In the 1970’s-1980’s how to store a date? u Use MM/DD/YY v More efficient – every byte counts (especially then) u What is/was the issue? u What was the assumption here? v “No way my COBOL program will still be in use 25+ years from now” u Wrong! 4 Agenda u What is a program u Brief History of High-Level Languages u Very Brief Introduction to Compilers u ”Robot Example” u Quiz 6 What is a Program? u A set of instructions expressed in a language the computer can understand (and therefore execute) u Algorithm: abstract (usually expressed ‘loosely’ e.g., in english or a kind of programming pidgin) u Program: concrete (expressed in a computer language with precise syntax) v Why does it need to be precise? 8 Programming in Machine Language is Hard u CPU performs fetch-decode-execute cycle millions of time a second u Each time, one instruction is fetched, decoded and executed u Each instruction is very simple (e.g., move item from memory to register, add contents of two registers, etc.) u To write a sophisticated program as a sequence of these simple instructions is very difficult (impossible) for humans 9 Machine Language Example
    [Show full text]
  • Exploratory Data Science Using a Literate Programming Tool Mary Beth Kery1 Marissa Radensky2 Mahima Arya1 Bonnie E
    The Story in the Notebook: Exploratory Data Science using a Literate Programming Tool Mary Beth Kery1 Marissa Radensky2 Mahima Arya1 Bonnie E. John3 Brad A. Myers1 1Human-Computer Interaction Institute 2Amherst College 3Bloomberg L. P. Carnegie Mellon University Amherst, MA New York City, NY Pittsburgh, PA [email protected] [email protected] mkery, mahimaa, bam @cs.cmu.edu ABSTRACT engineers, many of whom never receive formal training in Literate programming tools are used by millions of software engineering [30]. programmers today, and are intended to facilitate presenting data analyses in the form of a narrative. We interviewed 21 As even more technical novices engage with code and data data scientists to study coding behaviors in a literate manipulations, it is key to have end-user programming programming environment and how data scientists kept track tools that address barriers to doing effective data science. For of variants they explored. For participants who tried to keep instance, programming with data often requires heavy a detailed history of their experimentation, both informal and exploration with different ways to manipulate the data formal versioning attempts led to problems, such as reduced [14,23]. Currently even experts struggle to keep track of the notebook readability. During iteration, participants actively experimentation they do, leading to lost work, confusion curated their notebooks into narratives, although primarily over how a result was achieved, and difficulties effectively through cell structure rather than markdown explanations. ideating [11]. Literate programming has recently arisen as a Next, we surveyed 45 data scientists and asked them to promising direction to address some of these problems [17].
    [Show full text]
  • Novice Programmer = (Sourcecode) (Pseudocode) Algorithm
    Journal of Computer Science Original Research Paper Novice Programmer = (Sourcecode) (Pseudocode) Algorithm 1Budi Yulianto, 2Harjanto Prabowo, 3Raymond Kosala and 4Manik Hapsara 1Computer Science Department, School of Computer Science, Bina Nusantara University, Jakarta, Indonesia 11480 2Management Department, BINUS Business School Undergraduate Program, Bina Nusantara University, Jakarta, Indonesia 11480 3Computer Science Department, Faculty of Computing and Media, Bina Nusantara University, Jakarta, Indonesia 11480 4Computer Science Department, BINUS Graduate Program - Doctor of Computer Science, Bina Nusantara University, Jakarta, Indonesia 11480 Article history Abstract: Difficulties in learning programming often hinder new students Received: 7-11-2017 as novice programmers. One of the difficulties is to transform algorithm in Revised: 14-01-2018 mind into syntactical solution (sourcecode). This study proposes an Accepted: 9-04-2018 application to help students in transform their algorithm (logic) into sourcecode. The proposed application can be used to write down students’ Corresponding Author: Budi Yulianto algorithm (logic) as block of pseudocode and then transform it into selected Computer Science Department, programming language sourcecode. Students can learn and modify the School of Computer Science, sourcecode and then try to execute it (learning by doing). Proposed Bina Nusantara University, application can improve 17% score and 14% passing rate of novice Jakarta, Indonesia 11480 programmers (new students) in learning programming. Email: [email protected] Keywords: Algorithm, Pseudocode, Novice Programmer, Programming Language Introduction students in some universities that are new to programming and have not mastered it. In addition, Programming language is a language used by some universities (especially in rural areas or with programmers to write commands (syntax and semantics) limited budget) do not have tools that can help their new that can be understood by a computer to create a students in learning programming (Yulianto et al ., 2016b).
    [Show full text]
  • Does Surprisal Predict Code Comprehension Difficulty?
    Does Surprisal Predict Code Comprehension Difficulty? Casey Casalnuovo ([email protected]), Prem Devanbu ([email protected]) Department of Computer Science, University of California, Davis One Shields Avenue, Davis, CA 95616 USA Emily Morgan ([email protected]) Department of Linguistics, University of California, Davis One Shields Avenue, Davis, CA 95616 USA Abstract Appreciation of the similarities and differences between natural and programming languages has led to the adoption Recognition of the similarities between programming and nat- ural languages has led to a boom in the adoption of language of computational language models for code. Language mod- modeling techniques in tools that assist developers. However, els operate by learning probability distributions over text, and language model surprisal, which guides the training and eval- key to training these models is the notion of surprisal. The uation in many of these methods, has not been validated as surprisal of a token is its negative log probability in context as a measure of cognitive difficulty for programming language 1 comprehension as it has for natural language. We perform a captured by the language model . Programming language is controlled experiment to evaluate human comprehension on more repetitive and has lower surprisal than natural language, fragments of source code that are meaning-equivalent but with different surprisal. We find that more surprising versions of i.e. language models find code more predictable than natural code take humans longer to finish answering correctly. We language (Hindle et al., 2012). Moreover, this finding holds also provide practical guidelines to design future studies for across many natural and programming languages, and some code comprehension and surprisal.
    [Show full text]
  • Trisycl Open Source C++17 & Openmp-Based Opencl SYCL Prototype
    triSYCL Open Source C++17 & OpenMP-based OpenCL SYCL prototype Ronan Keryell Khronos OpenCL SYCL committee 05/12/2015 — IWOCL 2015 SYCL Tutorial • I OpenCL SYCL committee work... • Weekly telephone meeting • Define new ways for modern heterogeneous computing with C++ I Single source host + kernel I Replace specific syntax by pure C++ abstractions • Write SYCL specifications • Write SYCL conformance test • Communication & evangelism triSYCL — Open Source C++17 & OpenMP-based OpenCL SYCL prototype IWOCL 2015 2 / 23 • I SYCL relies on advanced C++ • Latest C++11, C++14... • Metaprogramming • Implicit type conversion • ... Difficult to know what is feasible or even correct... ;• Need a prototype to experiment with the concepts • Double-check the specification • Test the examples Same issue with C++ standard and GCC or Clang/LLVM triSYCL — Open Source C++17 & OpenMP-based OpenCL SYCL prototype IWOCL 2015 3 / 23 • I Solving the meta-problem • SYCL specification I Includes header files descriptions I Beautified .hpp I Tables describing the semantics of classes and methods • Generate Doxygen-like web pages Generate parts of specification and documentation from a reference implementation ; triSYCL — Open Source C++17 & OpenMP-based OpenCL SYCL prototype IWOCL 2015 4 / 23 • I triSYCL (I) • Started in April 2014 as a side project • Open Source for community purpose & dissemination • Pure C++ implementation I DSEL (Domain Specific Embedded Language) I Rely on STL & Boost for zen style I Use OpenMP 3.1 to leverage CPU parallelism I No compiler cannot generate kernels on GPU yet • Use Doxygen to generate I Documentation; of triSYCL implementation itself with implementation details I SYCL API by hiding implementation details with macros & Doxygen configuration • Python script to generate parts of LaTeX specification from Doxygen LaTeX output triSYCL — Open Source C++17 & OpenMP-based OpenCL SYCL prototype IWOCL 2015 5 / 23 • I Automatic generation of SYCL specification is a failure..
    [Show full text]