tlm_noc_sim/scripts/others/gen_map_random.py

34 lines
603 B
Python

import random
NET_SIZE_X = 4
NET_SIZE_Y = 4
NET_SIZE_Z = 1
NUM_TASKS = 84
REPEAT = 2
MAP_START = """<?xml version="1.0" ?>
<map xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">"""
BIND = """ <bind>
<task value="{}"/>
<node value="{}"/>
</bind>"""
MAP_END = "</map>"
NUM_NODES = NET_SIZE_X*NET_SIZE_Y*NET_SIZE_Z
print(MAP_START)
count = 0
for i in range(NUM_TASKS):
#node_id = random.randint(0, NUM_NODES-1)
node_id = count
if ((i+1) % REPEAT) == 0:
count += 1
if count >= NUM_NODES:
count = 0
print(BIND.format(i, node_id))
print(MAP_END)