Replies: 19 comments
-
Benchmark Pull Request I tested my sorting algorithm by editing The hardest part of this task was writing code in bril. Although the syntax is well documented and there are many other benchmarks to reference, the language style feels like a different way of thinking compared to the programming languages I'm most familiar with. Analyze Bril Programs One thing I found annoying was that if there are issues in the program, turnt would only show that the program failed to run on the test cases with error message CFG I again tested my CFG implementation using turnt, creating test cases from the 3 example bril code we saw in class. To check that the blocks are correctly formed, I printed out all of the blocks and the instructions for each block to make sure that the number of blocks is accurate and each one holds the correct order of instructions. To check that I find the correct CFG, I print out each block's successors. Since we went over the 3 examples in class and marked out the blocks and CFG for each, I manually inspected the print statements for each test case and made sure they matched our results. I believe I deserve a Michelin star for familiarizing myself with bril tools and applying what we learned in class in implementing CFG and adding my own design choices to it. |
Beta Was this translation helpful? Give feedback.
-
BenchmarkMy benchmark was replicating the very standard montecarlo simulation for calculating pi. Because bril is very minimal, I had to write from scratch the following three functions
The What I noticed: The implementation process allowed me to internalize the language and helped me devise my own conventions for coding bril. For example,
ToolMy tool inserts a print statement before each TestingTesting was done using a straightforward ConclusionThe most challenging part of the task was writing bril. As mentioned, bril is very minimal, and a lot of my time was spent on re-inventing the wheel. Before starting the task, I had the impression that simple I would be deserving of a Michelin star because of the complex code I needed to write for my montecarlo benchmark, as well as the time spent implementing and testing both the CFG and code transform tool I built. |
Beta Was this translation helpful? Give feedback.
-
Source Code: https://github.com/magg1egao/cs6120_tasks/tree/main/task_2 Benchmark: I manually tested this benchmark with a variety of different numbers, making sure the final output was correct. The sample input listed, Tool: CFG: I tested this with Hardest Part: Self Assessment: |
Beta Was this translation helpful? Give feedback.
-
Code: https://github.com/maheshejs/cs6120pr Benchmark Analyzing Bril Programs Basic Blocks and CFG While testing on the Conclusion |
Beta Was this translation helpful? Give feedback.
-
Week 2 DiscussionSource code: https://github.com/Jacqueline-Wen/cs6120-AdvCompilers-Tasks/tree/main/Task2 Benchmark AssignmentPR: sampsyo/bril#432 ToolThe tool that I implemented calculated the number of different arguments being used in the program. For testing, I included the Bril benchmark I wrote in the first part of the assignment, as well as the simple JSON file provided in the task writeup. CFGI implemented the CFG in C++. The way that I implemented the CFG was that I had one iteration that both identified the basic blocks as well as created the connections to other blocks. In the end, the CFG printed out each of the basic blocks, its associated labels, as well as the connections between the different labels. ConclusionI think I deserve a Michelin star for learning how to use the Bril tools, implementing the CFG meticulously in C++, and learning how to use Turnt to test my programs. Working through the various unexpected issues that came up during this assignment has helped me demonstrate perseverance. |
Beta Was this translation helpful? Give feedback.
-
BenchmarkI decided to implement a new benchmark that calculates the length of the longest increasing subsequence (LIS) in an 8-element array. The benchmark utilizes the memory extension for Bril for array operations. The algorithm is the standard My benchmark allows for custom input via the For testing, I used randomized testing where I compare the result of my Bril program with a reference C++ implementation. The testing script can be found here. Initially, I intended to work on the correlation coefficient calculation but found no straightforward method to divide a ToolI implemented a tool analyzing Bril programs that detects unused labels. The tool works by generating a list of all labels defined in each function. A label is then marked as used if it is referenced by some I tested the tool with CFGI implemented the algorithm for forming the control flow graph as discussed in class. My implementation reuses the code from the basic blocks algorithm to first extract basic blocks for each function. Successors for each block are then determined by looking for control instructions at the end of the block, or the lack thereof. I also decided to identify each basic block with an index, based on its order of appearance in the function, to produce a simpler output format. The algorithm is tested using ConclusionI believe I deserve a Michelin star for handwriting the Bril IR and familiarizing myself with the Bril ecosystem. Also, I believe the tool I built is quite useful as a basic static analyzer, and it successfully found unused labels in one of the selected benchmark codes (Binary Search). |
Beta Was this translation helpful? Give feedback.
-
Code: Link Benchmark: Pull Request Tool: CFG/Basic Blocks: Conclusion and Challenging Part: I believe I deserve a Michelin star for creatively figuring out the constraints of the TypeScript compiler, getting around the constraints, and mixing compiled and handwritten |
Beta Was this translation helpful? Give feedback.
-
Amanda Wang @arw274 and I worked together on these tasks. BenchmarkWe implemented a simple benchmark which computes the _n_th triangular number (sums all the integers from 1 to n): PR Link. ToolWe implemented a function in a few lines of Python which computes a call graph for the given program: a graph whose nodes are the functions in the program, and where there is an edge from i to j if function i contains a call to function j: Link CFGWe implemented CFG creation in python in the way shown in class. Of course, since real programs in bril have many functions, we had to create a separate CFG for each. ConclusionWe believe we deserve a Michelin star for thorough testing, clean implementation, and a slightly-more-sophisticated-than-necessary benchmark and tool. |
Beta Was this translation helpful? Give feedback.
-
BenchmarkI implemented a benchmark which I made a simple function create a really deep call stack using bril's ToolI wrote a tool called
would turn into
CFGI implemented a flag in VerificationBoth parts of the tool had nice serializable outputs with little logic between them and the underlying data structures. This meant end-to-end testing was particularly effective here. I used Difficult PartsThe hardest part was (and probably still is) testing. Manually verifying CFGs is tedious and difficult to do quickly. My collection of hand crafted examples and the few benchmarks taken from the bril repo give me confidence that the program works and doesn't break on most common cases, but especially the serde based parsing logic probably needs more verification work. I'm not the most familiar with serde. The remedy for this is time. I additionally had a bit of difficulty figuring out how to identify CFG nodes. I went with identifying them by the index of their instruction. This simplified the logic a lot from a previous attempt. Stars?I think I deserve a star. The benchmark shows an interesting quirk of |
Beta Was this translation helpful? Give feedback.
-
LinkSummaryI have finished:
Do my implementations work?Yes, all codes are tested using turnt with at least 3 test examples Hardest / Interesting PartThe task itself is not that hard, so I focus more on the readability of the outputs. It is very hard to interpret the raw outputs from the CFG outputs (many use original key-value pairs from json), so I make the outputs look clearer as follows:
For each block, we use codes rather than original key-value pairs from JSON. A Michelin Star?Yes, I think I deserve a Michelin Star:
|
Beta Was this translation helpful? Give feedback.
-
Benchmark / What I built How I tested it / Results CFG / Tooling Hardest part / Fixes Michelin star? |
Beta Was this translation helpful? Give feedback.
-
https://github.com/Smubge/cs6120-L2# SummaryBenchmarkThis benchmark simulates a systolic array implementation of a general matrix matrix multiplication. To generate inputs, we borrowed a cool random number generator function If we let A and B be the input matrix, and C be the product of A and B,
It’s unfortunately not a real parallel implementation, as we don’t really need FIFOs and all code in Bril is sequential, but it's a cool way to implement matrix matrix multiplication!! We manually tested if the outputs were correct by plugging them into a matrix multiplier, testing different seeds to generate random matrices A and B. Additionally, what we found interesting was that besides the difference in instructions, using the Analyzer/TransformerFor the analyzer/transformer, we first brainstormed to replace every “add” with a “mul” in add.json. We then logged the amount of times it was replaced. We coded the algorithm in Rust, with an input of the filename, it would parse the json, replace the instructions, and then output the changed file. We tested this by using snapshot testing on both handwritten Bril programs and also the CFGFor the control flow algorithm, we first designed an algorithm to form basic blocks. We first iterated through checking for the instructions. Using the input of a bril json, we first iterated through each instruction in each function. We decided that each basic block would be labeled by either the destination of the first instruction or a label if the block had any. We created a class Block to easily represent the traits of a basic block. We identified block boundaries at labels and terminator instructions (br, jmp, ret), and created Block objects to represent each basic block with their instructions and edge connections. Finally, we output the control flow graph as a dictionary mapping of block identifiers to lists of their successor blocks. We tested this implementation using snapshot testing on both handwritten Bril programs and also the Hardest PartThe hardest part of this was different for each stage in the implementation. Writing the benchmark was difficult because of the ‘simulation’ from sequential to parallel, as well as trying to write Bril for the first time. As we got more familiar with Bril, the problem of parsing and maintaining correctness was the most difficult part. For the control flow graph, we would incrementally test on more and more complicated programs, which revealed more bugs within our CFG and basic blocks implementation. We also encountered many problems while attempting to write our tool in Rust, resulting in a change to python. But, we learned more about Bril and determined that nested function calls within one line would be a basic block. One of the biggest problems we had was figuring out labeling - something that when writing pseudocode, we didn’t really need to think about. Self AssessmentWe believe we deserve a Michelin star because we are proud of our work! We brainstormed a cool benchmark which simulates execution of a systolic array, and thoroughly tested with many different randomized seeds. We also created a cool tool in Rust, and tested both our CFG and tool thoroughly using both hand implemented benchmarks and benchmarks from the testing suite. We also practiced good team coding practices with git, and learned a lot about Bril and snapshot testing! |
Beta Was this translation helpful? Give feedback.
-
Benchmark I wrote a benchmark which computes the sum of integers between [1, n] which are divisible by m. I used the Tool I implemented a tool in Python which simply counts the number of appearances of each control flow operation ( CFG Python implementation here. This is a direct translation of the algorithm from class, and outputs a cfg for each function in a program. I treated the Conclusion Overall I found this to be a pretty interesting exercise, and the most challenging part was getting familiar with the language and tooling. I'd give myself a star; I think I put an honest effort into completing the tasks and learning about the system. |
Beta Was this translation helpful? Give feedback.
-
Benchmark: I created a benchmark for converting RGB color to gray scale color. There are several ways to implement the conversion. My implementation uses a commonly adopted implementation with the standard luminance coefficients (e.g. OpenCV). The coefficients for RGB channels are coded as constants. This benchmark is built with the Bril float extension. I wrote the program in Bril. For testing, I generated multiple test cases with Python. I included one test case in the Tool: I implemented a tool in Python, simply counting the number of CFG: I implemented a cfg in Python. The program reads a Bril function’s instructions, finds "leaders" (the first instruction, any jump/branch targets, and the instruction after any terminator), and uses them to split the instruction list into basic blocks named by their leading label. It builds a mapping from labels to the blocks that start at those labels, then computes control-flow edges by looking at each block’s last real instruction: jmp and br create edges to the labeled target blocks, ret ends the flow, and any other instruction falls through to the next block. From this it assembles a successor list per block and can emit a Graphviz DOT graph for the function. The main routine loads a JSON program from stdin, processes each function, and prints the block ranges and the computed successor lists. One good thing about my implementation is that I typed all the variables clearly. Hardest part: The trickiest part was getting familiar with Bril, especially for someone who mostly works with Python (Well, a little bit of C#). But with the help of the docs and stuff, it's manageable. Self assessment: I claim a Michelin star for my work, which I'm proud of. The benchmark is a useful application that researchers/developers in computer vision actually use a lot. I verified my implementation works. I believe my code is well-written and organized. Bon appétit! |
Beta Was this translation helpful? Give feedback.
-
Team Members Link to Benchmark PR Link to Tool Benchmark Implementation Testing the Benchmark
Tool Implementation CFG Implementation
form_blocks() scans the flat instruction/label list and maintains a small dict variable called state, with key-value pairs = {'label': None, 'instrs': [], 'next_id': 0}`. On a label, call yield_block(). On instruction, we append to state['instrs'], and if it's a terminator (this list was defiend in class), we call yield_block(). form_cfg() first initializes label_to_block to map labels to block names. Then for each block inspect the last instruction. If:
Conclusion Self-Assessment GAI Tools Disclaimer |
Beta Was this translation helpful? Give feedback.
-
Helen Ge and Pedro Pontes Garcia. link: https://github.com/mercure67/bril/tree/feat, in the Pedro implemented binary search and harmonic series benchmarks; and a program which counts the number of variables used in every function of a Bril program. I implemented the CFG and block forming methods, with support for function calls / boundaries; and tracking which labels are used. Explain how you know your implementation works—how did you test it? Which test inputs did you use? Do you have any quantitative results to report? Pedro tested the variable counting implementation with turnt, on the test cases:
I did a cursory inspection of the output on one benchmark, the ackermann one. It provides a good idea of some of the edge cases that might be encountered (function calls, recursion, etc.) What was the hardest part of the task? How did you solve this problem? For both of us, working with the Do you think your work deserves a Michelin star? Yes, we did some non-trivial extensions to the CFG and block formation; and Pedro did some extensive testing on his variable counter. He also implemented two benchmarks! GAI |
Beta Was this translation helpful? Give feedback.
-
Bril PR: sampsyo/bril#447 Benchmark: I added the mountain benchmark to bril, which tests whether an integer is a 'mountain,' that is a non-decreasing sequence of digits (in base 10) followed by a non-increasing sequence. I tested this via the default args available in the file, but also by a variety of my own tests, which revealed quite a few bugs. I found this to be a particularly difficult implementation, as there were a lot niche issues, especially ones which wouldn't appear in a higher level language. Bril Tool: I added a simple tool which, for all prints, adds a "prefix" from the CLI options of the command. I tested this on a few bril files, and produced some turnt tests in my repository to verify correctness. The implementation for this was fairly straightforward, as simple JSON file handling proved more than sufficient. CFG: I implemented this largely akin to how we did in class, especially as I also did mine in python. Similarly to the bril tool, I used a few pre-generated bril JSON files to verify correctness here, storing these as turnt checkpoint tests. Since we did this together in class, I didn't find this too difficult, though it was certainly insightful to rebuild it myself. GAI Statement: I only used ChatGPT during this assignment, and only to troubleshoot my benchmark tool. Because I had chosen relatively poor naming of my variables, it was somewhat difficult to debug. The concrete example I used it for was to determine why on certain inputs (014 for example) the program had an infinite loop. ChatGPT determined it was due to an incorrect comparison for when the non-decreasing segment ended. It however took almost four minutes to figure this out. I'd say it was helpful, but probably slower than if I just read the code through myself. I also felt like I poorly engaged with my code by using it, so I'd like to avoid using it in the future. Conclusion & Michelin Star: I thought the hardest part was honestly getting myself accustomed to Bril and Turnt. It's always a little confusing seeing a library or framework or tool for the first time, so getting myself properly in the headspace - even with lecture and the videos to guide me - took a little bit of investment. But, I think the work I did was good, and therefore deserves a Michelin star, because I introduced a novel benchmark, a new tool, and successfully make a python program to make a CFG |
Beta Was this translation helpful? Give feedback.
-
Jake Hyun - Lesson 2 SummaryIn Lesson 2, I worked on three parts: a new benchmark, a simple transformation, and CFG construction. New Benchmark
Constant Addition Folding
Control-Flow Graph Construction
Testing
Hardest PartThe hardest part was getting around the Bril infrastructure and learning how to use Turnt, since I was new to them. It took some trial and error to understand how Generative AI StatementI used ChatGPT (OpenAI GPT-5) to help with docstrings, and the
Reflection: ChatGPT was useful for producing clear documentation quickly. |
Beta Was this translation helpful? Give feedback.
-
Source code: https://github.com/sunwookim028/bril For benchmarks, I wrote a simpler one of printing squares of integers 1 to input, and a little more interesting one of printing out the Braille coded version of the input integer using recursion. For new tools, I wrote two simple ones, one adding ".hi" to every label names, and another counting all labels or function names. I tested these with sample input Bril programs I wrote. For algorithms constructing basic blocks and control flow graphs, I implemented the ones figured in class. Coding the Braille convention in Bril was the most time-consuming part since it requires to assign different values for different digits. I mitigated the issue by first minimizing the benchmark functionality (I originally wanted to do and express integer calculations) then write reusable modules across the code. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When you finish your tasks for Lesson 2, post here! Include a link here to your benchmark PR and your new Bril tool. Explain what you did and mention anything you found interesting about it.
Beta Was this translation helpful? Give feedback.
All reactions