Having attended a single class on multicore programming which had a brief lecture by my college senior about parallel programming paradigms,I was interested to try it myself and perhaps to learn "abc" write "abc" instead of listening to "abc" :) :).The basic structure you got to keep in your mind for parallel programming is as follows.
function()
{
bla bla bla....
parallel
{
/*I am pretty sure running this parallel wouldn't affect consistency and so I enclose here statements which can be executed in parallel*/
}
bla bla bla
}
I decided to work on matrix multiplication as the senior who handled the lecture hour asked us to try the very same problem.Making a presumption that every ram,rahim and robert knows to code matrix multiplication in C,I proceed further to talk about parallelism.The core part of the code is the ' three nested for loops ' and I first executed that part normally and later under the constraint '#pragma omp parallel for private(i, j, k, temp)'(which parallelizes the code) and my results were follows
Test Case 1 :matrix dimension is 100(ofc
ourse not higher !! :-P)I filled in the values of input matrices using rand() function.
Test case 2: Matrix dimension is 1000
And now as you see,executing the code parallel produces better results.It has saved more than 5 seconds.One more factor that came to my mind was to check the resource utilization when the code is executed under pragma and I immediately went to system->administration->system monitor.case 1) without omp ,high input value
CPU1 24.2%case 2)with omp,using high input

CPU1 = 100.0 %
Ubuntu/linux :
From the knowledge I have acquired from ubuntuforums gcc 4.2 and later versions support openmp
Windows :
1)Visual c++
http://msdn.microsoft.com/en-us/magazine/cc163717.aspx
2)gcc equivalent of windows : tdm/mingw installer
http://www.tdragon.net/recentgcc/
3)dev-cpp (not sure)

No comments:
Post a Comment