@@ -120,15 +120,17 @@ def sendout_profiles(self):
120
120
)
121
121
self .sizes [fun_name ] = 0
122
122
try :
123
+ profile_data = bytes (
124
+ struct .pack ( # runtime_percent runtime_sec size
125
+ "ddi" ,
126
+ self .runtimes .get (fun_name , (0.0 , 0.0 ))[0 ],
127
+ self .runtimes .get (fun_name , (0.0 , 0.0 ))[1 ],
128
+ self .sizes [fun_name ],
129
+ )
130
+ )
131
+ message = self .embeddings [fun_name ] + profile_data
123
132
self .env_socket .sendto (
124
- bytes (
125
- struct .pack ( # runtime_percent runtime_sec size
126
- "ddi" ,
127
- self .runtimes .get (fun_name , (0.0 , 0.0 ))[0 ],
128
- self .runtimes .get (fun_name , (0.0 , 0.0 ))[1 ],
129
- self .sizes [fun_name ],
130
- )
131
- ),
133
+ message ,
132
134
func_env_address ,
133
135
)
134
136
except (ConnectionError , FileNotFoundError ):
@@ -180,7 +182,7 @@ def get_runtimes(self):
180
182
check = True ,
181
183
)
182
184
.stdout .decode ("utf-8" )
183
- .splitlines ()[ 5 :]
185
+ .splitlines ()
184
186
)
185
187
os .unlink ("gmon.out" )
186
188
os .unlink ("gmon.sum" )
@@ -190,6 +192,7 @@ def get_runtimes(self):
190
192
for fun_name in self .active_funcs_lists .keys ():
191
193
self .runtimes [self .encode_fun_name (fun_name )] = (0.0 , 0.0 )
192
194
else :
195
+ runtime_data = runtime_data [5 :]
193
196
for line in runtime_data :
194
197
pieces = line .split ()
195
198
self .runtimes [self .encode_fun_name (pieces [- 1 ])] = (
@@ -291,9 +294,7 @@ def gather_active_envs(self):
291
294
while True :
292
295
try :
293
296
logging .debug ("KERNEL: env cycling wewo" )
294
- self .add_env_to_list (
295
- * self .env_socket .recvfrom (4096 )
296
- )
297
+ self .add_env_to_list (* self .env_socket .recvfrom (4096 ))
297
298
except (TimeoutError , socket .timeout ):
298
299
self .env_socket .settimeout (None )
299
300
break
@@ -319,6 +320,8 @@ def gather_active_envs(self):
319
320
exit (0 )
320
321
321
322
def compile_for_size (self ):
323
+ self .embeddings = {}
324
+
322
325
self .gcc_instance = Popen (
323
326
self .build_str , shell = True
324
327
) # Compile without gprof do all the compilation stuff
@@ -350,19 +353,8 @@ def compile_for_size(self):
350
353
)
351
354
embedding = self .gcc_socket .recv (1024 * self .EMBED_LEN_MULTIPLIER )
352
355
logging .debug (f"KERNEL: Got embedding from gcc" )
353
- try :
354
- self .env_socket .sendto (
355
- embedding ,
356
- f"\0 { self .args .bench_name } :{ sock_fun_name } _{ self .args .instance } " .encode (
357
- "utf-8"
358
- ),
359
- )
360
- logging .debug (f"KERNEL: Sent embedding to env" )
361
- except (ConnectionError , FileNotFoundError ):
362
- print (
363
- f"Environment [{ sock_fun_name } ] unexpectedly died" ,
364
- file = sys .stderr ,
365
- )
356
+ emb_len = bytes (struct .pack ("i" , len (embedding )))
357
+ self .embeddings [sock_fun_name ] = emb_len + embedding
366
358
else :
367
359
logging .debug (f"KERNEL: No list for { sock_fun_name } " )
368
360
list_msg = bytes (1 )
0 commit comments