Menu

Devise Formulas Calculate Myfirsti Mylasti Example Assume P Number Cores N Number Values A Q43886531

Devise formulas to calculate my_first_i and my_last_i in ourexample.

Assume that p (number of cores) and n (number of values) areavailable to all cores, and each core has a value my_id, which is aunique identifier between 0 and n‐1.

•Remember that each core should be assigned roughly the samenumber of elements (First consider the case where n is divisible byp)

for my current code, I have some problems with the elif, andelse.

The correct answer should be:

0: 0->4 # remainder 1 -> 4 value1: 5->9 # remainder 2 -> 4 value2: 10->14 # remainder 3 -> 4 value3: 15->18 # 3 value4: 19->22 # 3 value5: 23->26 # 3 value

this is my code

remainder = 27%8 #remain 3my_id = 6my_first = 0my_last = 0p = 8n = 26for 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)

Expert Answer


Answer to Devise formulas to calculate my_first_i and my_last_i in our example. Assume that p (number of cores) and n (number of v…

OR