10import matplotlib.pyplot 
as plt
 
   17from functions_main 
import Find_Topologies
 
   18from functions_main 
import Partition
 
   19from functions_main 
import Find_Nektar_Files
 
   20from functions_main 
import Parse_Nektar_Output
 
   26from class_topology 
import Topology
 
   33def Run_Parallel_Model(Parallelisation, Scheme, Mesh_File, Num_Modes, P, Num_Constants, Fit, BW_Node_To_Node, LAT_Node_To_Node, BW_Socket_To_Socket, 
 
   34    LAT_Socket_To_Socket, BW_Core_To_Core, LAT_Core_To_Core, Num_Core_Per_Socket, Num_Sock_Per_Node, PROC_TOT, Pressure, Velocity_1, Velocity_2,
 
   38    if (Parallelisation 
is 'Hybrid_Socket' or Parallelisation 
is 'Hybrid_Node'):
 
   42    if (Parallelisation 
is 'Modal'):
 
   43        PROC_Z = [2, 4, 5, 8, 10, 20]
 
   44        PROC_XY = [1, 1, 1, 1, 1, 1]
 
   47    if (Parallelisation 
is 'Elemental'):
 
   48        PROC_Z = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
 
   49        PROC_XY = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
 
   68    for i 
in range(0, len(PROC_Z)):
 
   71        Communication_Count = 0.0
 
   74        Simulation = 
Topology(PROC_Z[i], PROC_XY[i], Num_Core_Per_Socket, Num_Sock_Per_Node, Scheme)
 
   77        (Num_Element_Msg, Num_Elements) = 
Partition(Mesh_File, PROC_XY[i])
 
   80        Simulation.Input_Communication(BW_Node_To_Node, LAT_Node_To_Node, BW_Socket_To_Socket, LAT_Socket_To_Socket, BW_Core_To_Core, LAT_Core_To_Core)
 
   83        Simulation.Distribute_Modes(Num_Modes);
 
   84        Simulation.Distribute_Elements(Num_Element_Msg, Num_Elements);
 
   87        Simulation.CG_Iterations(Pressure, Velocity_1, Velocity_2, Velocity_3)
 
   90        Simulation.Data_Size(P)
 
   93        Simulation.Hardware_Constant(Num_Constants, Fit)
 
   96        Pairwise.append(Simulation.Communication_Pairwise_Exchange())
 
   97        Communication_Count += Pairwise[i]
 
  100        Allreduce.append(Simulation.Communication_Allreduce())
 
  101        Communication_Count += Allreduce[i]
 
  104        Alltoall.append(Simulation.Communication_Alltoall())
 
  105        Communication_Count += Alltoall[i]
 
  108        Serial.append(Simulation.Serial_Compute())
 
  111        Serial_Pairwise.append(Serial[i] + Pairwise[i])
 
  112        Serial_Allreduce.append(Serial[i] + Allreduce[i])
 
  113        Serial_Alltoall.append(Serial[i] + Alltoall[i])
 
  116        Communication.append(Communication_Count)
 
  119        Total.append(Communication[i] + Serial[i])
 
  121    if (Parallelisation == 
'Hybrid'):
 
  122        fig, ax = plt.subplots()
 
  123        ax.plot(PROC_Z, Total, label = 
'Model')
 
  124        ax.set_xlabel(
'$ R_Z $')
 
  125        ax.set_ylabel(
'Timestep (s)')
 
  126        ax.set_title(
'Length of Single Timestep: Model')
 
  128        fig.savefig(
"Output/Figures/Model_Hybrid.png")
 
  130    if (Parallelisation == 
'Modal'):
 
  131        fig, ax = plt.subplots()
 
  132        ax.plot(PROC_Z, Total, label = 
'Model')
 
  133        ax.set_xlabel(
'$ R_Z $')
 
  134        ax.set_ylabel(
'Timestep (s)')
 
  135        ax.set_title(
'Length of Single Timestep: Model')
 
  137        fig.savefig(
"Output/Figures/Model_Modal.png")
 
  139    if (Parallelisation == 
'Elemental'):
 
  140        fig, ax = plt.subplots()
 
  141        ax.plot(PROC_XY, Total, label = 
'Model')
 
  142        ax.set_xlabel(
'$ R_{XY} $')
 
  143        ax.set_ylabel(
'Timestep (s)')
 
  144        ax.set_title(
'Length of Single Timestep: Model')
 
  146        fig.savefig(
"Output/Figures/Model_Elemental.png")
 
  148    return(PROC_Z, PROC_XY, Total)
 
  153    if (Parallelisation 
is 'Modal'):
 
  157        (Nektar_Modes_Fin, Timing_Files_Fin) = 
Find_Nektar_Files(Loc_Parallel_Timing_Files)
 
  159        for i 
in range(0, len(Timing_Files_Fin)):
 
  160            Data.append(np.mean(
Parse_Nektar_Output(Loc_Parallel_Timing_Files + Timing_Files_Fin[i]))/10) 
 
  165        for i 
in range(0, len(Timing_Files_Fin)):
 
  166            difference.append(
abs(Data[i] - Total[i]))
 
  168        mean_diff = np.mean(difference) 
 
  169        std_dev_diff = np.std(difference)
 
  170        var_diff = np.var(difference)
 
  173        print(
'The mean of the differences between the Data and the Model is ' + str(mean_diff))
 
  174        print(
'The standard deviation of the differences between the Data and the Model is ' + str(std_dev_diff))
 
  175        print(
'The variance of the differences between the Data and the Model is ' + str(var_diff))
 
  177        fig, ax = plt.subplots()
 
  178        ax.plot(PROC_Z, Data, label = 
'Data')
 
  179        ax.plot(PROC_Z, Total, label = 
'Model')
 
  180        ax.set_xlabel(
'$ R_Z $')
 
  181        ax.set_ylabel(
'Timestep (s)')
 
  182        ax.set_title(
'Length of Single Timestep: Model vs Data')
 
  184        fig.savefig(
"Output/Figures/Mode_Full.png")
 
  186    if (Parallelisation 
is 'Elemental'):
 
  190        (Nektar_Modes_Fin, Timing_Files_Fin) = 
Find_Nektar_Files(Loc_Parallel_Timing_Files)
 
  192        for i 
in range(0, len(Timing_Files_Fin)):
 
  193            Data.append(np.mean(
Parse_Nektar_Output(Loc_Parallel_Timing_Files + Timing_Files_Fin[i]))/10)
 
  198        for i 
in range(0, len(Timing_Files_Fin)):
 
  199            difference.append(
abs(Data[i] - Total[i]))
 
  201        mean_diff = np.mean(difference) 
 
  202        std_dev_diff = np.std(difference)
 
  203        var_diff = np.var(difference)
 
  206        print(
'The mean of the differences between the Data and the Model is ' + str(mean_diff))
 
  207        print(
'The standard deviation of the differences between the Data and the Model is ' + str(std_dev_diff))
 
  208        print(
'The variance of the differences between the Data and the Model is ' + str(var_diff))
 
  210        fig, ax = plt.subplots()
 
  211        ax.plot(PROC_XY, Data, label = 
'Data')
 
  212        ax.plot(PROC_XY, Total, label = 
'Model')
 
  213        ax.set_xlabel(
'$ R_{XY} $')
 
  214        ax.set_ylabel(
'Timestep (s)')
 
  215        ax.set_title(
'Length of Single Timestep: Model vs Data')
 
  217        fig.savefig(
"Output/Figures/Element_Full.png")
 
  219    if (Parallelisation 
is 'Hybrid_Socket' or Parallelisation 
is 'Hybrid_Node'):
 
  222        (Nektar_Modes_Fin, Timing_Files_Fin) = 
Find_Nektar_Files(Loc_Parallel_Timing_Files)
 
  224        for i 
in range(0, len(Timing_Files_Fin)):
 
  225            Data.append(np.mean(
Parse_Nektar_Output(Loc_Parallel_Timing_Files + Timing_Files_Fin[i]))/10)
 
  230        for i 
in range(0, len(Timing_Files_Fin)):
 
  231            difference.append(
abs(Data[i] - Total[i]))
 
  233        mean_diff = np.mean(difference) 
 
  234        std_dev_diff = np.std(difference)
 
  235        var_diff = np.var(difference)
 
  238        print(
'The mean of the differences between the Data and the Model is ' + str(mean_diff))
 
  239        print(
'The standard deviation of the differences between the Data and the Model is ' + str(std_dev_diff))
 
  240        print(
'The variance of the differences between the Data and the Model is ' + str(var_diff))
 
  242        fig, ax = plt.subplots()
 
  243        ax.plot(PROC_Z, Data, label = 
'Data')
 
  244        ax.plot(PROC_Z, Total, label = 
'Model')
 
  245        ax.set_xlabel(
'$ R_Z $')
 
  246        ax.set_ylabel(
'Timestep (s)')
 
  247        ax.set_title(
'Length of Single Timestep: Model vs Data')
 
  249        fig.savefig(
"Output/Figures/Hybrid_Full.png")
 
def Parse_Nektar_Output(Input_Filename, Skip_Steps)
 
def Partition(Input_Filename, PROC_XY)
 
def Find_Topologies(PROC_TOT, Num_Modes)
 
def Find_Nektar_Files(Input_Filename)
 
def Run_Parallel_Comparison(Loc_Parallel_Timing_Files, Parallelisation, PROC_Z, PROC_XY, Total)
 
def Run_Parallel_Model(Parallelisation, Scheme, Mesh_File, Num_Modes, P, Num_Constants, Fit, BW_Node_To_Node, LAT_Node_To_Node, BW_Socket_To_Socket, LAT_Socket_To_Socket, BW_Core_To_Core, LAT_Core_To_Core, Num_Core_Per_Socket, Num_Sock_Per_Node, PROC_TOT, Pressure, Velocity_1, Velocity_2, Velocity_3)
 
scalarT< T > abs(scalarT< T > in)