Esempio n. 1
0
    def syncAndApply(self):
        if mpi.rank == 0:
            self.dataLock.acquire()  # this lock probably isn't necessary yet

            try:
                for i in range(len(self.cursorObjects)):
                    #self.cursors[i] = self.cursorObjects[i][0].getPos()
                    self.cursors[i] = (self.cursorObjects[i][0].getPos(),
                                       self.cursorObjects[i][0].getScale()
                                       or (1.0, 1.0))
                for i in range(len(self.dataObjList)):
                    self.data[i] = self.dataObjList[i].getData()
                    # print "Sending data:", self.data
                #print "syncing %s cursors and %s data." % (len(self.cursorObjects), len(self.dataObjList)), self.dataObjList[0]

            except:
                traceback.print_exc()
            finally:
                self.dataLock.release()

        if mpi.rank == 0:
            self.resultCursors = mpi.bcast(self.cursors)
            if len(self.data) > 0:
                self.resultData = mpi.bcast(self.data)
        else:
            self.resultCursors = mpi.bcast()
            if len(self.data) > 0:
                self.resultData = mpi.bcast()
                #if mpi.rank == 1:
                #    print "Received data:", self.resultData

        if mpi.rank != -1:  #ok, done for all
            for i in range(len(self.cursorObjects)):
                if len(self.resultCursors) > i:
                    # access: cursorObjects[i][localcopies]
                    for j in range(len(
                            self.cursorObjects[i])):  # set for each local copy
                        # print "Obj data:", self.resultCursors[i]
                        self.cursorObjects[i][j].setPos(
                            self.resultCursors[i][0][0],
                            self.resultCursors[i][0][1])
                        self.cursorObjects[i][j].setScale(
                            (self.resultCursors[i][1][0],
                             self.resultCursors[i][1][1]))
        if mpi.rank != 0:
            for i in range(len(self.dataObjList)):
                if len(self.resultData) > i:
                    self.dataObjList[i].setData(self.resultData[i])
Esempio n. 2
0
    def syncAndApply(self):
        # Get updated data from data sources
        for obj in self.dataSources:
            obj.storeDataInDict(self.data)

        # could lock the data and make a copy before sending, but this is
        #   good enough for now

        if mpi.rank == 0:
            self.resultData = mpi.bcast(self.data)
        else:
            self.resultData = mpi.bcast()
            #if len(self.data) > 0:
            #if mpi.rank == 1:
            #    print "Received data:", self.resultData

        if self.updateCallback != None:
            self.updateCallback(self.resultData)
Esempio n. 3
0
    def syncAndApply(self):
        # Get updated data from data sources
        for obj in self.dataSources:
            obj.storeDataInDict(self.data)


        # could lock the data and make a copy before sending, but this is
        #   good enough for now

        if mpi.rank == 0:
            self.resultData = mpi.bcast(self.data)
        else:
            self.resultData = mpi.bcast()
            #if len(self.data) > 0:
                #if mpi.rank == 1:
                #    print "Received data:", self.resultData

        if self.updateCallback != None:
            self.updateCallback(self.resultData)
Esempio n. 4
0
    def syncAndApply(self):
        if mpi.rank == 0:
            self.dataLock.acquire() # this lock probably isn't necessary yet

            try:
                for i in range(len(self.cursorObjects)):
                    #self.cursors[i] = self.cursorObjects[i][0].getPos()
                    self.cursors[i] = (self.cursorObjects[i][0].getPos(), self.cursorObjects[i][0].getScale() or (1.0,1.0) )
                for i in range(len(self.dataObjList)):
                    self.data[i] = self.dataObjList[i].getData()
                    # print "Sending data:", self.data
                #print "syncing %s cursors and %s data." % (len(self.cursorObjects), len(self.dataObjList)), self.dataObjList[0]

            except:
                traceback.print_exc()
            finally:
                self.dataLock.release()

        if mpi.rank == 0:
            self.resultCursors = mpi.bcast(self.cursors)
            if len(self.data) > 0:
                self.resultData = mpi.bcast(self.data)
        else:
            self.resultCursors = mpi.bcast()
            if len(self.data) > 0:
                self.resultData = mpi.bcast()
                #if mpi.rank == 1: 
                #    print "Received data:", self.resultData

        if mpi.rank != -1: #ok, done for all
            for i in range(len(self.cursorObjects)):
                if len(self.resultCursors) > i:
                    # access: cursorObjects[i][localcopies]
                    for j in range(len(self.cursorObjects[i])): # set for each local copy
                        # print "Obj data:", self.resultCursors[i]
                        self.cursorObjects[i][j].setPos( self.resultCursors[i][0][0], self.resultCursors[i][0][1])
                        self.cursorObjects[i][j].setScale( (self.resultCursors[i][1][0], self.resultCursors[i][1][1]) )
        if mpi.rank != 0:
            for i in range(len(self.dataObjList)):
               if len(self.resultData) > i:
                   self.dataObjList[i].setData(self.resultData[i])