Пример #1
0
    def testAttr(self, copy_fn=None, delete_fn=None):
        self.keyval = MPI.Comm.Create_keyval(copy_fn, delete_fn)
        self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID)

        attrval = [1,2,3]
        rc = getrc(attrval)
        self.comm.Set_attr(self.keyval, attrval)
        self.assertEqual(getrc(attrval), rc+1)

        o = self.comm.Get_attr(self.keyval)
        self.assertTrue(o is attrval)
        self.assertEqual(getrc(attrval), rc+2)
        o = None

        dupcomm = self.comm.Clone()
        if copy_fn is True:
            self.assertEqual(getrc(attrval), rc+2)
        o = dupcomm.Get_attr(self.keyval)
        if copy_fn is True:
            self.assertTrue(o is attrval)
            self.assertEqual(getrc(attrval), rc+3)
        elif not copy_fn:
            self.assertTrue(o is None)
            self.assertEqual(getrc(attrval), rc+1)
        dupcomm.Free()
        o = None

        self.assertEqual(getrc(attrval), rc+1)
        self.comm.Delete_attr(self.keyval)
        self.assertEqual(getrc(attrval), rc)

        o = self.comm.Get_attr(self.keyval)
        self.assertTrue(o is None)
Пример #2
0
    def testAttrCopyDelete(self):
        self.keyval = MPI.Win.Create_keyval(delete_fn=MPI.Win.Free)
        self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID)

        newwin = MPI.Win.Create(MPI.BOTTOM, 1, MPI.INFO_NULL, MPI.COMM_SELF)
        rc = getrc(newwin)
        #
        self.win.Set_attr(self.keyval, newwin)
        self.assertTrue(newwin != MPI.WIN_NULL)
        self.assertTrue(getrc(newwin), rc + 1)
        #
        self.win.Delete_attr(self.keyval)
        self.assertTrue(newwin == MPI.WIN_NULL)
        self.assertTrue(getrc(newwin), rc)
Пример #3
0
    def testAttr(self, copy_fn=None, delete_fn=None):
        self.keyval = MPI.Comm.Create_keyval(copy_fn, delete_fn)
        self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID)

        attrval = [1, 2, 3]
        rc = getrc(attrval)
        self.comm.Set_attr(self.keyval, attrval)
        self.assertEqual(getrc(attrval), rc + 1)

        o = self.comm.Get_attr(self.keyval)
        self.assertTrue(o is attrval)
        self.assertEqual(getrc(attrval), rc + 2)
        o = None

        dupcomm = self.comm.Clone()
        if copy_fn is True:
            self.assertEqual(getrc(attrval), rc + 2)
        o = dupcomm.Get_attr(self.keyval)
        if copy_fn is True:
            self.assertTrue(o is attrval)
            self.assertEqual(getrc(attrval), rc + 3)
        elif not copy_fn:
            self.assertTrue(o is None)
            self.assertEqual(getrc(attrval), rc + 1)
        dupcomm.Free()
        o = None

        self.assertEqual(getrc(attrval), rc + 1)
        self.comm.Delete_attr(self.keyval)
        self.assertEqual(getrc(attrval), rc)

        o = self.comm.Get_attr(self.keyval)
        self.assertTrue(o is None)
Пример #4
0
    def testAttrCopyDelete(self):
        self.keyval = MPI.Win.Create_keyval(delete_fn=MPI.Win.Free)
        self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID)

        newwin = MPI.Win.Create(MPI.BOTTOM, 1,
                                MPI.INFO_NULL, MPI.COMM_SELF)
        rc = getrc(newwin)
        #
        self.win.Set_attr(self.keyval, newwin)
        self.assertTrue(newwin != MPI.WIN_NULL)
        self.assertTrue(getrc(newwin), rc+1)
        #
        self.win.Delete_attr(self.keyval)
        self.assertTrue(newwin == MPI.WIN_NULL)
        self.assertTrue(getrc(newwin), rc)
Пример #5
0
    def testAttrCopyDelete(self):
        self.keyval = MPI.Comm.Create_keyval(
            copy_fn=MPI.Comm.Clone,
            delete_fn=MPI.Comm.Free)
        self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID)

        comm1 = self.comm
        dupcomm1 = comm1.Clone()
        rc = getrc(dupcomm1)

        comm1.Set_attr(self.keyval, dupcomm1)
        self.assertTrue(dupcomm1 != MPI.COMM_NULL)
        self.assertTrue(getrc(dupcomm1), rc+1)

        comm2 = comm1.Clone()
        dupcomm2 = comm2.Get_attr(self.keyval)
        self.assertTrue(dupcomm1 != dupcomm2)
        self.assertTrue(getrc(dupcomm1), rc+1)
        self.assertTrue(getrc(dupcomm2), 3)
        comm2.Free()
        self.assertTrue(dupcomm2 == MPI.COMM_NULL)
        self.assertTrue(getrc(dupcomm1), rc+1)
        self.assertTrue(getrc(dupcomm2), 2)

        self.comm.Delete_attr(self.keyval)
        self.assertTrue(dupcomm1 == MPI.COMM_NULL)
        self.assertTrue(getrc(dupcomm1), rc)
Пример #6
0
    def testAttrCopyDelete(self):
        self.keyval = MPI.Datatype.Create_keyval(
            copy_fn=MPI.Datatype.Dup,
            delete_fn=MPI.Datatype.Free)
        self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID)

        datatype1 = self.datatype
        dupdatatype1 = datatype1.Dup()
        rc = getrc(dupdatatype1)

        datatype1.Set_attr(self.keyval, dupdatatype1)
        self.assertTrue(dupdatatype1 != MPI.DATATYPE_NULL)
        self.assertTrue(getrc(dupdatatype1), rc+1)

        datatype2 = datatype1.Dup()
        dupdatatype2 = datatype2.Get_attr(self.keyval)
        self.assertTrue(dupdatatype1 != dupdatatype2)
        self.assertTrue(getrc(dupdatatype1), rc+1)
        self.assertTrue(getrc(dupdatatype2), 3)
        datatype2.Free()
        self.assertTrue(dupdatatype2 == MPI.DATATYPE_NULL)
        self.assertTrue(getrc(dupdatatype1), rc+1)
        self.assertTrue(getrc(dupdatatype2), 2)

        self.datatype.Delete_attr(self.keyval)
        self.assertTrue(dupdatatype1 == MPI.DATATYPE_NULL)
        self.assertTrue(getrc(dupdatatype1), rc)
Пример #7
0
    def testAttrCopyDelete(self):
        self.keyval = MPI.Comm.Create_keyval(copy_fn=MPI.Comm.Clone,
                                             delete_fn=MPI.Comm.Free)
        self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID)

        comm1 = self.comm
        dupcomm1 = comm1.Clone()
        rc = getrc(dupcomm1)

        comm1.Set_attr(self.keyval, dupcomm1)
        self.assertTrue(dupcomm1 != MPI.COMM_NULL)
        self.assertTrue(getrc(dupcomm1), rc + 1)

        comm2 = comm1.Clone()
        dupcomm2 = comm2.Get_attr(self.keyval)
        self.assertTrue(dupcomm1 != dupcomm2)
        self.assertTrue(getrc(dupcomm1), rc + 1)
        self.assertTrue(getrc(dupcomm2), 3)
        comm2.Free()
        self.assertTrue(dupcomm2 == MPI.COMM_NULL)
        self.assertTrue(getrc(dupcomm1), rc + 1)
        self.assertTrue(getrc(dupcomm2), 2)

        self.comm.Delete_attr(self.keyval)
        self.assertTrue(dupcomm1 == MPI.COMM_NULL)
        self.assertTrue(getrc(dupcomm1), rc)
Пример #8
0
    def testAttrCopyDelete(self):
        self.keyval = MPI.Datatype.Create_keyval(copy_fn=MPI.Datatype.Dup,
                                                 delete_fn=MPI.Datatype.Free)
        self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID)

        datatype1 = self.datatype
        dupdatatype1 = datatype1.Dup()
        rc = getrc(dupdatatype1)

        datatype1.Set_attr(self.keyval, dupdatatype1)
        self.assertTrue(dupdatatype1 != MPI.DATATYPE_NULL)
        self.assertTrue(getrc(dupdatatype1), rc + 1)

        datatype2 = datatype1.Dup()
        dupdatatype2 = datatype2.Get_attr(self.keyval)
        self.assertTrue(dupdatatype1 != dupdatatype2)
        self.assertTrue(getrc(dupdatatype1), rc + 1)
        self.assertTrue(getrc(dupdatatype2), 3)
        datatype2.Free()
        self.assertTrue(dupdatatype2 == MPI.DATATYPE_NULL)
        self.assertTrue(getrc(dupdatatype1), rc + 1)
        self.assertTrue(getrc(dupdatatype2), 2)

        self.datatype.Delete_attr(self.keyval)
        self.assertTrue(dupdatatype1 == MPI.DATATYPE_NULL)
        self.assertTrue(getrc(dupdatatype1), rc)
Пример #9
0
    def testAttr(self, copy_fn=None, delete_fn=None):
        self.keyval = MPI.Win.Create_keyval(copy_fn, delete_fn)
        self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID)

        attrval = [1, 2, 3]
        rc = getrc(attrval)
        self.win.Set_attr(self.keyval, attrval)
        self.assertEqual(getrc(attrval), rc + 1)

        o = self.win.Get_attr(self.keyval)
        self.assertTrue(o is attrval)
        self.assertEqual(getrc(attrval), rc + 2)
        o = None

        self.assertEqual(getrc(attrval), rc + 1)
        self.win.Delete_attr(self.keyval)
        self.assertEqual(getrc(attrval), rc)

        o = self.win.Get_attr(self.keyval)
        self.assertTrue(o is None)
Пример #10
0
    def testAttr(self, copy_fn=None, delete_fn=None):
        self.keyval = MPI.Win.Create_keyval(copy_fn, delete_fn)
        self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID)

        attrval = [1,2,3]
        rc = getrc(attrval)
        self.win.Set_attr(self.keyval, attrval)
        self.assertEqual(getrc(attrval), rc+1)

        o = self.win.Get_attr(self.keyval)
        self.assertTrue(o is attrval)
        self.assertEqual(getrc(attrval), rc+2)
        o = None

        self.assertEqual(getrc(attrval), rc+1)
        self.win.Delete_attr(self.keyval)
        self.assertEqual(getrc(attrval), rc)


        o = self.win.Get_attr(self.keyval)
        self.assertTrue(o is None)