<commit_before>from mpi4py import MPI
import mpiunittest as unittest
import arrayimpl


class BaseTestP2PBufPart(object):

    COMM = MPI.COMM_NULL

    def testSelf(self):
        size = self.COMM.Get_size()
        rank = self.COMM.Get_rank()
        for array, typecode in arrayimpl.subTest(self):
            for s in range(1, size):
                for p in range(1, 4):
                    sbuf = array( s, typecode, s*p)
                    rbuf = array(-1, typecode, s*p)
                    sreq = self.COMM.Psend_init(sbuf.as_mpi(), p, rank, 0)
                    rreq = self.COMM.Precv_init(rbuf.as_mpi(), p, rank, 0)
                    for _ in range(3):
                        rreq.Start()
                        for i in range(p):
                            flag = rreq.Parrived(i)
                            self.assertFalse(flag)
                        sreq.Start()
                        for i in range(p):
                            sreq.Pready(i)
                            for j in range(i+1, p):
                                flag = rreq.Parrived(j)
                                self.assertFalse(flag)
                        for i in range(p):
                            while not rreq.Parrived(i): pass
                            flag = rreq.Parrived(i)
                            self.assertTrue(flag)
                        rreq.Wait()
                        sreq.Wait()
                        self.assertNotEqual(sreq, MPI.REQUEST_NULL)
                        self.assertNotEqual(rreq, MPI.REQUEST_NULL)
                        for value in rbuf:
                            self.assertEqual(value, s)
                    rreq.Free()
                    sreq.Free()
                    self.assertEqual(sreq, MPI.REQUEST_NULL)
                    self.assertEqual(rreq, MPI.REQUEST_NULL)

    def testRing(self):
        size = self.COMM.Get_size()
        rank = self.COMM.Get_rank()
        dest = (rank + 1) % size
        source = (rank - 1) % size
        for array, typecode in arrayimpl.subTest(self):
            for s in range(1, size):
                for p in range(1, 4):
                    sbuf = array( s, typecode, s*p)
                    rbuf = array(-1, typecode, s*p)
                    sreq = self.COMM.Psend_init(sbuf.as_mpi(), p, dest, 0)
                    rreq = self.COMM.Precv_init(rbuf.as_mpi(), p, source, 0)
                    for _ in range(3):
                        self.COMM.Barrier()
                        rreq.Start()
                        for i in range(p):
                            flag = rreq.Parrived(i)
                            self.assertFalse(flag)
                        self.COMM.Barrier()
                        sreq.Start()
                        for i in range(p):
                            sreq.Pready(i)
                        self.COMM.Barrier()
                        for i in range(p):
                            while not rreq.Parrived(i): pass
                            flag = rreq.Parrived(i)<commit_msg>test: Fix partitioned communication tests to include zero-size messages<commit_after>from mpi4py import MPI
import mpiunittest as unittest
import arrayimpl


class BaseTestP2PBufPart(object):

    COMM = MPI.COMM_NULL

    def testSelf(self):
        size = self.COMM.Get_size()
        rank = self.COMM.Get_rank()
        for array, typecode in arrayimpl.subTest(self):
            for s in range(0, size):
                for p in range(1, 4):
                    sbuf = array( s, typecode, s*p)
                    rbuf = array(-1, typecode, s*p)
                    sreq = self.COMM.Psend_init(sbuf.as_mpi(), p, rank, 0)
                    rreq = self.COMM.Precv_init(rbuf.as_mpi(), p, rank, 0)
                    for _ in range(3):
                        rreq.Start()
                        for i in range(p):
                            flag = rreq.Parrived(i)
                            self.assertFalse(flag)
                        sreq.Start()
                        for i in range(p):
                            sreq.Pready(i)
                            for j in range(i+1, p):
                                flag = rreq.Parrived(j)
                                self.assertFalse(flag)
                        for i in range(p):
                            while not rreq.Parrived(i): pass
                            flag = rreq.Parrived(i)
                            self.assertTrue(flag)
                        rreq.Wait()
                        sreq.Wait()
                        self.assertNotEqual(sreq, MPI.REQUEST_NULL)
                        self.assertNotEqual(rreq, MPI.REQUEST_NULL)
                        for value in rbuf:
                            self.assertEqual(value, s)
                    rreq.Free()
                    sreq.Free()
                    self.assertEqual(sreq, MPI.REQUEST_NULL)
                    self.assertEqual(rreq, MPI.REQUEST_NULL)

    def testRing(self):
        size = self.COMM.Get_size()
        rank = self.COMM.Get_rank()
        dest = (rank + 1) % size
        source = (rank - 1) % size
        for array, typecode in arrayimpl.subTest(self):
            for s in range(0, size):
                for p in range(1, 4):
                    sbuf = array( s, typecode, s*p)
                    rbuf = array(-1, typecode, s*p)
                    sreq = self.COMM.Psend_init(sbuf.as_mpi(), p, dest, 0)
                    rreq = self.COMM.Precv_init(rbuf.as_mpi(), p, source, 0)
                    for _ in range(3):
                        self.COMM.Barrier()
                        rreq.Start()
                        for i in range(p):
                            flag = rreq.Parrived(i)
                            self.assertFalse(flag)
                        self.COMM.Barrier()
                        sreq.Start()
                        for i in range(p):
                            sreq.Pready(i)
                        self.COMM.Barrier()
                        for i in range(p):
                            while not rreq.Parrived(i): pass
                            flag = rreq.Parrived(i)
{'fraction_non_alphanumeric': 0.09049330284220843, 'fraction_numerical': 0.006207121855602744, 'mean_word_length': 0.9688102893890675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5771213', 'n_tokens_mistral': 1713, 'n_tokens_neox': 1593, 'n_words': 379}