Difference between revisions of "Team Titans"

From CDOT Wiki
Jump to: navigation, search
(Blanked the page)
(Calculation of Pi)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{GPU610/DPS915 Index | 20157}}
 +
= Team Titans =
 +
== Team Members ==
 +
# [mailto:vfernandes4@senecacollege.ca?subject=dps915 Vanessa Fernandes]
 +
# [mailto:mzaidi4@senecacollege.ca?subject=gpu610 Maira Zaidi]
  
 +
[mailto:mzaidi4@senecacollege.ca,vfernandes4@senecacollege.ca?subject=dps901-gpu610 Email All]
 +
 +
== Progress ==
 +
=== Assignment 1 ===
 +
 +
===Calculation of Pi===
 +
 +
 +
I decided on finding a technique which is the most efficient way to calculate pi. I found one way of doing this on http://www.codecodex.com/wiki/Calculate_digits_of_pi as seen below. By parallelizing the code, it could reduce the computation time considerably.
 +
 +
void pi_digits(int digits) { 
 +
  int carry = 0; 
 +
    int arr[digits + 1]; 
 +
    for (int i = 0; i <= digits; ++i) 
 +
        arr[i] = ARRINIT; 
 +
    for (int i = digits; i > 0; i-= 14) { 
 +
        int sum = 0; 
 +
        for (int j = i; j > 0; --j) { 
 +
            sum = sum * j + SCALE * arr[j]; 
 +
            arr[j] = sum % (j * 2 - 1); 
 +
            sum /= j * 2 - 1; 
 +
        } 
 +
        printf("%04d", carry + sum / SCALE); 
 +
        carry = sum % SCALE; 
 +
    } 
 +
 +
 +
After profiling, I get the following results:
 +
 +
Flat profile:
 +
 +
Each sample counts as 0.01 seconds.
 +
  %  cumulative  self              self    total
 +
time  seconds  seconds    calls  Ts/call  Ts/call  name                                                                                                           
 +
100.00      1.56    1.56                            pi_digits(int)
 +
 +
===Image Manipulation===
 +
 +
 +
Image Resampling/Rescaling is the method used to create a new and potentially better version of an image with a different size. I chose to decipher the code mentioned on  http://www.cplusplus.com/forum/general/2615/ to better understand how it works.
 +
The following performs a basic pixel enlarging resample:
 +
 
 +
  bool Resample(int newWidth, int newHeight)
 +
    {
 +
        if(_data == NULL) return false;
 +
        //
 +
        // Get a new buuffer to interpolate into
 +
        unsigned char* newData = new unsigned char [newWidth * newHeight * 3];
 +
        double scaleWidth =  (double)newWidth / (double)_width;
 +
        double scaleHeight = (double)newHeight / (double)_height;
 +
        for(int cy = 0; cy < newHeight; cy++)
 +
        {
 +
            for(int cx = 0; cx < newWidth; cx++)
 +
            {
 +
                int pixel = (cy * (newWidth *3)) + (cx*3);
 +
                int nearestMatch =  (((int)(cy / scaleHeight) * (_width *3)) + ((int)(cx / scaleWidth) *3) );
 +
                newData[pixel    ] =  _data[nearestMatch    ];
 +
                newData[pixel + 1] =  _data[nearestMatch + 1];
 +
                newData[pixel + 2] =  _data[nearestMatch + 2];
 +
            }
 +
        }
 +
  }
 +
 +
 +
However, I've noticed the code needed to be modified so the user can decide the dimensions of the image instead of it being hard coded. Therefore, we can parallelize the above portion of the code to make it more efficient while looking similar to the for loops but functions differently and potentially better at runtime.
 +
 +
The following displays the gprof profile:
 +
 +
Flat profile:
 +
Each sample counts as 0.01 seconds.
 +
 +
  %  cumulative  self              self    total
 +
time  seconds  seconds    calls  Ts/call  Ts/call  name
 +
100.00      0.03                                    RawBitMap::Resample(int,int)
 +
  0.00      0.03    0.00        1    0.00    0.00  _GLOBAL__sub_I_main
 +
 +
=== Assignment 2 ===
 +
=== Assignment 3 ===

Latest revision as of 04:18, 15 October 2015


GPU610/DPS915 | Student List | Group and Project Index | Student Resources | Glossary

Team Titans

Team Members

  1. Vanessa Fernandes
  2. Maira Zaidi

Email All

Progress

Assignment 1

Calculation of Pi

I decided on finding a technique which is the most efficient way to calculate pi. I found one way of doing this on http://www.codecodex.com/wiki/Calculate_digits_of_pi as seen below. By parallelizing the code, it could reduce the computation time considerably.

void pi_digits(int digits) {

 int carry = 0;  
   int arr[digits + 1];  
   for (int i = 0; i <= digits; ++i)  
       arr[i] = ARRINIT;  
   for (int i = digits; i > 0; i-= 14) {  
       int sum = 0;  
       for (int j = i; j > 0; --j) {  
           sum = sum * j + SCALE * arr[j];  
           arr[j] = sum % (j * 2 - 1);  
           sum /= j * 2 - 1;  
       }  
       printf("%04d", carry + sum / SCALE);  
       carry = sum % SCALE;  
   }  

}

After profiling, I get the following results:

Flat profile:

Each sample counts as 0.01 seconds.

 %   cumulative   self              self     total
time   seconds   seconds    calls  Ts/call  Ts/call  name                                                                                                             

100.00 1.56 1.56 pi_digits(int)

Image Manipulation

Image Resampling/Rescaling is the method used to create a new and potentially better version of an image with a different size. I chose to decipher the code mentioned on http://www.cplusplus.com/forum/general/2615/ to better understand how it works. The following performs a basic pixel enlarging resample:

  bool Resample(int newWidth, int newHeight)
   {
       if(_data == NULL) return false;
       //
       // Get a new buuffer to interpolate into
       unsigned char* newData = new unsigned char [newWidth * newHeight * 3];
       double scaleWidth =  (double)newWidth / (double)_width;
       double scaleHeight = (double)newHeight / (double)_height;
       for(int cy = 0; cy < newHeight; cy++)
       {
           for(int cx = 0; cx < newWidth; cx++)
           {
               int pixel = (cy * (newWidth *3)) + (cx*3);
               int nearestMatch =  (((int)(cy / scaleHeight) * (_width *3)) + ((int)(cx / scaleWidth) *3) );
               newData[pixel    ] =  _data[nearestMatch    ];
               newData[pixel + 1] =  _data[nearestMatch + 1];
               newData[pixel + 2] =  _data[nearestMatch + 2];
           }
       }
  }


However, I've noticed the code needed to be modified so the user can decide the dimensions of the image instead of it being hard coded. Therefore, we can parallelize the above portion of the code to make it more efficient while looking similar to the for loops but functions differently and potentially better at runtime.

The following displays the gprof profile:

Flat profile:

Each sample counts as 0.01 seconds.

 %   cumulative   self              self     total
time   seconds   seconds    calls  Ts/call  Ts/call  name 

100.00 0.03 RawBitMap::Resample(int,int)

 0.00      0.03     0.00        1     0.00     0.00  _GLOBAL__sub_I_main

Assignment 2

Assignment 3