I am using ParallelPython to develop a performance critical script. I would like to share one value between 8 processes running on the system. Please excuse the trivial example, but this illustrates my question.
def findMin(listOfElements):
for el in listOfElements:
if el < min:
min = el
import pp
min = 0
myList = range(100000)
job_server = pp.Server()
f1 = job_server.submit(findMin, myList[0:25000])
f2 = job_server.submit(findMin, myList[25000:50000])
f3 = job_server.submit(findMin, myList[50000:75000])
f4 = job_server.submit(findMin, myList[75000:100000])
The pp docs do not describe how to exchange data between processes. Is it possible?
If so, is there a standard locking mechanism (for example, in the streaming module) to confirm that only one update is performed at a time?
l = Lock()
if(el < min):
l.acquire
if(el < min):
min = el
l.release
I understand that I can keep the local minimum and compare 4 in the main thread that was returned, but by sharing this value, I can slightly improve the trimming of my BFS binary tree and potentially save a lot of loop iterations.
Thank -
Jonathan