OSP600 Lab 6 Vectorization Lab

In this lab we were asked to create a very simple program that will make sure the compiler will use  vectorization optimization when the program is compiled. This is the program :

lab6Program.PNG

This is a simple program where two arrays filled with random values are added together and stored in the third array. the program complied above with the -O3 flag will cause the code to be vectorizied. When obj dumping the compiled code above we get the following result. I will only show the <main> program as well as commented lines on what I think it happening the between the commands.

part1vector

vectorpart2

As for result on what is important within the vectorization. The following are the important instructions for vector additons :

LD1 {Vt.<T>, [base]

ADD Vd.<T>, Vn.<T>, Vm.<T>

ST1 {Vt.<T>}, [base]

Those instructions load the vector register with 1 element strctures from memory. To add them together we use the following instructions :

SXTL Vd.<Td>, Vn<Ts>

SXTL2 Vd.<Td>, Vn<Ts>

ADDP Dd, vn.2D

Those take signed integers in the first half of the vector, extend them , and store them in destination vector, does the same thing to the  second half and adds them together and stores them in destination register.

 

Advertisements

Release 0.2 bug fixes

For the 2.0 release I decided to take an issue regarding weird behavior with right click menu on firefox on a mac.

The link to the issue can be found here : https://github.com/mozilla/thimble.mozilla.org/issues/1728

I think this issue will help me get more familiar with the way thimble and bracket interact and will help me explore more of the options on how to figure out an issue within the open source project.

Since this issue may be somewhat small depending on its fix, I will most likely end up grabbing another one once this is all figured out. The next issue I want to tackle, I want it to have more of a complicated fix as in more coding challenge rather than a small condition check.

One small issue I may run into is the problem being only persisted on one operating system. I do own a mac and my first task will be trying to replicate the issue, however I may need to switch gears depending whether or not this issue is able to be replicated on same system/ different system.

I will update on my findings and the next issue that I find on later blog posts.

 

 

Release 0.1 Fixing a bug in Thimble

For the first release of class OSD600, I choose to fix a bug found in the thimble project ran by mozilla. The issue located here: https://github.com/mozilla/thimble.mozilla.org/issues/1632

Was a minor bug in the code editor which caused the font size to have a minimum of 1px and maximum of 72px when using the increase/decrease font size buttons. The first real challange was installing the necessary components in order to reproduce the bug locally. To go about this, I installed thimble and brackets locally and after some debugging was able to get the server running and able to reproduce the issue.

thumblerunninglocally

Now to figure out on how to fix the issue with the font sizes, I backtracked from using the button directly and tried to connect it to the code. I found possible 4 places where either the font size gets set or where a function is being called in order to connect to a  listener to handle the method. After much investigation and looking up I stumbled across this piece of code.

bugIssue.PNG

So as you can tell someone already has the minimum and the maximum set for the font size, as such the solution was simply to change them to appropriate values. In this case 8 for minimum and 32 for maximum.

After fixing the bug I committed the changes locally and submitted the pull request at :

https://github.com/mozilla/brackets/pull/572

As of today the request has been merged to main branch and the issue is now fixed!

If you would like to work check out the thimble project here are the two links :

Thimble : https://github.com/mozilla/thimble.mozilla.org

Brackets : https://github.com/mozilla/brackets

SPO600 Algorithm Selection Lab

Today’s lab purpose was to see the difference in selecting algorithms when dealing with a problem. The challenge was to create a program that is capable of adjusting volumes on a sequence of sound samples in a range of 0.000 to 1.000.

Designing the code – Solution A

For first design, we created a simple table that stored a range of random value ( o-36750 ) to simulate a sound sample. Using that table we multiplied each index by the specified volume increment. The program looks as follows :

lab5simple

Note : We only want to time the difference in calculating the time for actually processing the sound adjustment and not the initialization, hence the timer starts after all initialization is complete.

Designing the code – Solution B

Second design involved creating a table with pre-calculated values that we use to modify the sound chunk with.

lab5table

Note : As you can see in this variation of the program, most of the calculations are done before our timer, and we only need to have the access to the index which holds our results.

Analyzing The Result

  1. Various optimization levels had different results, with -O3 optimization flag being the fastest improvement by about 6 times over zero optimizations.
  2. Distribution of data does not matter, as in both cases the code executes every peice of information in the array.
  3. Samples fed at 44100 samples per second at two channels, can be handled by both algorithms as current rate of samples per second is 125 million.
  4. Memory footprint of the second approach is slightly larger due to having an extra pre compiled table that it needs to loop up from.
  5. The performance results are as follow : Lab5Result.PNG
  6. The simple multiplication solution is faster as an algorithm in this case, but I believe it is due to processor being able to calculate the needed data in a very fast time, on a slower processor I think we can see the table algorithm catching up if not even overtaking in terms of speed, as long as there is enough memory to supply the needed pre-computed values.

OSD Lab 3 – Setting up Thimble and Working on a local machine

Thimble is an open source project by Mozilla, to provide a simple live code editor for html pages. To develop and work on thimble, one must be able to set it up locally. In order to get it to work I had to download and install the following software :

  1. Node.js
  2. Virtual Box
  3. Vagrant
  4. Brackets

Node.js is required in order to launch a copy of brackets locally, it was simply installed from the main website. Virtual box and vagrant go hand in hand with that vagrant uses virtual box to run a script in order to set up the virtual machine, downloading the required software and providing live updates when the changes are made to the files. Finally the last piece if a copy of Mozilla brackets fork, which is a embedded program in the thimble that actually does the editorial work.

After downloading all of those program and launching their respective services, I was able to launch thimble locally.

ThumbleRunningLocally.png