diff --git a/envs/neurovec.py b/envs/neurovec.py index f81a6766..03ab4c8d 100755 --- a/envs/neurovec.py +++ b/envs/neurovec.py @@ -67,14 +67,24 @@ def __init__(self, env_config): if self.compile: # stores the runtimes of O3 to compute the RL reward and compared to -O3. - self.O3_runtimes=get_O3_runtimes(self.new_rundir,self.new_testfiles) + self.O3_runtimes = get_O3_runtimes(self.new_rundir, self.new_testfiles) + runtimes_with_pid = {} + for key in self.O3_runtimes: + value = self.O3_runtimes[key] + + # assumes keys are of the format ./dirname/... + key_components = key[2:].split('/') # removes the `./` prefix + key_components[0] = self.new_rundir + key = '/'.join(key_components) + runtimes_with_pid[key] = value + self.O3_runtimes = runtimes_with_pid def init_from_env_config(self,env_config): '''Receives env_config and initalizes all config parameters.''' # dirpath is the path to the train data. self.dirpath = env_config.get('dirpath') # new_rundir is the directory to create and copy the train data to. - self.new_rundir = env_config.get('new_rundir') + self.new_rundir = env_config.get('new_rundir') + str(os.getpid()) # whether or not in inference mode self.inference_mode = env_config.get('inference_mode', False) if self.inference_mode: diff --git a/utility.py b/utility.py index 4bb26a2f..6d1f7526 100644 --- a/utility.py +++ b/utility.py @@ -39,6 +39,7 @@ #the maximum number of leafs in the LLVM abstract sytnax tree MAX_LEAF_NODES = 320 +TEST_SHELL_COMMAND_TIMEOUT = '50s' # pragma line injected for each loop pragma_line = '#pragma clang loop vectorize_width({0}) interleave_count({1})\n' @@ -168,8 +169,8 @@ def get_encodings_from_local(rundir): def run_llvm_test_shell_command(rundir,filename): '''runs the file after the pragma is injected and returns runtime.''' - full_path_header = os.path.join(rundir,'header.c') - cmd1 = 'timeout 4s '+ os.environ['CLANG_BIN_PATH'] + ' -O3 -lm '+full_path_header \ + full_path_header = os.path.join(rundir, 'header.c') + cmd1 = 'timeout ' + TEST_SHELL_COMMAND_TIMEOUT + ' ' + os.environ['CLANG_BIN_PATH'] + ' -O3 -lm '+full_path_header \ +' ' +filename+' -o ' +filename[:-1]+'o' cmd2 = filename[:-1]+'o ' os.system(cmd1) @@ -179,8 +180,8 @@ def run_llvm_test_shell_command(rundir,filename): runtime = None #None if fails logger.warning('Could not compile ' + filename + ' due to time out. Setting runtime to: ' + - str(runtime)+'. Considering increasing the timeout,'+ - ' which is currently set to 4 seconds.') + str(runtime)+'. Considering increasing the TEST_SHELL_COMMAND_TIMEOUT,'+ + ' which is currently set to ' + TEST_SHELL_COMMAND_TIMEOUT) return runtime def get_runtime(rundir,new_code,current_filename):