16 from serial
import Serial_Computation
29 def __init__(self, PROC_Z, PROC_XY, Num_Core_Per_Socket, Num_Sock_Per_Node, Scheme):
33 self.PROC_XY = PROC_XY
34 self.Num_Core_Per_Socket = Num_Core_Per_Socket
35 self.Num_Sock_Per_Node = Num_Sock_Per_Node
39 self.PROC_TOT = self.PROC_XY * self.PROC_Z
53 for i
in range(0, self.PROC_Z):
54 for j
in range(0, self.PROC_XY):
55 self.Core.append(count_core)
56 self.Socket.append(count_socket_new)
57 self.Node.append(count_node)
62 if(count_core % Num_Core_Per_Socket == 0):
63 count_socket_new = count_socket_new + 1
66 if(count_socket_old != count_socket_new):
67 if(count_socket_new % Num_Sock_Per_Node == 0):
68 count_node = count_node + 1;
71 count_socket_old = count_socket_new;
74 self.Elements_Disributed =
False
75 self.Modes_Disributed =
False
76 self.Data_Size_Input =
False
77 self.Data_Communication_Input =
False
88 output_path =
'Output'
89 if not os.path.exists(output_path):
93 f = open(
'Output/Hardware_Topology.txt',
"w")
95 f.write(
"Core Distribution")
98 for i
in range(0, self.PROC_Z):
99 for j
in range(0, self.PROC_XY):
100 f.write(repr(self.Core[i*self.PROC_XY + j]).rjust(5))
107 f.write(
"Socket Distribution")
109 for i
in range(0, self.PROC_Z):
110 for j
in range(0, self.PROC_XY):
111 f.write(repr(self.Socket[i*self.PROC_XY + j]).rjust(5))
118 f.write(
"Node Distribution")
120 for i
in range(0, self.PROC_Z):
121 for j
in range(0, self.PROC_XY):
122 f.write(repr(self.Node[i*self.PROC_XY + j]).rjust(5))
134 self.Num_Elements = []
135 for i
in range(0, self.PROC_Z):
136 self.Num_Elements.append([])
137 for j
in range(0, self.PROC_XY):
138 self.Num_Elements[i].append(Num_Elements[j])
140 self.Num_Element_Msg = Num_Element_Msg
142 self.Elements_Disributed =
True
150 self.Num_Modes = Num_Modes
151 self.N_Z = Num_Modes * 2
152 self.Split = self.Num_Modes / self.PROC_Z
156 for i
in range(0, self.PROC_TOT):
157 self.Modes.append(self.Split)
158 self.Planes.append(self.Split * 2)
160 for i
in range(0, self.PROC_Z):
161 self.Plane_Num.append([])
162 for j
in range(0, self.Split * 2):
163 self.Plane_Num[i].append(i * (self.Split * 2) + j)
165 self.Modes_Disributed =
True
173 self.Num_Constants = Num_Constants
174 self.constants = constants
184 if (self.Elements_Disributed
is True):
187 output_path =
'Output'
188 if not os.path.exists(output_path):
189 os.mkdir(output_path)
192 f = open(
'Output/Element_Distribution_' + str(Index) +
'.txt',
"w")
194 f.write(
"Core Distribution")
197 for i
in range(0, self.PROC_Z):
198 for j
in range(0, self.PROC_XY):
199 f.write(repr(self.Core[i * self.PROC_XY + j]).rjust(5))
204 f.write(
"Element Distribution")
207 for i
in range(0, self.PROC_Z):
208 for j
in range(0, self.PROC_XY):
209 f.write(repr(self.Num_Elements[i][j]).rjust(5))
214 output_path =
'Output'
215 if not os.path.exists(output_path):
216 os.mkdir(output_path)
219 f = open(
'Output/Element_Distribution_' + str(Index) +
'.txt',
"w")
221 f.write(
'Elements have no yet been distributed by the program.')
233 if (self.Modes_Disributed
is True):
236 output_path =
'Output'
237 if not os.path.exists(output_path):
238 os.mkdir(output_path)
241 f = open(
'Output/Mode_Distribution.txt',
"w")
243 f.write(
"Core Distribution")
246 for i
in range(0, self.PROC_Z):
247 for j
in range(0, self.PROC_XY):
248 f.write(repr(self.Core[i*self.PROC_XY + j]).rjust(5))
253 f.write(
"Mode Distribution")
255 for i
in range(0, self.PROC_Z):
256 for j
in range(0, self.PROC_XY):
257 f.write(repr(self.Modes[i*self.PROC_XY + j]).rjust(5))
262 output_path =
'Output'
263 if not os.path.exists(output_path):
264 os.mkdir(output_path)
267 f = open(
'Output/Mode_Distribution_' + str(Index) +
'.txt',
"w")
269 f.write(
'Modes have no yet been distributed by the program.')
278 self.Pressure = Pressure
279 self.Velocity_1 = Velocity_1
280 self.Velocity_2 = Velocity_2
281 self.Velocity_3 = Velocity_3
291 self.Data_Element = (P + 1) * 8
292 self.Data_Mode = 8 * ((P+1) ** 2)
295 self.Data_Size_Input =
True
302 def Input_Communication(self, BW_Node_To_Node, LAT_Node_To_Node, BW_Socket_To_Socket, LAT_Socket_To_Socket, BW_Core_To_Core, LAT_Core_To_Core):
303 self.BW_Node_To_Node = BW_Node_To_Node
304 self.BW_Socket_To_Socket = BW_Socket_To_Socket
305 self.BW_Core_To_Core = BW_Core_To_Core
306 self.LAT_Node_To_Node = LAT_Node_To_Node
307 self.LAT_Socket_To_Socket = LAT_Socket_To_Socket
308 self.LAT_Core_To_Core = LAT_Core_To_Core
311 self.Data_Communication_Input =
True
319 if(core_1 == core_2):
322 if(self.Socket[core_1] == self.Socket[core_2]):
325 if(self.Node[core_1] == self.Node[core_2]):
339 for i
in range(0, self.PROC_Z):
345 for j
in range(0, len(self.Plane_Num[current_row])):
347 Plane = self.Plane_Num[current_row][j] + 1
348 CG_Iter += self.Pressure[str(Plane)][0]
349 CG_Iter += self.Velocity_1[str(Plane)][0]
350 CG_Iter += self.Velocity_2[str(Plane)][0]
351 CG_Iter += self.Velocity_3[str(Plane)][0]
355 for j
in range(0, self.PROC_XY):
357 current = i * self.PROC_XY + j
359 for k
in range(0, self.PROC_XY):
360 send_loc = i * self.PROC_XY + k
362 relation = self.Check_Neighbour(current, send_loc)
365 comm_count += self.LAT_Core_To_Core + (self.Num_Element_Msg[j][k] * self.Data_Element)/(self.BW_Core_To_Core)
368 comm_count += self.LAT_Socket_To_Socket + (self.Num_Element_Msg[j][k] * self.Data_Element)/(self.BW_Socket_To_Socket)
371 comm_count += self.LAT_Node_To_Node + (self.Num_Element_Msg[j][k] * self.Data_Element)/(self.BW_Node_To_Node)
373 comm_count = comm_count * CG_Iter
375 if (comm_count >= comm_max):
376 comm_max = comm_count
395 for i
in range(0, self.PROC_Z):
396 current = self.Core[i * self.PROC_XY]
401 for j
in range(0, len(self.Plane_Num[current_row])):
403 Plane = self.Plane_Num[current_row][j] + 1
404 CG_Iter += self.Pressure[str(Plane)][0]
405 CG_Iter += self.Velocity_1[str(Plane)][0]
406 CG_Iter += self.Velocity_2[str(Plane)][0]
407 CG_Iter += self.Velocity_3[str(Plane)][0]
413 for j
in range(0, self.PROC_XY - 1):
414 current_right = current + 1
416 relation = self.Check_Neighbour(current, current_right)
419 comm_count += self.LAT_Core_To_Core + (3 * 8)/(self.BW_Core_To_Core)
423 comm_count += self.LAT_Socket_To_Socket + (3 * 8)/(self.BW_Socket_To_Socket)
427 comm_count += self.LAT_Node_To_Node + (3 * 8)/(self.BW_Node_To_Node)
432 comm_count = comm_count * CG_Iter
433 if (comm_count >= comm_max):
434 comm_max = comm_count
437 if (relation_1
is True and relation_2
is False and relation_3
is False):
438 comm_max += (self.LAT_Core_To_Core + (3 * 8)/(self.BW_Core_To_Core)) * CG_MAX
440 if (relation_1
is True and relation_2
is True and relation_3
is False):
441 comm_max += (self.LAT_Socket_To_Socket + (3 * 8)/(self.BW_Socket_To_Socket)) * CG_MAX
443 if (relation_1
is True and relation_2
is True and relation_3
is True):
444 comm_max += (self.LAT_Node_To_Node + (3 * 8)/(self.BW_Node_To_Node)) * CG_MAX
461 for i
in range(0, self.PROC_Z):
462 for j
in range(0, self.PROC_XY):
463 MSG_Node_Mode.append(self.LAT_Node_To_Node + (self.Planes[i] * self.Num_Elements[i][j] * self.Data_Mode)/((self.BW_Node_To_Node) * self.PROC_Z))
464 MSG_Socket_Mode.append(self.LAT_Socket_To_Socket + (self.Planes[i] * self.Num_Elements[i][j] * self.Data_Mode)/((self.BW_Socket_To_Socket) * self.PROC_Z))
465 MSG_Core_Mode.append(self.LAT_Core_To_Core + (self.Planes[i] * self.Num_Elements[i][j] * self.Data_Mode)/((self.BW_Core_To_Core) * self.PROC_Z))
471 for i
in range(0, self.PROC_Z):
472 for j
in range(0, self.PROC_XY):
478 current = self.Core[i*self.PROC_XY + j]
479 current_column = current % self.PROC_XY
482 for k
in range(0, self.PROC_TOT):
483 if (k % self.PROC_XY == current_column):
484 relation = self.Check_Neighbour(current, k)
490 comm_count += MSG_Core_Mode[current]
494 comm_count += MSG_Socket_Mode[current]
498 comm_count += MSG_Node_Mode[current]
502 if (comm_count >= comm_max):
503 comm_max = comm_count
506 return(18 * comm_max)
516 for i
in range(0, self.PROC_Z):
517 for j
in range(0, self.PROC_XY):
521 current = self.PROC_XY * i + j
529 length = len(self.Plane_Num[i])
533 for k
in range(0, length):
535 Current_Plane = str(1 + self.Plane_Num[i][k])
538 N_P += self.Pressure[Current_Plane][0]
540 Turing =
'King of Computers'
543 N_V_1 += self.Velocity_1[Current_Plane][0]
545 Turing =
'King of Computers'
548 N_V_2 += self.Velocity_2[Current_Plane][0]
550 Turing =
'King of Computers'
553 N_V_3 += self.Velocity_3[Current_Plane][0]
555 Turing =
'King of Computers'
557 serial_count =
Serial_Computation(self.P, self.Num_Elements[i][j], self.Planes[current], N_P, N_V_1, N_V_2, N_V_3, self.Num_Constants, self.constants, self.Scheme)
559 if (serial_count >= serial_max):
560 serial_max = serial_count
def Communication_Alltoall
def Communication_Allreduce
def Communication_Pairwise_Exchange