1 / 14

Problem Description

Hill Climbing In a Banking Application (PThreads Version) -by Nitin Agarwal Kailash Aurangabadkar Prashant Jain Rashmi Kankaria Nan Zhang. Problem Description. Find a way to distribute k lockboxes amongst n locations so as to get minimum float.

fleur
Download Presentation

Problem Description

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hill Climbing In a Banking Application(PThreads Version)-byNitin AgarwalKailash AurangabadkarPrashant JainRashmi KankariaNan Zhang

  2. Problem Description • Find a way to distribute k lockboxes amongst n locations so as to get minimum float. • We are parallelizing this problem because :- • For a large value of n and k, the sequential algorithm works slow and its easy to parallelize the problem using hill climbing algorithm.

  3. Sequential Algorithm For m Start Points { Generate a start siting pattern Compute float for the initial siting pattern For each lockbox j { For Each Not Used Place s { Change the Jth position in the siting pattern with city s Calculate the float of the new siting pattern If float of new pattern < float of original pattern Save New Pattern and Float } } }

  4. Parallel Approach Used • The parallel approach to this is direct. • We divide the m different starting points among m threads and let them each reach their peak. • We then take the least value of float and siting pattern from them as our result.

  5. PThread Used • Declaring the thread variable pthread_t thread[no_threads] • Creating the threads for(i=0;i<no_threads;i++) pthread_create(&thread[i],NULL,slave,NULL) • Mutex Lock Used Declaring Lock Variable pthread_mutex_t mutex1 Initializing the Lock pthread_mutex_init(&mutex1,NULL)

  6. Pthreads Contd. • Mutex Locks Used Locking and Unlocking pthread_mutex_lock(&mutex1) …….. pthread_mutex_unlock(&mutex1) • Joining the threads for(i=0;i<no_threads;i++) pthread_join(thread[i],NULL)

  7. Example • Here is an example of how the program works. • We start with 20 cities and 5 lockboxes and use 3 threads (starting points). • The float values of the 20 cities are given below:

  8. Example Contd. • Each thread will generate its start siting pattern using a random number generator. Start Siting Pattern for Thread 1: 3 5 16 4 0 Starting Float Value for Thread 1: 125 Start Siting Pattern for Thread 2: 4 13 9 8 18 Starting Float Value for Thread 2: 250 Start Siting Pattern for Thread 3: 16 2 6 7 19 Starting Float Value for Thread 3: 187 • Each thread will then try to reach its own minimum float and the minimum of all three would be produced as the output. The minimum float as given by the program is: 53 The siting pattern that produces the given float: 19 1 15 9 3

  9. Speed-Up Vs # Processors • To get this curve the problem size was fixed at • Number of Cities = 1000 • Number of Lockboxes = 5 and the number of threads were varied from 2 to 8. Each thread starts with its own random siting pattern.

  10. Values

  11. Chart

  12. Results • When # cities is increased and # threads is kept constant

  13. Observations • Pthreads works better than both MPI and PVM and works almost the same as openMP. • Better Performance due to lesser communication costs. • Mutex locks slow down the system but cant be done without since we’re using shared variables.

  14. Questions??

More Related