Beispiel #1
0
def main():
    global directory, mach
    options, args = parser.parse_args()
    experiments = args if args else None
    if not database.get_instance(options.url):
        print("ERROR: could not connect to the database")
        sys.exit(-1)
    directory = options.directory
    if len(args) > 0:
        m = model.parse_model_file(args[0])
        mach = m.machine
    else:
        mach = machine.MachineType()
    max_size = get_max_size()
    line_count = util.round_power2(max_size // (mach.word_size * 8))
    while line_count >= 128:
        line_size = util.round_power2(max_size // 8)
        while line_size >= mach.word_size:
            associativity = min(line_count, 8)
            while associativity >= 1:
                for policy in get_policies(associativity):
                    generate_cache(line_count, line_size, associativity, policy, True, experiments)
                    generate_cache(line_count, line_size, associativity, policy, False, experiments)
                associativity //= 2
            line_size //= 2
        line_count //= 2
    print("Total:", total)
    print("Best Cost:  ", best_cost)
    print("Best Memory:", best_name)
Beispiel #2
0
    def __init__(self, index, word_size, depth, mem):
        """Create a memory to be used with a kernel.

        Arguments:
            index:      A unique identifier for this subsystem.
            word_size:  The word size in bytes.
            depth:      The number of words.
            mem:        The memory subsystem.
        """
        base.Memory.__init__(self)
        self.index = index
        self.word_size = util.round_power2(word_size)
        self.mem = mem
        self.depth = depth
        self.score = 0
Beispiel #3
0
def estimate_cost(width, depth):
    if mach.target == machine.TargetType.FPGA:
        if width % BRAM_WIDTH != 0:
            max_width = BRAM_WIDTH * BRAM_DEPTH
            small_width = width % BRAM_WIDTH
            rounded_width = util.round_power2(small_width)
            small_depth = max_width // rounded_width
            result = (depth + small_depth - 1) // small_depth
        else:
            result = 0
        big_count = width // BRAM_WIDTH
        big_depth = (depth + BRAM_DEPTH - 1) // BRAM_DEPTH
        result += big_depth * big_count
        return result
    elif mach.target == machine.TargetType.SIMPLE:
        return width * depth
    else:
        return width * depth * mach.technology
Beispiel #4
0
 def test_rp2(self):
     self.assertEqual(util.round_power2(4), 4)
     self.assertEqual(util.round_power2(5), 8)
     self.assertEqual(util.round_power2(7), 8)
     self.assertEqual(util.round_power2(8), 8)