Skip to content

Instantly share code, notes, and snippets.

@andersx
Created January 31, 2019 14:40
Show Gist options
  • Select an option

  • Save andersx/e9ceea9821c2dd6061b32657c279d3ae to your computer and use it in GitHub Desktop.

Select an option

Save andersx/e9ceea9821c2dd6061b32657c279d3ae to your computer and use it in GitHub Desktop.
Multiprocessing loop example
def multiprocessing_func(pids, compounds_list, rd):
for i in pids:
rep_out = generate_fchl_acsf(
compounds[i].nuclear_charges,
compounds[i].coordinates,
**rep_params)
rd[i] = rep_out
manager = mp.Manager()
return_dict = manager.dict()
processes = []
nprocs = 24
pids = np.array_split(list(range(TOTAL)),nprocs)
for i in range(nprocs):
p = mp.Process(target=multiprocessing_func, args=(pids[i],compounds,return_dict))
processes.append(p)
p.start()
for process in processes:
process.join()
for i, c in enumerate(compounds):
c.representation = return_dict[i]
# for i, c in enumerate(compounds):
# c.representation = generate_fchl_acsf(c.nuclear_charges,
# c.coordinates, **rep_params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment