Wednesday 30 April 2014

Graphs of Pthread Programs

1. Pi Mutex

pi_mutex.png

In this graph, initially time increases as number of threads increases, but eventually time decreases as number of threads increase because as we increase the number of threads work is divided and so time of execution decreases and at one point almost becomes zero or minimum because at this point equal work is done by all threads and there are minimum overheads. This is the optimum value of number of threads. But then after this, the graph gradually increases because now the work is less but the number of threads is quite large which results in increased overheads and hence increases the time of execution.


2. Pi Busywait

pi_busywait.png

Here, time increases as number of threads increase as every thread is looping in an infinite loop. So as number of threads increases number of cpu cycles increases which increases the overall time.


3. Matrix Multiplication

matmul.png


Here, when size of array is small, as the no of threads increase, the time rise is very steep because there is no point in parallelizing such small work. Overheads are more in this case.

When we increase the size of array to a high value, d graph does not rise as fast as was the case before because now each thread is working in parallel n work is distributed equally among all so time of execution is less. But when number of threads  is more than what is required time increases because of overheads.


4. Barrier Semaphores

barrier_2sems.png

Here,  graph could not be seen properly because number of threads could not be increased after a certain point because OS would not allow it. So the actual graph could not be obtained but it was seen that for very few number of threads time was almost zero n at high values of no. of threads time increases to a great extent.


5. Barrier Mutex

barrier_mutex.png

Here, the graph increases linearly with the number of threads.


6. Conditional Barrier

cond.png

Here also,  graph could not be seen properly because number of threads could not be increased after a certain point because OS would not allow it. So the actual graph could not be obtained. But it was seen that for very few number of threads time was almost zero and at high values of number of threads time increases to a great extent.


7. Cout v/s Std

greet.png

Here, the graphs just show that std is faster that cout.


VIVEK SEHGAL 374/CO/11

VIREN GULATI 369/CO/11


No comments:

Post a Comment