diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/simple_mesh1d/sim.c | 11 | ||||
| -rw-r--r-- | tests/simple_mesh1d/test.c | 13 | ||||
| -rw-r--r-- | tests/simple_mesh2d/sim.c | 80 | ||||
| -rw-r--r-- | tests/simple_mesh2d/test.c | 2 | ||||
| -rw-r--r-- | tests/simple_mesh3d/sim.c | 35 | ||||
| -rw-r--r-- | tests/simple_mesh3d/test.c | 14 |
6 files changed, 81 insertions, 74 deletions
diff --git a/tests/simple_mesh1d/sim.c b/tests/simple_mesh1d/sim.c index c5f7290..b419633 100644 --- a/tests/simple_mesh1d/sim.c +++ b/tests/simple_mesh1d/sim.c @@ -15,7 +15,6 @@ static stat build_node1d(struct clock_domain *clk, uint16_t x, uint16_t y) assert(mesh); for (int i = 1; i < x + 1; ++i) { - /* 4 CPUs + 1 mem = 5 elems in total */ struct component *node = create_mesh_node1d(i, y + 1); clock_domain_add(clk, node); mesh[i] = node; @@ -23,8 +22,8 @@ static stat build_node1d(struct clock_domain *clk, uint16_t x, uint16_t y) for (int j = 0; j < y; ++j) { struct component *imem = create_simple_mem(4096); init_simple_mem(imem, 0, - build_tests_simple_mesh1d_test_bin_len, - build_tests_simple_mesh1d_test_bin); + build_tests_simple_mesh1d_test_bin_len, + build_tests_simple_mesh1d_test_bin); uint64_t rcv = mesh1d_addr(i, j, 0); struct component *rv64 = create_simple_riscv64(rcv, 0, imem, node); @@ -44,7 +43,7 @@ static stat build_node1d(struct clock_domain *clk, uint16_t x, uint16_t y) mesh_node1d_connect(node, dmem, 4); } - /* extra I/O node (kind of?) */ + /* extra I/O node */ struct component *node = create_mesh_node1d(0, 2); clock_domain_add(clk, node); mesh[0] = node; @@ -59,10 +58,10 @@ static stat build_node1d(struct clock_domain *clk, uint16_t x, uint16_t y) for (int i = 0; i < x + 1; ++i) { if (i - 1 >= 0) - mesh_node1d_connect_right(mesh[i], mesh[i - 1]); + mesh_node1d_connect_south(mesh[i], mesh[i - 1]); if (i + 1 < x + 1) - mesh_node1d_connect_left(mesh[i], mesh[i + 1]); + mesh_node1d_connect_north(mesh[i], mesh[i + 1]); } free(mesh); diff --git a/tests/simple_mesh1d/test.c b/tests/simple_mesh1d/test.c index b3de347..293a91c 100644 --- a/tests/simple_mesh1d/test.c +++ b/tests/simple_mesh1d/test.c @@ -1,7 +1,8 @@ #include <stdint.h> __attribute__((always_inline)) -static inline uint64_t extreme_numa_addr(uint16_t cluster, uint16_t elem, uint32_t off) +static inline uint64_t mesh1d_addr(uint16_t cluster, uint16_t elem, + uint32_t off) { return ((uint64_t)cluster << 48) | ((uint64_t)elem << 32) | off; } @@ -40,18 +41,18 @@ static inline uint64_t next_idx(unsigned x, unsigned y, unsigned X, unsigned Y) unsigned yi = wrap(y, Y); unsigned xi = yi < y ? wrap(x, X) : x; - return extreme_numa_addr(xi, yi, 0); + return mesh1d_addr(xi, yi, 0); } void _start(unsigned x, unsigned y, unsigned X, unsigned Y) { - volatile char *uart = (char *)extreme_numa_addr(0, 0, 0); - volatile uint64_t *control = (uint64_t *)extreme_numa_addr(0, 1, 0); + volatile char *uart = (char *)mesh1d_addr(0, 0, 0); + volatile uint64_t *control = (uint64_t *)mesh1d_addr(0, 1, 0); if (x == 1 && y == 0) { goto do_work; } else { - while (*control != extreme_numa_addr(x, y, 0)) {} + while (*control != mesh1d_addr(x, y, 0)) {} } do_work: @@ -59,7 +60,7 @@ do_work: *control = next_idx(x, y, X, Y); if (x == X - 1 && y == Y - 1) - asm("ebreak"); + asm ("ebreak"); /* otherwise just loop */ while (1) {} diff --git a/tests/simple_mesh2d/sim.c b/tests/simple_mesh2d/sim.c index 1a9ba32..5afb1a7 100644 --- a/tests/simple_mesh2d/sim.c +++ b/tests/simple_mesh2d/sim.c @@ -18,8 +18,8 @@ static size_t idx_1d(int x, int y, uint8_t xw, uint8_t yw) } static struct component *mesh_at(struct component **mesh, - int x, int y, - uint8_t xw, uint8_t yw) + int x, int y, + uint8_t xw, uint8_t yw) { if (x < 0) return NULL; @@ -37,13 +37,17 @@ static struct component *mesh_at(struct component **mesh, } static void connect_mesh(struct component **mesh, struct component *c, - uint16_t x, uint16_t y, - uint16_t xw, uint16_t yw) + uint16_t x, uint16_t y, + uint16_t xw, uint16_t yw) { - mesh_node2d_connect_north(mesh_at(mesh, x, y, xw, yw), mesh_at(mesh, x , y+1, xw, yw)); - mesh_node2d_connect_south(mesh_at(mesh, x, y, xw, yw), mesh_at(mesh, x , y-1, xw, yw)); - mesh_node2d_connect_east(mesh_at(mesh, x, y, xw, yw), mesh_at(mesh, x+1, y , xw, yw)); - mesh_node2d_connect_west(mesh_at(mesh, x, y, xw, yw), mesh_at(mesh, x-1, y , xw, yw)); + mesh_node2d_connect_north(mesh_at(mesh, x, y, xw, yw), + mesh_at(mesh, x, y+1, xw, yw)); + mesh_node2d_connect_south(mesh_at(mesh, x, y, xw, yw), + mesh_at(mesh, x, y-1, xw, yw)); + mesh_node2d_connect_east(mesh_at(mesh, x, y, xw, yw), + mesh_at(mesh, x+1, y, xw, yw)); + mesh_node2d_connect_west(mesh_at(mesh, x, y, xw, yw), + mesh_at(mesh, x-1, y, xw, yw)); mesh_node2d_connect(mesh_at(mesh, x, y, xw, yw), c, 0); } @@ -56,34 +60,36 @@ static stat build_mesh(struct clock_domain *clk, uint16_t x, uint16_t y) assert(pes); for (size_t i = 0; i < x; ++i) - for (size_t j = 0; j < y; ++j) { - struct component *node = create_mesh_node2d(i, j, 1); - clock_domain_add(clk, node); - mesh[idx_1d(i, j, x, y)] = node; + for (size_t j = 0; j < y; ++j) { + struct component *node = create_mesh_node2d(i, j, 1); + clock_domain_add(clk, node); + mesh[idx_1d(i, j, x, y)] = node; - if (i == 0 && j == 0) - continue; + if (i == 0 && j == 0) + continue; - if (i == 0 && j == 1) - continue; + if (i == 0 && j == 1) + continue; - struct component *imem = create_simple_mem(4096); - init_simple_mem(imem, 0, - build_tests_simple_mesh2d_test_bin_len, - build_tests_simple_mesh2d_test_bin); + struct component *imem = create_simple_mem(4096); + init_simple_mem(imem, 0, + build_tests_simple_mesh2d_test_bin_len, + build_tests_simple_mesh2d_test_bin); - uint64_t rcv = mesh2d_addr(i, j, 0, 0); - struct component *rv64 = create_simple_riscv64(rcv, 0, imem, node); - simple_riscv64_set_reg(rv64, 10, i); /* a0 */ - simple_riscv64_set_reg(rv64, 11, j); /* a1 */ - simple_riscv64_set_reg(rv64, 12, x); /* a3 */ - simple_riscv64_set_reg(rv64, 13, y); /* a4 */ + uint64_t rcv = mesh2d_addr(i, j, 0, 0); + struct component *rv64 = create_simple_riscv64(rcv, 0, + imem, + node); + simple_riscv64_set_reg(rv64, 10, i); /* a0 */ + simple_riscv64_set_reg(rv64, 11, j); /* a1 */ + simple_riscv64_set_reg(rv64, 12, x); /* a3 */ + simple_riscv64_set_reg(rv64, 13, y); /* a4 */ - clock_domain_add(clk, rv64); - clock_domain_add(clk, imem); + clock_domain_add(clk, rv64); + clock_domain_add(clk, imem); - pes[idx_1d(i, j, x, y)] = rv64; - } + pes[idx_1d(i, j, x, y)] = rv64; + } struct component *uart = create_simple_uart(); clock_domain_add(clk, uart); @@ -94,15 +100,15 @@ static stat build_mesh(struct clock_domain *clk, uint16_t x, uint16_t y) connect_mesh(mesh, dmem, 0, 1, x, y); for (int i = 0; i < x; ++i) - for (int j = 0; j < y; ++j) { - if (i == 0 && j == 0) - continue; + for (int j = 0; j < y; ++j) { + if (i == 0 && j == 0) + continue; - if (i == 0 && j == 1) - continue; + if (i == 0 && j == 1) + continue; - connect_mesh(mesh, pes[idx_1d(i, j, x, y)], i, j, x, y); - } + connect_mesh(mesh, pes[idx_1d(i, j, x, y)], i, j, x, y); + } free(mesh); free(pes); diff --git a/tests/simple_mesh2d/test.c b/tests/simple_mesh2d/test.c index d607a59..431245c 100644 --- a/tests/simple_mesh2d/test.c +++ b/tests/simple_mesh2d/test.c @@ -48,7 +48,7 @@ do_work: *control = next_idx(x, y, X, Y); if (x == X - 1 && y == Y - 1) - asm("ebreak"); + asm ("ebreak"); /* otherwise just loop */ while (1) {} diff --git a/tests/simple_mesh3d/sim.c b/tests/simple_mesh3d/sim.c index 9557d83..f5d6244 100644 --- a/tests/simple_mesh3d/sim.c +++ b/tests/simple_mesh3d/sim.c @@ -19,8 +19,8 @@ static size_t idx_1d(int x, int y, int z, uint8_t xw, uint8_t yw, uint8_t zw) } static struct component *mesh_at(struct component **mesh, - int x, int y, int z, - uint8_t xw, uint8_t yw, uint8_t zw) + int x, int y, int z, + uint8_t xw, uint8_t yw, uint8_t zw) { if (x < 0) return NULL; @@ -44,20 +44,21 @@ static struct component *mesh_at(struct component **mesh, } static void connect_mesh3d(struct component **mesh, struct component *c, - uint8_t x, uint8_t y, uint8_t z, - uint8_t xw, uint8_t yw, uint8_t zw) + uint8_t x, uint8_t y, uint8_t z, + uint8_t xw, uint8_t yw, uint8_t zw) { - mesh_node3d_connect(mesh_at(mesh, x, y, z, xw, yw, zw), - mesh_at(mesh, x , y+1, z , xw, yw, zw), - mesh_at(mesh, x , y-1, z , xw, yw, zw), - mesh_at(mesh, x+1, y , z , xw, yw, zw), - mesh_at(mesh, x-1, y , z , xw, yw, zw), - mesh_at(mesh, x , y , z+1, xw, yw, zw), - mesh_at(mesh, x , y , z-1, xw, yw, zw), - c); + struct component *n = mesh_at(mesh, x, y, z, xw, yw, zw); + mesh_node3d_connect(n, c, 0); + mesh_node3d_connect_north(n, mesh_at(mesh, x, y+1, z, xw, yw, zw)); + mesh_node3d_connect_south(n, mesh_at(mesh, x, y-1, z, xw, yw, zw)); + mesh_node3d_connect_east(n, mesh_at(mesh, x+1, y, z, xw, yw, zw)); + mesh_node3d_connect_west(n, mesh_at(mesh, x-1, y, z, xw, yw, zw)); + mesh_node3d_connect_down(n, mesh_at(mesh, x, y, z-1, xw, yw, zw)); + mesh_node3d_connect_up(n, mesh_at(mesh, x, y, z+1, xw, yw, zw)); } -static stat build_mesh3d(struct clock_domain *clk, uint8_t x, uint8_t y, uint8_t z) +static stat build_mesh3d(struct clock_domain *clk, uint8_t x, uint8_t y, + uint8_t z) { struct component **mesh = calloc(x * y * z, sizeof(struct component *)); assert(mesh); @@ -68,7 +69,7 @@ static stat build_mesh3d(struct clock_domain *clk, uint8_t x, uint8_t y, uint8_t for (size_t i = 0; i < x; ++i) for (size_t j = 0; j < y; ++j) for (size_t k = 0; k < z; ++k) { - struct component *node = create_mesh_node3d(i, j, k); + struct component *node = create_mesh_node3d(i, j, k, 1); clock_domain_add(clk, node); mesh[idx_1d(i, j, k, x, y, z)] = node; @@ -83,7 +84,7 @@ static stat build_mesh3d(struct clock_domain *clk, uint8_t x, uint8_t y, uint8_t build_tests_simple_mesh3d_test_bin_len, build_tests_simple_mesh3d_test_bin); - uint64_t rcv = mesh3d_addr(i, j, k, 0); + uint64_t rcv = mesh3d_addr(i, j, k, 0, 0); struct component *rv64 = create_simple_riscv64(rcv, 0, imem, node); simple_riscv64_set_reg(rv64, 10, i); /* a0 */ simple_riscv64_set_reg(rv64, 11, j); /* a1 */ @@ -115,9 +116,7 @@ static stat build_mesh3d(struct clock_domain *clk, uint8_t x, uint8_t y, uint8_t if (i == 0 && j == 0 && k == 1) continue; - connect_mesh3d(mesh, - pes[idx_1d(i, j, k, x, y, z)], - i, j, k, x, y, z); + connect_mesh3d(mesh, pes[idx_1d(i, j, k, x, y, z)], i, j, k, x, y, z); } free(mesh); diff --git a/tests/simple_mesh3d/test.c b/tests/simple_mesh3d/test.c index 2953d41..e00e717 100644 --- a/tests/simple_mesh3d/test.c +++ b/tests/simple_mesh3d/test.c @@ -6,7 +6,8 @@ static inline void print_int8(volatile char *uart, unsigned x) } __attribute__((always_inline)) -static inline void print_addr(volatile char *uart, unsigned x, unsigned y, unsigned z) +static inline void print_addr(volatile char *uart, unsigned x, unsigned y, + unsigned z) { *uart = '('; print_int8(uart, x); @@ -27,7 +28,8 @@ static inline unsigned wrap(unsigned x, unsigned X) } __attribute__((always_inline)) -static inline unsigned next_idx(unsigned x, unsigned y, unsigned z, unsigned X, unsigned Y, unsigned Z) +static inline unsigned next_idx(unsigned x, unsigned y, unsigned z, unsigned X, + unsigned Y, unsigned Z) { unsigned zi = wrap(z, Z); unsigned yi = zi < z ? wrap(y, Y) : y; @@ -36,11 +38,11 @@ static inline unsigned next_idx(unsigned x, unsigned y, unsigned z, unsigned X, return (xi << 16) | (yi << 8) | zi; } -void _start(unsigned x, unsigned y, unsigned z, unsigned X, unsigned Y, unsigned Z) +void _start(unsigned x, unsigned y, unsigned z, unsigned X, unsigned Y, + unsigned Z) { volatile char *uart = (char *)4096; - /* x = 1ULL << 32, y = 1ULL << 40, z = 1ULL << 48 I guess */ - volatile unsigned *control = (unsigned *)(1ULL << 48); + volatile unsigned *control = (unsigned *)(1ULL << 56); if (x == 0 && y == 0 && z == 2) { @@ -54,7 +56,7 @@ do_work: *control = next_idx(x, y, z, X, Y, Z); if (x == X - 1 && y == Y - 1 && z == Z - 1) - asm("ebreak"); + asm ("ebreak"); /* otherwise just loop */ while (1) {} |
