Lab05 - Score:_ Section:_ Date:_ Name:_ ECE 3055 Laboratory...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Score:______ Section:____________ Date:__________ Name:______________________________ ECE 3055 Laboratory Assignment 5 Due Date: Thursday, December 9 In this lab, you will use C/C++ and the Windows OS to compare the performance of a program with and without threads. The program will count the number of primes found that are less than 1,000,000. Two versions will be timed and compared. One will use a standard application without any thread creation. The second version will use four created threads each searching different numbers for primes in parallel to count the number of primes. The global data variable prime_count will be shared among the threads and a mutex lock, critical section, or semaphore will need to be used for synchronization. Each time a thread finds a prime in it’s assigned search area, it increments prime_count . The main application will also need to wait for all of the threads to complete using an OS synchronization primitive and then print the final count value before exiting. I used a Boolean flag in my prime search algorithm whenever I found a divisor with no remainder and used the “break” statement in C to exit the inner “ for loop early. You can use an improved algorithm to find primes (not start at 1, 2 or 3, skip even numbers, only try to divide up to n/2, etc), but be sure to use the same algorithm on the threaded version so that the timing and speedup comparison makes more sense. On processors with multiple cores, such as the newest PCs in the ECE Klaus PC labs that have two cores you should be able to demonstrate close to a linear speedup, since this CPU bound problem has the ideal properties needed. So you should see close to a 2X speedup on a dual core processor. It can be split up evenly among processors, does very minimal I/O, and only has minimal shared data. It is not a good idea to just split up the search area a give one thread the low numbers (0. .500K) and one the large numbers (500K-100K) , since the point here is to balance the computational load for maximum speedup (i.e., it takes a lot longer to check large numbers to see if they are prime). If you have access to a four core processor, you should see a speedup of almost 4. With an i7 processor with 8 threads you should see some additional speedup beyond 4 due to hyperthreading (two different threads can run on one core on the i7). ( 5% Extra credit ) For measuring and plotting the speedup on the i7 for 1 to 8 threads. A very similar example program that searches for perfect numbers is attached along with additional
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/27/2011 for the course ECE 3055 taught by Professor Staff during the Spring '08 term at Georgia Institute of Technology.

Page1 / 4

Lab05 - Score:_ Section:_ Date:_ Name:_ ECE 3055 Laboratory...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online