mapper_miniVite.py
def seed_configurations(self):
        """
        Look for seed configuration permutation in file 'seed_permutation.txt'.
        If this file doesn't exist, proceed with a consecutive assignment of ranks
        to processes
        """
        """
        return[{'Perm':p}]
        return [{'Perm': list(range(self.processes)), 'Perm' : random.shuffle(list(range(self.processes))),
                 'Perm_reversed' : (list(range(self.processes))).reverse()}]
        """
        if self.seed_file != 'not set':
            seeds = []
            try:
                with open(self.seed_file, 'r') as f:
                    seeds = json.load(f)
                print(seeds)
                #return self.translate_permutation_to_config(p)
            except RuntimeError:
                pass
                #p = list(range(self.processes))
                #return self.translate_permutation_to_config(p)
            p = [-1 for _ in range(self.processes)]
            l_ppn = self.G.getNumVertices() // self.n_nodes
            for node in range(self.n_nodes):
                for core in range(l_ppn):
                    p[self.pps * self.n_sockets * node + core] = l_ppn * node + core
            seeds.append({'Perm': p})
            print('Appended Blocked')
            return seeds
        else:
            """Hyperplane Permutation 16x16"""
            # p = [0, 16, 32, 48, 1, 17, 33, 49, 2, 18, 34, 50, 3, 19, 35, 51, 4, 20, 36, 52, 5, 21, 37, 53, 6, 22, 38, 54, 7, 23, 39, 55, 64, 80, 96, 112, 65, 81, 97, 113, 66, 82, 98, 114, 67, 83, 99, 115, 68, 84, 100, 116, 69, 85, 101, 117, 70, 86, 102, 118, 71, 87, 103, 119, 8, 24, 40, 56, 9, 25, 41, 57, 10, 26, 42, 58, 11, 27, 43, 59, 12, 28, 44, 60, 13, 29, 45, 61, 14, 30, 46, 62, 15, 31, 47, 63, 72, 88, 104, 120, 73, 89, 105, 121, 74, 90, 106, 122, 75, 91, 107, 123, 76, 92, 108, 124, 77, 93, 109, 125, 78, 94, 110, 126, 79, 95, 111, 127, 128, 144, 160, 176, 129, 145, 161, 177, 130, 146, 162, 178, 131, 147, 163, 179, 132, 148, 164, 180, 133, 149, 165, 181, 134, 150, 166, 182, 135, 151, 167, 183, 192, 208, 224, 240, 193, 209, 225, 241, 194, 210, 226, 242, 195, 211, 227, 243, 196, 212, 228, 244, 197, 213, 229, 245, 198, 214, 230, 246, 199, 215, 231, 247, 136, 152, 168, 184, 137, 153, 169, 185, 138, 154, 170, 186, 139, 155, 171, 187, 140, 156, 172, 188, 141, 157, 173, 189, 142, 158, 174, 190, 143, 159, 175, 191, 200, 216, 232, 248, 201, 217, 233, 249, 202, 218, 234, 250, 203, 219, 235, 251, 204, 220, 236, 252, 205, 221, 237, 253, 206, 222, 238, 254, 207, 223, 239, 255]
            """Hyperplane Permutation 6x31"""
            # p = [0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 1, 2, 7, 8, 13, 14, 19, 20, 25, 26, 31, 32, 37, 38, 43, 44, 49, 50, 55, 56, 61, 62, 67, 68, 73, 74, 79, 80, 85, 86, 91, 92, 97, 98, 103, 104, 109, 110, 115, 116, 121, 122, 127, 128, 133, 134, 139, 140, 145, 146, 151, 152, 157, 158, 163, 164, 169, 170, 175, 176, 181, 182, 3, 4, 9, 10, 15, 16, 21, 22, 27, 28, 33, 34, 39, 40, 45, 46, 51, 52, 57, 58, 63, 64, 69, 70, 75, 76, 81, 82, 87, 88, 93, 94, 99, 100, 105, 106, 111, 112, 117, 118, 123, 124, 129, 130, 135, 136, 141, 142, 147, 148, 153, 154, 159, 160, 165, 166, 171, 172, 177, 178, 183, 184, 5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119, 125, 131, 137, 143, 149, 155, 161, 167, 173, 179, 185]
            # seed_hp = self.translate_permutation_to_config(p)
            """kd Tree Permutation 16x16"""
            # p = [0, 1, 2, 6, 12, 7, 8, 13, 14, 3, 4, 5, 9, 15, 10, 11, 16, 17, 18, 24, 19, 20, 25, 26, 30, 36, 31, 32, 37, 38, 21, 27, 22, 23, 28, 29, 33, 39, 34, 35, 40, 41, 42, 48, 43, 44, 49, 50, 54, 60, 55, 56, 61, 62, 45, 51, 46, 47, 52, 53, 57, 63, 58, 59, 64, 65, 66, 72, 67, 68, 73, 74, 78, 84, 79, 80, 85, 86, 69, 75, 70, 71, 76, 77, 81, 87, 82, 83, 88, 89, 90, 96, 91, 92, 97, 98, 102, 108, 103, 104, 109, 110, 93, 99, 94, 95, 100, 101, 105, 111, 106, 107, 112, 113, 114, 120, 115, 116, 121, 122, 126, 132, 127, 128, 133, 134, 117, 123, 118, 119, 124, 125, 129, 135, 130, 131, 136, 137, 138, 144, 139, 140, 145, 146, 150, 156, 151, 152, 157, 158, 141, 147, 142, 143, 148, 149, 153, 159, 154, 155, 160, 161, 162, 168, 163, 164, 169, 170, 174, 180, 175, 176, 181, 182, 165, 171, 166, 167, 172, 173, 177, 183, 178, 179, 184, 185]
            self.log.debug(HIGHLIGHTER + "entered seed" + HIGHLIGHTER)
            seeds = []
            p = [-1 for _ in range(self.processes)]
            l_ppn = self.G.getNumVertices() // self.n_nodes
            for node in range(self.n_nodes):
                for core in range(l_ppn):
                    p[self.pps * self.n_sockets * node + core] = l_ppn * node + core
            # bottleneck, sum = utils.countInterNodeCommunication(self.G, p, self.n_nodes, self.pps*self.n_sockets)
            # if sum < self.sum and sum > 0:
            #    self.bottleneck, self.sum = bottleneck, sum
            #    self.init_perm = p
            # self.seen_configurations[utils.hash_permutation(p, self.n_sockets, self.n_nodes, self.pps)] = np.inf
            seeds.append({'Perm': p})
            p = [-1 for _ in range(self.processes)]
            for v in range(self.G.getNumVertices()):
                p[v] = v
            # bottleneck, sum = utils.countInterNodeCommunication(self.G, p, self.n_nodes, self.pps*self.n_sockets)
            # if sum < self.sum and sum > 0:
            #    self.bottleneck, self.sum = bottleneck, sum
            #    self.init_perm = p
            # self.seen_configurations[utils.hash_permutation(p, self.n_sockets, self.n_nodes, self.pps)] = np.inf
            seeds.append({'Perm': p})
            self.init_perm = list(range(self.processes))
            """
            for _ in range(40):
                p = util.greedy_partition_grower(self.n_nodes, self.pps * self.n_sockets, self.stencil, self.dims)
                mapping = util.mapping_from_permutation(p, self.dims, [self.pps * self.n_sockets] * self.n_nodes)
                bottleneck, sum = util.analyze_matrix(mapping, self.stencil)
                if sum < self.sum:
                    self.bottleneck, self.sum = bottleneck, sum
                    self.init_perm = p
                self.seen_configurations[util.hash_permutation(p, self.n_sockets, self.n_nodes, self.pps)] = np.inf
                #seeds.append(self.translate_permutation_to_config(p))
                seeds.append({'Perm': p})
            # FIX ME. Want to return the actual runtime of best seen configuration
            #seed_block = self.translate_permutation_to_config(list(range(self.processes)))
            """
            self.log.info(HIGHLIGHTER + "end of seed" + HIGHLIGHTER)
            return seeds
        # """

        Look for seed configuration permutation in file 'seed_permutation.txt'.
        If this file doesn't exist, proceed with a consecutive assignment of ranks
        to processes
        
Look for seed configuration permutation in file 'seed_permutation.txt'.
If this file doesn't exist, proceed with a consecutive assignment of ranks
to processes
Look for seed configuration permutation in file ' seed_permutation . txt ' . If this file doesn ' t exist proceed with a consecutive assignment of ranks to processes
def seed_configurations(self):
        if self.seed_file != 'not set':
            seeds = []
            try:
                with open(self.seed_file, 'r') as f:
                    seeds = json.load(f)
                print(seeds)
            except RuntimeError:
                pass
            p = [-1 for _ in range(self.processes)]
            l_ppn = self.G.getNumVertices() // self.n_nodes
            for node in range(self.n_nodes):
                for core in range(l_ppn):
                    p[self.pps * self.n_sockets * node + core] = l_ppn * node + core
            seeds.append({'Perm': p})
            print('Appended Blocked')
            return seeds
        else:
            self.log.debug(HIGHLIGHTER + "entered seed" + HIGHLIGHTER)
            seeds = []
            p = [-1 for _ in range(self.processes)]
            l_ppn = self.G.getNumVertices() // self.n_nodes
            for node in range(self.n_nodes):
                for core in range(l_ppn):
                    p[self.pps * self.n_sockets * node + core] = l_ppn * node + core
            seeds.append({'Perm': p})
            p = [-1 for _ in range(self.processes)]
            for v in range(self.G.getNumVertices()):
                p[v] = v
            seeds.append({'Perm': p})
            self.init_perm = list(range(self.processes))
            self.log.info(HIGHLIGHTER + "end of seed" + HIGHLIGHTER)
            return seeds
def seed_configurations ( self ) : """
        return[{'Perm':p}]
        return [{'Perm': list(range(self.processes)), 'Perm' : random.shuffle(list(range(self.processes))),
                 'Perm_reversed' : (list(range(self.processes))).reverse()}]
        """ if self . seed_file != 'not set' : seeds = [ ] try : with open ( self . seed_file , 'r' ) as f : seeds = json . load ( f ) print ( seeds ) except RuntimeError : pass p = [ - 1 for _ in range ( self . processes ) ] l_ppn = self . G . getNumVertices ( ) // self . n_nodes for node in range ( self . n_nodes ) : for core in range ( l_ppn ) : p [ self . pps * self . n_sockets * node + core ] = l_ppn * node + core seeds . append ( { 'Perm' : p } ) print ( 'Appended Blocked' ) return seeds else : """Hyperplane Permutation 16x16""" """Hyperplane Permutation 6x31""" """kd Tree Permutation 16x16""" self . log . debug ( HIGHLIGHTER + "entered seed" + HIGHLIGHTER ) seeds = [ ] p = [ - 1 for _ in range ( self . processes ) ] l_ppn = self . G . getNumVertices ( ) // self . n_nodes for node in range ( self . n_nodes ) : for core in range ( l_ppn ) : p [ self . pps * self . n_sockets * node + core ] = l_ppn * node + core seeds . append ( { 'Perm' : p } ) p = [ - 1 for _ in range ( self . processes ) ] for v in range ( self . G . getNumVertices ( ) ) : p [ v ] = v seeds . append ( { 'Perm' : p } ) self . init_perm = list ( range ( self . processes ) ) """
            for _ in range(40):
                p = util.greedy_partition_grower(self.n_nodes, self.pps * self.n_sockets, self.stencil, self.dims)
                mapping = util.mapping_from_permutation(p, self.dims, [self.pps * self.n_sockets] * self.n_nodes)
                bottleneck, sum = util.analyze_matrix(mapping, self.stencil)
                if sum < self.sum:
                    self.bottleneck, self.sum = bottleneck, sum
                    self.init_perm = p
                self.seen_configurations[util.hash_permutation(p, self.n_sockets, self.n_nodes, self.pps)] = np.inf
                #seeds.append(self.translate_permutation_to_config(p))
                seeds.append({'Perm': p})
            # FIX ME. Want to return the actual runtime of best seen configuration
            #seed_block = self.translate_permutation_to_config(list(range(self.processes)))
            """ self . log . info ( HIGHLIGHTER + "end of seed" + HIGHLIGHTER ) return seeds
Look for seed configuration permutation in file 'seed_permutation.txt'.
Look for seed configuration permutation in file ' seed_permutation . txt ' .
"""
        Look for seed configuration permutation in file 'seed_permutation.txt'.
        If this file doesn't exist, proceed with a consecutive assignment of ranks
        to processes
        """ """
        return[{'Perm':p}]
        return [{'Perm': list(range(self.processes)), 'Perm' : random.shuffle(list(range(self.processes))),
                 'Perm_reversed' : (list(range(self.processes))).reverse()}]
        """ #return self.translate_permutation_to_config(p) #p = list(range(self.processes)) #return self.translate_permutation_to_config(p) """Hyperplane Permutation 16x16""" # p = [0, 16, 32, 48, 1, 17, 33, 49, 2, 18, 34, 50, 3, 19, 35, 51, 4, 20, 36, 52, 5, 21, 37, 53, 6, 22, 38, 54, 7, 23, 39, 55, 64, 80, 96, 112, 65, 81, 97, 113, 66, 82, 98, 114, 67, 83, 99, 115, 68, 84, 100, 116, 69, 85, 101, 117, 70, 86, 102, 118, 71, 87, 103, 119, 8, 24, 40, 56, 9, 25, 41, 57, 10, 26, 42, 58, 11, 27, 43, 59, 12, 28, 44, 60, 13, 29, 45, 61, 14, 30, 46, 62, 15, 31, 47, 63, 72, 88, 104, 120, 73, 89, 105, 121, 74, 90, 106, 122, 75, 91, 107, 123, 76, 92, 108, 124, 77, 93, 109, 125, 78, 94, 110, 126, 79, 95, 111, 127, 128, 144, 160, 176, 129, 145, 161, 177, 130, 146, 162, 178, 131, 147, 163, 179, 132, 148, 164, 180, 133, 149, 165, 181, 134, 150, 166, 182, 135, 151, 167, 183, 192, 208, 224, 240, 193, 209, 225, 241, 194, 210, 226, 242, 195, 211, 227, 243, 196, 212, 228, 244, 197, 213, 229, 245, 198, 214, 230, 246, 199, 215, 231, 247, 136, 152, 168, 184, 137, 153, 169, 185, 138, 154, 170, 186, 139, 155, 171, 187, 140, 156, 172, 188, 141, 157, 173, 189, 142, 158, 174, 190, 143, 159, 175, 191, 200, 216, 232, 248, 201, 217, 233, 249, 202, 218, 234, 250, 203, 219, 235, 251, 204, 220, 236, 252, 205, 221, 237, 253, 206, 222, 238, 254, 207, 223, 239, 255] """Hyperplane Permutation 6x31""" # p = [0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 1, 2, 7, 8, 13, 14, 19, 20, 25, 26, 31, 32, 37, 38, 43, 44, 49, 50, 55, 56, 61, 62, 67, 68, 73, 74, 79, 80, 85, 86, 91, 92, 97, 98, 103, 104, 109, 110, 115, 116, 121, 122, 127, 128, 133, 134, 139, 140, 145, 146, 151, 152, 157, 158, 163, 164, 169, 170, 175, 176, 181, 182, 3, 4, 9, 10, 15, 16, 21, 22, 27, 28, 33, 34, 39, 40, 45, 46, 51, 52, 57, 58, 63, 64, 69, 70, 75, 76, 81, 82, 87, 88, 93, 94, 99, 100, 105, 106, 111, 112, 117, 118, 123, 124, 129, 130, 135, 136, 141, 142, 147, 148, 153, 154, 159, 160, 165, 166, 171, 172, 177, 178, 183, 184, 5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119, 125, 131, 137, 143, 149, 155, 161, 167, 173, 179, 185] # seed_hp = self.translate_permutation_to_config(p) """kd Tree Permutation 16x16""" # p = [0, 1, 2, 6, 12, 7, 8, 13, 14, 3, 4, 5, 9, 15, 10, 11, 16, 17, 18, 24, 19, 20, 25, 26, 30, 36, 31, 32, 37, 38, 21, 27, 22, 23, 28, 29, 33, 39, 34, 35, 40, 41, 42, 48, 43, 44, 49, 50, 54, 60, 55, 56, 61, 62, 45, 51, 46, 47, 52, 53, 57, 63, 58, 59, 64, 65, 66, 72, 67, 68, 73, 74, 78, 84, 79, 80, 85, 86, 69, 75, 70, 71, 76, 77, 81, 87, 82, 83, 88, 89, 90, 96, 91, 92, 97, 98, 102, 108, 103, 104, 109, 110, 93, 99, 94, 95, 100, 101, 105, 111, 106, 107, 112, 113, 114, 120, 115, 116, 121, 122, 126, 132, 127, 128, 133, 134, 117, 123, 118, 119, 124, 125, 129, 135, 130, 131, 136, 137, 138, 144, 139, 140, 145, 146, 150, 156, 151, 152, 157, 158, 141, 147, 142, 143, 148, 149, 153, 159, 154, 155, 160, 161, 162, 168, 163, 164, 169, 170, 174, 180, 175, 176, 181, 182, 165, 171, 166, 167, 172, 173, 177, 183, 178, 179, 184, 185] # bottleneck, sum = utils.countInterNodeCommunication(self.G, p, self.n_nodes, self.pps*self.n_sockets) # if sum < self.sum and sum > 0: #    self.bottleneck, self.sum = bottleneck, sum #    self.init_perm = p # self.seen_configurations[utils.hash_permutation(p, self.n_sockets, self.n_nodes, self.pps)] = np.inf # bottleneck, sum = utils.countInterNodeCommunication(self.G, p, self.n_nodes, self.pps*self.n_sockets) # if sum < self.sum and sum > 0: #    self.bottleneck, self.sum = bottleneck, sum #    self.init_perm = p # self.seen_configurations[utils.hash_permutation(p, self.n_sockets, self.n_nodes, self.pps)] = np.inf """
            for _ in range(40):
                p = util.greedy_partition_grower(self.n_nodes, self.pps * self.n_sockets, self.stencil, self.dims)
                mapping = util.mapping_from_permutation(p, self.dims, [self.pps * self.n_sockets] * self.n_nodes)
                bottleneck, sum = util.analyze_matrix(mapping, self.stencil)
                if sum < self.sum:
                    self.bottleneck, self.sum = bottleneck, sum
                    self.init_perm = p
                self.seen_configurations[util.hash_permutation(p, self.n_sockets, self.n_nodes, self.pps)] = np.inf
                #seeds.append(self.translate_permutation_to_config(p))
                seeds.append({'Perm': p})
            # FIX ME. Want to return the actual runtime of best seen configuration
            #seed_block = self.translate_permutation_to_config(list(range(self.processes)))
            """ # """
self