16from serial
import Serial_Computation
29 def __init__(self, PROC_Z, PROC_XY, Num_Core_Per_Socket, Num_Sock_Per_Node, Scheme):
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;
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):
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))
135 for i
in range(0, self.
PROC_Z):
137 for j
in range(0, self.
PROC_XY):
160 for i
in range(0, self.
PROC_Z):
162 for j
in range(0, self.
Split * 2):
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):
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.')
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):
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.')
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):
319 if(core_1 == 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]
355 for j
in range(0, self.
PROC_XY):
359 for k
in range(0, self.
PROC_XY):
360 send_loc = i * self.
PROC_XY + k
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):
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]
413 for j
in range(0, self.
PROC_XY - 1):
414 current_right = current + 1
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):
440 if (relation_1
is True and relation_2
is True and relation_3
is False):
443 if (relation_1
is True and relation_2
is True and relation_3
is True):
461 for i
in range(0, self.
PROC_Z):
462 for j
in range(0, self.
PROC_XY):
471 for i
in range(0, self.
PROC_Z):
472 for j
in range(0, self.
PROC_XY):
479 current_column = current % self.
PROC_XY
483 if (k % self.
PROC_XY == current_column):
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):
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'
545 Turing =
'King of Computers'
550 Turing =
'King of Computers'
555 Turing =
'King of Computers'
559 if (serial_count >= serial_max):
560 serial_max = serial_count
def Communication_Pairwise_Exchange(self)
def Hardware_Constant(self, Num_Constants, constants)
def Communication_Alltoall(self)
def Distribute_Elements(self, Num_Element_Msg, Num_Elements)
def Distribute_Modes(self, Num_Modes)
def Print_Modes(self, Index)
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)
def Check_Neighbour(self, core_1, core_2)
def Print_Elements(self, Index)
def Communication_Allreduce(self)
def CG_Iterations(self, Pressure, Velocity_1, Velocity_2, Velocity_3)
def __init__(self, PROC_Z, PROC_XY, Num_Core_Per_Socket, Num_Sock_Per_Node, Scheme)
def Serial_Computation(P, Num_Elements, Num_Modes, N_P, N_V_1, N_V_2, N_V_3, Num_Constants, constants, Scheme)