GithubHelp home page GithubHelp logo

shreytiwari / parallel-aggregate Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 95 KB

The repository contains the code for calculating the aggregates in an Array using parallel programming.

C++ 7.51% Jupyter Notebook 92.49%
parallel-programming threading array analytics

parallel-aggregate's Introduction

Parallel Aggregate

Repository contains the code for calculating aggregates in an Array using parallel programming. The elements of the Array are randomly generated and the sum is calculated using both the linear as well as the parallel methods. The results are then compared for correctness and analysed to measure the speed up.

Commands for execution

g++ <filename>.cpp -std=c++11 -pthread
./a.out

Approach

The sum of the array with randomly generated elements from within a range is calculated using two methods:

  • Standard Linear Tranversal Aggregate:
    • Time Complexity = O(N)
    • Space Complexity = O(1)
  • Parallel Multiple Linear Traversal Aggregate:
    • Time Complexity = O(N/K) + O(K)
    • Space Complexity = O(K)
    • Where 'K' is the factor of parallelization (here the number of CPU cores on the machine)

For the parallel approach, the input array is divided into 'K' parts and the sum of each part is computed independenly by a unique core and stored in a smaller array of size 'K'. Finally, the sum of the resulting array is computed in a linear manner to give the sum of the entire original array.

Note: The sum of the resulting smaller array can again be computed in a parallel manner. However, considering that the value of 'K' is usually very small, the overheads due function calls, involvement of branch predictor and the disruption of the execution pipeline could out weigh the benefits. A smaller 'K' value also means that there would be fewer 'Cache Misses'. Considering these points, a linear approach was taken to compute the sum of the resulting array.

Analysis

The data is collected for various tests by tuning the following parameters:

  • Size of input array (N).
  • Parallelization factor (K).

The data as well as the analysis performed on the data can be found in the 'Analysis' sub-directory.

Known Issues:

  • It is possible to measure the entire program execution time on the Windows operating system, however attempts made to measure the function exection time were not fruitful. For the purpose of the analysis, the code was run on the Ubuntu operating system.

Useful Links:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.