def WriteLoopTest1(workerID): """ Test all nodes writing and reading to/from a single shared object, one at a time """ nodes = PyDOOMS.getNumberOfNodes() if (workerID == 0): TestObject(1) PyDOOMS.barrier() oldObjValue = PyDOOMS.get(1).value PyDOOMS.barrier() for i in range(nodes): if (workerID == i): obj = PyDOOMS.get(1) obj.value += 1 PyDOOMS.objectUpdated(obj,"value") PyDOOMS.barrier() if not (oldObjValue == 0 and PyDOOMS.get(1).value == nodes): logging.critical("Worker " + str(workerID) + " Values are:" + str(oldObjValue) + "," + str(PyDOOMS.get(1).value) + " ") raise Exception
def WriteLoopTest3(workerID): """ Test writing and reading to/from multiple shared object from each node """ nodes = PyDOOMS.getNumberOfNodes() if (workerID == 0): TestObject(0) TestObject(1) TestObject(2) TestObject(3) PyDOOMS.barrier() oldObj0Value = PyDOOMS.get(0).value oldObj1Value = PyDOOMS.get(1).value oldObj2Value = PyDOOMS.get(2).value oldObj3Value = PyDOOMS.get(3).value PyDOOMS.barrier() for i in range(nodes): if (workerID == i): obj0 = PyDOOMS.get(0) obj1 = PyDOOMS.get(1) obj2 = PyDOOMS.get(2) obj3 = PyDOOMS.get(3) obj0.value += 1 obj1.value += 1 obj2.value += 1 obj3.value += 1 PyDOOMS.objectUpdated(obj0,"value") PyDOOMS.objectUpdated(obj1,"value") PyDOOMS.objectUpdated(obj2,"value") PyDOOMS.objectUpdated(obj3,"value") PyDOOMS.barrier() if not (oldObj0Value == 0 and oldObj1Value == 0 and oldObj2Value == 0 and oldObj3Value == 0 and PyDOOMS.get(0).value == nodes and PyDOOMS.get(1).value == nodes and PyDOOMS.get(2).value == nodes and PyDOOMS.get(3).value == nodes): logging.critical("Worker " + str(workerID) + " Values are:" + str(oldObj0Value) + "," + str(PyDOOMS.get(0).value) + " " + str(oldObj1Value) + "," + str(PyDOOMS.get(1).value) + " " + str(oldObj2Value) + "," + str(PyDOOMS.get(2).value) + " " + str(oldObj3Value) + "," + str(PyDOOMS.get(3).value) + " ") raise Exception
def SpreadTest2(workerID): """ Tests creation and spreading of objects created in several different nodes All nodes should have all objects in their local object store at the end of the test """ nodes = PyDOOMS.getNumberOfNodes() objectsPerNode = 100 for i in range(nodes): if (workerID == i): for i in range(i*objectsPerNode,i*objectsPerNode+objectsPerNode): TestObject(i) PyDOOMS.barrier() # The python dictionary appears to do non-blocking inserts into the object store dict. # Our PyDOOMS.get() function will wait for inserts to be made, but when checking the length of the dict # we must first wait for all inserts to complete time.sleep(0.02) if (len(PyDOOMS._store.objects) != objectsPerNode*nodes): logging.critical("Worker " + str(workerID) + " Number of objects:" + str(len(PyDOOMS._store.objects))) printDict() raise Exception