Nektar++
main.py
Go to the documentation of this file.
1# Andrew Gloster
2# Summer 2016
3# Python Version of Communication Model Implementation
4# Main Program
5
6#------------------------------------
7# Import relevant modules
8#------------------------------------
9
10import os
11from subprocess import Popen, PIPE
12
13#------------------------------------
14# Import relevant main functions
15#------------------------------------
16
17from functions_main import PBS_Job_Parse
18from functions_main import PBS_Benchmark_Parse
19from functions_main import Parse_Benchmark
20from functions_main import Parse_Nektar_Output
21from functions_main import Parse_Nektar_CG_Benchmark_Output
22from functions_main import Find_Nektar_Elements
23from functions_main import Find_Nektar_Files
24from functions_main import Find_Hardware
25from functions_main import Find_Conditions
26from functions_main import Filename_Generate
27
28#------------------------------------
29# Import function for serial computation
30#------------------------------------
31
32from serial import Run_Serial_Fit
33
34#------------------------------------
35# Import function for parallel model
36#------------------------------------
37
38from parallel import Run_Parallel_Model
39from parallel import Run_Parallel_Comparison
40
41#------------------------------------
42# Import relevant error checking functions
43#------------------------------------
44
45from error_main import Primary_Error_Out
46from error_main import Error_Check_Proc_Input
47from error_main import Error_Check_Comm_Input
48
49#------------------------------------
50# Main Program Begin
51#------------------------------------
52
53#------------------------------------
54# User Model Choices
55#------------------------------------
56
57# Input the mesh file name, stored in Input/Mesh/
58Mesh = 'cyl-small.xml'
59
60# Maximum value of N_Z
61Max_N_Z = 'output_72.txt'
62
63# Input the conditions file name stored in Input/Conditions/
64Conditions_File = 'conditions_80.xml'
65
66# Choose the numerical scheme you're using, IterativeFull or IterativeStaticCond
67Scheme = 'IterativeStaticCond'
68
69# Select the values of N_Z you wish to calibrate the model with
70Consider_Modes = [80]
71
72# Choose number of constant to fit to the serial model model, 1 or 2
73Num_Constants = 2
74
75# Do you wish to run the clearcomparison between the calibrated serial model prediction and the collected data.
76# Set to false if your serial data was collected to a different core than the one you are calibrating for.
77Compare_Serial = False
78
79# Do you wish to run the parallel portion of the model
80Parallel = True
81
82# Choose the Parallelisation method for the model to adopt, Modal, Elemental, Hybrid_Socket or Hybrid_Node
83Parallelisation = 'Hybrid_Socket'
84
85# Do you wish to run the comparison between the full model prediction and the collected data
86Compare_Parallel = True
87
88# Input number of nodes you are using (Can replace this with PBS_Job_Parse)
89Num_Node = 1
90
91#------------------------------------
92# Generate Input Filename Locations
93#------------------------------------
94
95(Mesh_File, Input_Nektar_Max, Conditions, Loc_Serial_Timing_Files, Loc_Parallel_Timing_Files, Benchmark_PBS, MPI_Benchmark, Node_Map) = Filename_Generate(Mesh, Max_N_Z, Conditions_File)
96
97#------------------------------------
98# Generate Output Locations
99#------------------------------------
100
101output_path = 'Output/Figures/'
102if os.path.exists(output_path):
103 cmd_string_clear = 'rm -r Output/Figures/ \n'
104 process = Popen([cmd_string_clear],shell=True, stdout=PIPE, stdin=PIPE)
105 process.wait()
106 os.mkdir(output_path)
107
108if not os.path.exists(output_path):
109 os.mkdir(output_path)
110
111#------------------------------------
112# Parse Max Modes Nektar Input
113#------------------------------------
114
115(Pressure, Velocity_1, Velocity_2, Velocity_3) = Parse_Nektar_CG_Benchmark_Output(Input_Nektar_Max)
116
117#------------------------------------
118# Pharse Serial Nektar Inputs
119#------------------------------------
120
121Nektar_Serial_Elements = Find_Nektar_Elements(Mesh_File)
122
123(Nektar_Modes, Timing_Files) = Find_Nektar_Files(Loc_Serial_Timing_Files)
124
125Timings = {}
126for i in range(0, len(Timing_Files)):
127 Timings[str(Nektar_Modes[i])] = Parse_Nektar_Output(Loc_Serial_Timing_Files + Timing_Files[i])
128
129#------------------------------------
130# Pharse Condition Inputs
131#------------------------------------
132
133(Num_Modes, P, Error, Message) = Find_Conditions(Conditions)
134
135# Print error to file if needed
136if (Error is False):
137 Primary_Error_Out(Message)
138 quit()
139
140#------------------------------------
141# Fit Serial Model
142#------------------------------------
143
144# Fit the model to the supplied data and return the FLOPs
145Fit = Run_Serial_Fit(Compare_Serial, Consider_Modes, Num_Constants, P, Nektar_Serial_Elements, Nektar_Modes, Timings, Pressure, Velocity_1, Velocity_2, Velocity_3, 'IterativeStaticCond')
146
147# Stop here if we do not wish to run the parallel model.
148if Parallel is False:
149 quit()
150
151#------------------------------------
152# Pharse Hardware Inputs
153#------------------------------------
154
155(Num_Core_Per_Node, Num_Core_Per_Socket, Num_Sock_Per_Node, Error, Message) = Find_Hardware(Node_Map)
156
157# Print error to file if needed
158if (Error is False):
159 Primary_Error_Out(Message)
160 quit()
161
162# Calculate PROC_TOT using outputs of the PBS_Pharse and Find_Hardware functions
163PROC_TOT = Num_Core_Per_Node * Num_Node
164
165# #------------------------------------
166# # Pharse Communication Inputs
167# #------------------------------------
168
169(PROC_BENCHMARK, Error, Message) = PBS_Benchmark_Parse(Benchmark_PBS)
170
171# Print error to file if needed
172if (Error is False):
173 Primary_Error_Out(Message)
174 quit()
175
176(BW_Node_To_Node, LAT_Node_To_Node, BW_Socket_To_Socket, LAT_Socket_To_Socket, BW_Core_To_Core, LAT_Core_To_Core) = Parse_Benchmark(MPI_Benchmark, PROC_BENCHMARK, Num_Core_Per_Socket, Num_Sock_Per_Node)
177
178print(BW_Node_To_Node, LAT_Node_To_Node, BW_Socket_To_Socket, LAT_Socket_To_Socket, BW_Core_To_Core, LAT_Core_To_Core)
179
180#------------------------------------
181# Error check all inputs
182#------------------------------------
183
184# Error check the inputs
185(Error, Message) = Error_Check_Proc_Input(PROC_TOT, Num_Core_Per_Socket, Num_Sock_Per_Node, Num_Modes)
186
187# Print error to file if needed
188if (Error is False):
189 Primary_Error_Out(Message)
190 quit()
191
192(Error, Message) = Error_Check_Comm_Input(BW_Node_To_Node, LAT_Node_To_Node, BW_Socket_To_Socket, LAT_Socket_To_Socket, BW_Core_To_Core, LAT_Core_To_Core)
193
194# Print error to file if needed
195if (Error is False):
196 Primary_Error_Out(Message)
197 quit()
198
199(PROC_Z, PROC_XY, Total) = 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,
200 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)
201
202if Compare_Parallel is False:
203 quit()
204
205Run_Parallel_Comparison(Loc_Parallel_Timing_Files, Parallelisation, PROC_Z, PROC_XY, Total)
206
207#------------------------------------
208# Main Program End
209#------------------------------------
210
211
212
def Parse_Nektar_Output(Input_Filename, Skip_Steps)
def quit(self)
def del(self): """ Tell our RVP process to quit.
Definition: validator.py:288
def Error_Check_Proc_Input(PROC_TOT, Num_Core_Per_Socket, Num_Sock_Per_Node, N_Modes)
Definition: error_main.py:42
def Primary_Error_Out(Message)
Definition: error_main.py:21
def Error_Check_Comm_Input(BW_Node_To_Node, LAT_Node_To_Node, BW_Socket_To_Socket, LAT_Socket_To_Socket, BW_Core_To_Core, LAT_Core_To_Core)
Definition: error_main.py:122
def Find_Conditions(Input_Filename)
def Find_Hardware(Input_Filename)
def Find_Nektar_Elements(Input_Filename)
def Filename_Generate(Mesh, Max_N_Z, Conditions_File)
def PBS_Benchmark_Parse(Input_Filename)
def Parse_Nektar_CG_Benchmark_Output(Input_Filename)
def Parse_Benchmark(Input_Filename, PROC_BENCHMARK, Num_Core_Per_Socket, Num_Sock_Per_Node)
def Find_Nektar_Files(Input_Filename)
def Run_Parallel_Comparison(Loc_Parallel_Timing_Files, Parallelisation, PROC_Z, PROC_XY, Total)
Definition: parallel.py:151
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)
Definition: parallel.py:35
def Run_Serial_Fit(Compare_Serial, Consider_Modes, Num_Constants, P, Num_Elements, Nektar_Modes, Timings, Pressure, Velocity_1, Velocity_2, Velocity_3, Scheme)
Definition: serial.py:156