Question: C program. I need help finishing the logic for finding partners. The user will pass two command line arguments, the number of threads to create
C program. I need help finishing the logic for finding partners.
The user will pass two command line arguments, the number of threads to create m and n the number they wish to compute the quadruple roots from to n of m and n will always be a power of The threads will access a shared global array where the partial sum of the quadruple root will be stored. To find these partial sums, each thread will have a partner on the opposite half of the array. So for example if the user chooses to create threads, thread will be partnered with thread thread with thread thread with thread and thread with thread The partial sum is the sum of the partners, and is then stored in the upper parter and pthreadjoin is called. Now that the threads are halved, new partners must be made. Now will be partnered with and with This partnering, summing, storing, and reducing will continue until there is only one thread left.
I am struggling to find an algorithm to correctly find the partner index. I really only need the upper half of the array to be consistent as that's who will call pthreadjoin We cannot use math library functions like log or pow we must use bitshift operations and XOR to determine parterns. We were told a partner could be found by taking itpartners's ID XORed with ri where r logm and i is the iteration, but I have not found that to be consistent. Please help!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
