Exemplo n.º 1
0
    def setrankaffinity(self):
        """pins the rank to an available core on its node"""
        ranknodes = self.comm.alltoall([self.name]*self.size)
        ranksonnode = [i for i, j in enumerate(ranknodes) if j == self.name]

        rankaffinity = sched_getaffinity()
        self.log.debug("affinity pre-set: %s", rankaffinity)

        cores = [i for i, j in enumerate(rankaffinity.cpus) if j == 1L]

        topin = None
        for index, iterrank in enumerate(ranksonnode):
            if iterrank == self.rank:
                topin = cores[index % len(cores)]
                self.log.debug("setting affinity to core: %s", topin)

        if topin is None:
            topin = cores[0]
            self.log.warning("could not determine core to pin the rank to. automatically set it to %s", topin)

        rankaffinity.convert_hr_bits(str(topin))
        rankaffinity.set_bits()
        sched_setaffinity(rankaffinity)

        rankaffinity = sched_getaffinity()
        self.log.debug("affinity post-set: %s", rankaffinity)
        return str(rankaffinity)
Exemplo n.º 2
0
    def setrankaffinity(self):
        """pins the rank to an available core on its node"""
        ranknodes = self.comm.alltoall([self.name] * self.size)
        ranksonnode = [i for i, j in enumerate(ranknodes) if j == self.name]

        rankaffinity = sched_getaffinity()
        self.log.debug("affinity pre-set: %s", rankaffinity)

        cores = [i for i, j in enumerate(rankaffinity.cpus) if j == 1L]

        topin = None
        for index, iterrank in enumerate(ranksonnode):
            if iterrank == self.rank:
                topin = cores[index % len(cores)]
                self.log.debug("setting affinity to core: %s", topin)

        if topin is None:
            topin = cores[0]
            self.log.warning(
                "could not determine core to pin the rank to. automatically set it to %s",
                topin)

        rankaffinity.convert_hr_bits(str(topin))
        rankaffinity.set_bits()
        sched_setaffinity(rankaffinity)

        rankaffinity = sched_getaffinity()
        self.log.debug("affinity post-set: %s", rankaffinity)
        return str(rankaffinity)
 def _set_affinity(self):
     cs = cpu_set_t()
     cs.set_bits(cpus=self.cpusett.cpus)
     sched_setaffinity(cs, pid=self.pid)
Exemplo n.º 4
0
 def _set_affinity(self):
     cs = cpu_set_t()
     cs.set_bits(cpus=self.cpusett.cpus)
     sched_setaffinity(cs, pid=self.pid)