0

serial pseudocode:

npoints = 10000
circle_count = 0

do j = 1,npoints
  generate 2 random numbers between 0 and 1
  xcoordinate = random1
  ycoordinate = random2
  if (xcoordinate, ycoordinate) inside circle
  then circle_count = circle_count + 1
end do

PI = 4.0*circle_count/npoints

parallel solution:

npoints = 10000
circle_count = 0

p = number of tasks
num = npoints/p

find out if I am MASTER or WORKER 

do j = 1,num 
  generate 2 random numbers between 0 and 1
  xcoordinate = random1
  ycoordinate = random2
  if (xcoordinate, ycoordinate) inside circle
  then circle_count = circle_count + 1
end do

if I am MASTER

  receive from WORKERS their circle_counts
  compute PI (use MASTER and WORKER calculations)

else if I am WORKER

  send to MASTER circle_count

endif

I want to find beta for the speed up?? beta=fraction of program that is naturally serial

How can I find beta in it????

Jim Mischel
  • 131,090
  • 20
  • 188
  • 351
Muneeb Ul HaXan
  • 551
  • 1
  • 4
  • 5
  • 1
    This looks like homework. Amdahl's Law is pretty easy and only requires basic arithmetic. I would suggest you hit the books. – sleeplessnerd Apr 07 '14 at 20:10
  • What exactly are you having trouble with? What is the "beta" you're trying to calculate? Have you attempted a solution at all? Show us where you're having trouble, and maybe we can help. Note also that if `npoints` is not evenly divisible by `p`, you're going to calculate too many points. – Jim Mischel Apr 08 '14 at 02:41
  • @sleeplessnerd i want to find scalar and vector quantities in parallel code..?? – Muneeb Ul HaXan Apr 08 '14 at 18:10

0 Answers0