Part 1. One core · lesson 3 of 42
3. The card¶
The card is a chip with a grid of 120 small computers, a big memory around them, and a network that joins them all. This lesson names the parts. It relies on lesson 1, What Komorebi is and has no code to write: a picture, and a short program that asks the card about itself.
The parts, in one picture¶
Press Next to see each part in turn.
- A Tensix core is one of the 120 small computers. This is where your code runs, and
all of this tutorial is about them. There are 12 in a row: the first six are the left
panel, the last six the right panel. Core
nis in rown // 12and placen % 12of that row. - DRAM is the big memory, many gigabytes, split in eight banks. It is far from the cores and slow compared with the memory inside a core.
- The NoC (network on chip) is the network between every core, every DRAM bank and the X280 cores. A core uses it to copy data from DRAM to itself, from itself to DRAM, or to another core.
- The X280 cores are the other kind of core. lesson 32, Hello, thread is the first lesson that uses them. Until then they are only a place that some of Komorebi runs on.
- The host is your computer.
Inside a Tensix core¶
A Tensix core is five small CPUs that share one memory.
- L1 is the core's own memory. A core works on what is in its L1 and on nothing else. After Komorebi has taken its share, 1.4 MB are left for your data. L1 is not a cache: nothing is copied into it unless a program asks for it.
- Two of the five CPUs move data. Either of them can copy data from DRAM into L1, from L1 to DRAM, and between the L1 of one core and another's. They are alike, with two differences that later lessons use: each of them uses its own NoC, and each queue of data in L1 has one CPU that fills it and one that empties it. Lesson 4 gives each of them a name.
- The other three CPUs, together with the matrix and vector units that they drive, do the arithmetic. They get a lesson of their own in Part 3.
The five CPUs run at the same time, each its own code. That is the reason for a core having so many: while one moves the next piece of data in, the others work on the piece before.
Ask the card¶
You can ask the card for these facts from Python. One fragment at a time:
columns, rows = session.grid
print(f"{columns * rows} Tensix cores: {columns} in a row, {rows} rows")
session.grid is the number of cores in a row and the number of rows.
(left_first, left_last), (right_first, right_last) = session.nocs().panels
print(f"panels: columns {left_first}-{left_last} and {right_first}-{right_last}")
The two panels, as the first and the last column of each.
session.l1() gives two numbers; the second is how many bytes of each core's L1 are left
for your data. The _ throws the first one away.
All three lines run inside with km.Session() as session:, which opens the card. Lesson 4
explains that line. The whole program, and what it printed:
120 Tensix cores: 12 in a row, 10 rows
panels: columns 0-5 and 6-11
each core has 1,461,120 bytes of L1 for data
Common mistakes¶
- Thinking of a core as one CPU. It is five, and they run different code at the same time.
- Thinking L1 is a cache. Nothing is in a core's L1 unless a program put it there.
- Counting cores from one. The numbers run from 0 to 119.
Next: lesson 4, Hello, core writes the smallest program that runs on a core.