Added support for parallel compute

This commit is contained in:
Lukáš Plevač 2024-01-28 12:38:41 +01:00
parent 3c6db0bbb5
commit 2271a01e68
2 changed files with 9 additions and 7 deletions

View File

@ -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)
# --

View File

@ -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("")