From 2271a01e68098c6683550ca1de6675de70d016c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Pleva=C4=8D?= Date: Sun, 28 Jan 2024 12:38:41 +0100 Subject: [PATCH] Added support for parallel compute --- src/SIMDDNA/register.py | 6 +++--- src/main.py | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/SIMDDNA/register.py b/src/SIMDDNA/register.py index 9df198f..0df5bbe 100644 --- a/src/SIMDDNA/register.py +++ b/src/SIMDDNA/register.py @@ -29,9 +29,6 @@ class Register: # def instruction(self, IMols): # @todo: while chainging - Parallel(n_jobs=4)(delayed(self.insDo)(IMols) for _ in range(4)) - - def insDo(self, IMols): for _ in range(20): for mol in IMols: # try bind mol to all possible bindings @@ -59,6 +56,9 @@ class Register: # remove all unstable binded chains binded on 1 base or lower self.removeUnstable() + return self + + ## # remove unbinded chains from register (because new imol have bind on more posisin on register that older) # -- diff --git a/src/main.py b/src/main.py index 65641bd..f948d8e 100755 --- a/src/main.py +++ b/src/main.py @@ -5,6 +5,8 @@ from SIMDDNA.assembly import Assembly from SIMDDNA.ascii import showMolecule import argparse +from joblib import Parallel, delayed + parser = argparse.ArgumentParser(description='DNA|SIMD python simulator POC1') parser.add_argument('assembly') parser.add_argument('-s', '--spaceing', default=" ", help='space sentense between ascii char of DNA strands') @@ -57,10 +59,10 @@ for ins in asm.getInstructions(): print("--------------------------------") print() - for reg in regs: - reg.instruction(ins["ins"]) - - if args.verbose: + regs = Parallel(n_jobs=max(len(regs), 4))(delayed(reg.instruction)(ins["ins"]) for reg in regs) + + if args.verbose: + for reg in regs: reg.asciiShow(spaceing = args.spaceing) print("")