gist.github.com
  
  
    https://gist.github.com/dakshanand/c83cf4419cd55157678eae9286a20405 21
threading_issue.py
def askAdvice(self, state):
    global msgGive, msgAsk        
    msgGive[self.agentNumber] = []
    for i in range(numAgents):   
            msgAsk[i][self.agentNumber] = state

    while True:
        self.giveAdvice()
        if len(msgGive[self.agentNumber]) == numAgents - 1:
          break
This file has been truncated. show original




  
  
    
    
  
  


We are training a RL agent in grid world domain. When we run multiple independent threads of different agents, they run perfectly fine. But when we introduce message passing(via askAdvice and giveAdvice functions) through common global variables across these threads the code slows down extremely.
And when the same code is run only on CPU there is no slow down.
We are not able to figure out the reason for the same, any help in the regards is really appreciated.
Please find the issue highlighted on github - https://github.com/dakshanand/state-granular-trust-metric/issues/1 16