Add multiprocessing code block
@@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import sys
import logging
+import time
+import multiprocessing
sys.path.append("pygen/")
from pygen_src.riscv_instr_pkg import *
from pygen_src.riscv_instr_gen_config import cfg # NOQA
@@ -28,8 +30,7 @@ class riscv_instr_base_test:
self.asm_file_name = cfg.argv.asm_file_name
self.asm = ""
- def run_phase(self):
- for _ in range(cfg.num_of_tests):
+ def run_phase(self, num):
self.randomize_cfg()
self.asm = riscv_asm_program_gen()
riscv_instr.create_instr_list(cfg)
@@ -37,7 +38,7 @@ class riscv_instr_base_test:
self.asm_file_name = "{}.{}".format(self.asm_file_name,
cfg.asm_test_suffix)
test_name = "{}_{}.S".format(self.asm_file_name,
- _ + self.start_idx)
+ num + self.start_idx)
self.asm.get_directed_instr_stream()
self.asm.gen_program()
self.asm.gen_test_file(test_name)
@@ -48,5 +49,9 @@ class riscv_instr_base_test:
gen_config_table()
+start_time = time.time()
riscv_base_test_ins = riscv_instr_base_test()
-riscv_base_test_ins.run_phase()
+with multiprocessing.Pool(processes = cfg.num_of_tests) as pool:
+ pool.map(riscv_base_test_ins.run_phase, list(range(cfg.num_of_tests)))
+end_time = time.time()
+logging.info("Total execution time: {}".format(round(end_time - start_time)))
