Nektar++
error_main.py
Go to the documentation of this file.
1# Andrew Gloster
2# Summer 2016
3# Python Version of Communication Model Implementation
4# Error Check Functions
5
6#------------------------------------
7# Import relevant modules
8#------------------------------------
9
10import os
11
12#------------------------------------
13# Import relevant functions and classes
14#------------------------------------
15
16
17#------------------------------------
18# New Function
19#------------------------------------
20
21def Primary_Error_Out(Message):
22
23 # Check for file path and create if necessary
24 error_path = 'Error'
25 if not os.path.exists(error_path):
26 os.mkdir(error_path)
27
28 error_txt = open('Error/error_proc_input.txt', 'w')
29
30 for i in range(0, len(Message)):
31 error_txt.write(Message[i])
32 error_txt.write("\n")
33
34 error_txt.close()
35
36#------------------------------------
37# New Function
38#------------------------------------
39
40# Check the Processor, Element and Mode inputs for Errors
41# Run this whenever using find_topologies from function_main.py
42def Error_Check_Proc_Input(PROC_TOT, Num_Core_Per_Socket, Num_Sock_Per_Node, N_Modes):
43
44 # Default no errors
45 check = True
46
47 # Check for file path and create if necessary
48 error_path = 'Error'
49 if not os.path.exists(error_path):
50 os.mkdir(error_path)
51
52 # Open file to write errors to.
53 error_txt = open('Error/error_proc_input.txt', 'w')
54
55 # PROC_TOT must be an int
56 if(type(PROC_TOT) is not int):
57 error_txt.write("Please input an integer for the number of Processors")
58 error_txt.write('\n')
59 check = False
60
61 # PROC_TOT must be a positive number
62 if(PROC_TOT <= 0):
63 error_txt.write("Please give a positive number of Processors")
64 error_txt.write('\n')
65 check = False
66
67 # PROC_TOT does not allow for an odd number of cores to be used.
68 if(PROC_TOT % 2 != 0):
69 error_txt.write("Odd Number of Processors Provided, Povide an Even Number")
70 error_txt.write('\n')
71 check = False
72
73 # Num_Core_Per_Socket must be an int
74 if(type(Num_Core_Per_Socket) is not int):
75 error_txt.write("Please input an integer for the number of Cores Per Socket")
76 error_txt.write('\n')
77 check = False
78
79 # Num_Core_Per_Socket must be a positive number
80 if(Num_Core_Per_Socket <= 0):
81 error_txt.write("Please give a positive number of Cores Per Socket")
82 error_txt.write('\n')
83 check = False
84
85 # Num_Core_Per_Socket must be an int
86 if(type(Num_Sock_Per_Node) is not int):
87 error_txt.write("Please input an integer for the number of Sockets Per Node")
88 error_txt.write('\n')
89 check = False
90
91 # Num_Core_Per_Socket must be a positive number
92 if(Num_Sock_Per_Node <= 0):
93 error_txt.write("Please give a positive number of Sockets Per Node")
94 error_txt.write('\n')
95 check = False
96
97 # Num_Core_Per_Socket must be an int
98 if(type(N_Modes) is not int):
99 error_txt.write("Please input an integer for the number of Modes")
100 error_txt.write('\n')
101 check = False
102
103 # Num_Core_Per_Socket must be a positive number
104 if(N_Modes <= 0):
105 error_txt.write("Please give a positive number of Modes")
106 error_txt.write('\n')
107 check = False
108
109 # Close the file and return result
110 error_txt.close()
111
112 if(check is True):
113 return(check, 'No errors in Processor, Element and Mode inputs')
114 if(check is False):
115 return(check, 'Errors found in Processor, Element and Mode inputs - Please see Error/error_proc_input.txt')
116
117#------------------------------------
118# New Function
119#------------------------------------
120
121# Check that the bandwidth and latency input are valid
122def 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):
123
124 # Default no errors
125 check = True
126
127 # Check for file path and create if necessary
128 error_path = 'Error'
129 if not os.path.exists(error_path):
130 os.mkdir(error_path)
131
132 # Open file to write errors to.
133 error_txt = open('Error/error_comm_input.txt', 'w')
134
135 # BW_Node_To_Node must be an float
136 if(type(BW_Node_To_Node) is not float):
137 error_txt.write("Please input an float for Bandwith Node To Node")
138 error_txt.write('\n')
139 check = False
140
141 # BW_Node_To_Node must be a positive number
142 if(BW_Node_To_Node <= 0):
143 error_txt.write("Please give a positive number for Bandwith Node To Node")
144 error_txt.write('\n')
145 check = False
146
147 # LAT_Node_To_Node must be an float
148 if(type(LAT_Node_To_Node) is not float):
149 error_txt.write("Please input an float for Latency Node To Node")
150 error_txt.write('\n')
151 check = False
152
153 # LAT_Node_To_Node must be a positive number
154 if(LAT_Node_To_Node <= 0):
155 error_txt.write("Please give a positive number for Latency Node To Node")
156 error_txt.write('\n')
157 check = False
158
159 # BW_Socket_To_Socket must be an float
160 if(type(BW_Socket_To_Socket) is not float):
161 error_txt.write("Please input an float for Bandwith Socket To Socket")
162 error_txt.write('\n')
163 check = False
164
165 # BW_Socket_To_Socket must be a positive number
166 if(BW_Socket_To_Socket <= 0):
167 error_txt.write("Please give a positive number for Bandwith Socket To Socket")
168 error_txt.write('\n')
169 check = False
170
171 # LAT_Socket_To_Socket must be an float
172 if(type(LAT_Socket_To_Socket) is not float):
173 error_txt.write("Please input an float for Latency Socket To Socket")
174 error_txt.write('\n')
175 check = False
176
177 # LAT_Socket_To_Socket must be a positive number
178 if(LAT_Socket_To_Socket <= 0):
179 error_txt.write("Please give a positive number for Latency Socket To Socket")
180 error_txt.write('\n')
181 check = False
182
183 # BW_Core_To_Core must be an float
184 if(type(BW_Core_To_Core) is not float):
185 error_txt.write("Please input an float for Bandwith Core To Core")
186 error_txt.write('\n')
187 check = False
188
189 # BW_Socket_To_Socket must be a positive number
190 if(BW_Core_To_Core <= 0):
191 error_txt.write("Please give a positive number for Bandwith Core To Core")
192 error_txt.write('\n')
193 check = False
194
195 # LAT_Core_To_Core must be an float
196 if(type(LAT_Core_To_Core) is not float):
197 error_txt.write("Please input an float for Latency Core To Core")
198 error_txt.write('\n')
199 check = False
200
201 # LAT_Core_To_Core must be a positive number
202 if(LAT_Core_To_Core <= 0):
203 error_txt.write("Please give a positive number for Latency Core To Core")
204 error_txt.write('\n')
205 check = False
206
207 if(check is True):
208 return(check, 'No errors in Processor, Element and Mode inputs')
209 if(check is False):
210 return(check, 'Errors found in Communication inputs - Please see Error/error_comm_input.txt')
211
212
213
214
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