Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Devise formulas to calculate my_first_i and my_last_i in our example. Assume that p (number of cores) and n (number of values) are available to all
Devise formulas to calculate my_first_i and my_last_i in our example.
Assume that p (number of cores) and n (number of values) are available to all cores, and each core has a value my_id, which is a unique identifier between 0 and n1.
Remember that each core should be assigned roughly the same number of elements (First consider the case where n is divisible by p)
for my current code, I have some problems with the elif, and else.
The correct answer should be:
0: 0->4 # remainder 1 -> 4 value 1: 5->9 # remainder 2 -> 4 value 2: 10->14 # remainder 3 -> 4 value 3: 15->18 # 3 value 4: 19->22 # 3 value 5: 23->26 # 3 value
this is my code
remainder = 27%8 #remain 3 my_id = 6 my_first = 0 my_last = 0 p = 8 n = 26 for my_id in range(0, 7): if (my_id == 0) and (my_id < remainder): my_first = my_id * n/p my_last = (my_id * n/p )+ n/p +1 elif (my_id > 0) and (my_id < remainder): my_first = my_id * n/p + my_id +1 my_last = (my_id * n/p )+ n/p + my_id + 2 else: my_first = (my_id * n/p) + remainder + 2 my_last = (my_id * n/p) + n/p + remainder + 2 print(my_first,"->",my_last)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started