Commit 10e8396f authored by Swann Perarnau's avatar Swann Perarnau
Browse files

[fix] make tilings and layout tests work

We're getting somewhere.
parent 8d3472bf
Pipeline #8423 failed with stages
in 10 seconds
......@@ -20,6 +20,7 @@ AREA_TESTS = \
LAYOUT_TESTS = layout/test_layout
TILING_TESTS = tiling/test_tiling
DMA_LINUX_TESTS = dma/test_dma_linux_seq \
dma/test_dma_linux_par
......@@ -30,6 +31,7 @@ endif
# unit tests
UNIT_TESTS = $(UTILS_TESTS) \
$(TILING_TESTS) \
$(LAYOUT_TESTS) \
$(BINDING_TESTS) \
$(AREA_TESTS) \
......
......@@ -38,7 +38,7 @@ void test_slice_contiguous(void)
NULL,
dims_col) == AML_SUCCESS);
assert(aml_layout_slice(a, &b, new_dims_col, offsets_col, NULL) == AML_SUCCESS);
assert(aml_layout_slice(a, &b, offsets_col, new_dims_col, NULL) == AML_SUCCESS);
assert(AML_LAYOUT_ORDER_COLUMN_MAJOR == aml_layout_order(b));
......@@ -67,8 +67,8 @@ void test_slice_contiguous(void)
dims_row,
NULL,
dims_row) == AML_SUCCESS);
assert(aml_layout_slice(a, &b, new_dims_row, offsets_row, NULL) == AML_SUCCESS);
assert(aml_layout_slice(a, &b, offsets_row, new_dims_row, NULL) == AML_SUCCESS);
assert(AML_LAYOUT_ORDER_ROW_MAJOR == aml_layout_order(b));
for(size_t i = 0; i < new_dims_row[0]; i++)
......@@ -128,8 +128,8 @@ void test_slice_strided(void)
stride,
pitch_col) == AML_SUCCESS);
assert(aml_layout_slice(a, &b, new_dims_col, offsets_col, new_stride_col) == AML_SUCCESS);
assert(aml_layout_slice(a, &b, offsets_col, new_dims_col, new_stride_col) == AML_SUCCESS);
for(size_t i = 0; i < 3; i++)
for(size_t j = 0; j < 3; j++)
for(size_t k = 0; k < 2; k++){
......@@ -152,8 +152,8 @@ void test_slice_strided(void)
dims_row,
stride,
pitch_row) == AML_SUCCESS);
assert(aml_layout_slice(a, &b, new_dims_row, offsets_row, new_stride_row) == AML_SUCCESS);
assert(aml_layout_slice(a, &b, offsets_row, new_dims_row, new_stride_row) == AML_SUCCESS);
for(size_t i = 0; i < 3; i++)
for(size_t j = 0; j < 3; j++)
......
......@@ -9,6 +9,8 @@
*******************************************************************************/
#include "aml.h"
#include "aml/layout/dense.h"
#include "aml/layout/native.h"
#include "aml/tiling/resize.h"
#include <assert.h>
......@@ -25,7 +27,6 @@ void test_tiling_even_mixed(void)
size_t dims_tile_row[3] = {3, 10, 4};
size_t expected_dims_col[3] = {2, 1, 3};
size_t expected_dims_row[3] = {3, 1, 2};
int l = 0;
for(size_t i = 0; i < 9; i++)
......@@ -36,18 +37,20 @@ void test_tiling_even_mixed(void)
}
struct aml_layout *a, *ares;
aml_layout_native_create(&a, AML_TYPE_LAYOUT_COLUMN_ORDER,
(void *)memory, sizeof(int), 3, dims_col,
aml_layout_dense_create(&a, (void *)memory,
AML_LAYOUT_ORDER_COLUMN_MAJOR,
sizeof(int), 3, dims_col,
stride, dims_col);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_ROW_ORDER,
(void *)memoryres, sizeof(int), 3, dims_row,
stride, dims_row);
aml_layout_dense_create(&ares, (void *)memoryres,
AML_LAYOUT_ORDER_ROW_MAJOR,
sizeof(int), 3, dims_row,
stride, dims_row);
struct aml_tiling *t, *tres;
aml_tiling_resize_create(&t, AML_TYPE_TILING_COLUMN_ORDER,
aml_tiling_resize_create(&t, AML_TILING_ORDER_COLUMN_MAJOR,
a, 3, dims_tile_col);
aml_tiling_resize_create(&tres, AML_TYPE_TILING_ROW_ORDER,
aml_tiling_resize_create(&tres, AML_TILING_ORDER_ROW_MAJOR,
ares, 3, dims_tile_row);
......@@ -55,9 +58,9 @@ void test_tiling_even_mixed(void)
for(size_t j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres;
b = aml_tiling_index(t, k, j, i);
bres = aml_tiling_index(tres, i, j, k);
aml_copy_layout_generic(bres, b);
b = aml_tiling_index(t, (size_t[]){k, j, i});
bres = aml_tiling_index(tres, (size_t[]){i, j, k});
aml_copy_layout_generic(bres, b, NULL);
free(b);
free(bres);
}
......@@ -68,17 +71,17 @@ void test_tiling_even_mixed(void)
free(t);
free(tres);
aml_layout_native_create(&a, AML_TYPE_LAYOUT_COLUMN_ORDER,
(void *)memory, sizeof(int), 3, dims_col,
aml_layout_dense_create(&a, memory, AML_LAYOUT_ORDER_COLUMN_MAJOR,
sizeof(int), 3, dims_col,
stride, dims_col);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_ROW_ORDER,
(void *)memoryres, sizeof(int), 3, dims_row,
aml_layout_dense_create(&ares, memoryres, AML_LAYOUT_ORDER_ROW_MAJOR,
sizeof(int), 3, dims_row,
stride, dims_row);
aml_tiling_resize_create(&t, AML_TYPE_TILING_ROW_ORDER,
aml_tiling_resize_create(&t, AML_TILING_ORDER_ROW_MAJOR,
a, 3, dims_tile_row);
aml_tiling_resize_create(&tres, AML_TYPE_TILING_COLUMN_ORDER,
aml_tiling_resize_create(&tres, AML_TILING_ORDER_COLUMN_MAJOR,
ares, 3, dims_tile_col);
for(size_t i = 0; i < 9; i++)
......@@ -90,9 +93,9 @@ void test_tiling_even_mixed(void)
for(size_t j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres;
b = aml_tiling_index(t, i, j, k);
bres = aml_tiling_index(tres, k, j, i);
aml_copy_layout_generic(bres, b);
b = aml_tiling_index(t, (size_t[]){i, j, k});
bres = aml_tiling_index(tres, (size_t[]){k, j, i});
aml_copy_layout_generic(bres, b, NULL);
free(b);
free(bres);
}
......@@ -129,26 +132,26 @@ void test_tiling_even(void)
}
struct aml_layout *a, *ares;
aml_layout_native_create(&a, AML_TYPE_LAYOUT_COLUMN_ORDER,
(void *)memory, sizeof(int), 3, dims_col,
aml_layout_dense_create(&a, memory, AML_LAYOUT_ORDER_COLUMN_MAJOR,
sizeof(int), 3, dims_col,
stride, dims_col);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_COLUMN_ORDER,
(void *)memoryres, sizeof(int), 3, dims_col,
aml_layout_dense_create(&ares, memoryres, AML_LAYOUT_ORDER_COLUMN_MAJOR,
sizeof(int), 3, dims_col,
stride, dims_col);
struct aml_tiling *t, *tres;
aml_tiling_resize_create(&t, AML_TYPE_TILING_COLUMN_ORDER,
aml_tiling_resize_create(&t, AML_TILING_ORDER_COLUMN_MAJOR,
a, 3, dims_tile_col);
aml_tiling_resize_create(&tres, AML_TYPE_TILING_COLUMN_ORDER,
aml_tiling_resize_create(&tres, AML_TILING_ORDER_COLUMN_MAJOR,
ares, 3, dims_tile_col);
assert(aml_tiling_order(t) == AML_TYPE_TILING_COLUMN_ORDER);
assert(aml_tiling_order(t) == AML_TILING_ORDER_COLUMN_MAJOR);
assert(aml_tiling_ndims(t) == 3);
size_t dims[3];
aml_tiling_tile_adims(t, dims);
aml_tiling_tile_dims(t, dims);
assert(memcmp(dims, dims_tile_col, 3*sizeof(size_t)) == 0);
aml_tiling_dims(t, dims);
assert(memcmp(dims, expected_dims_col, 3*sizeof(size_t)) == 0);
......@@ -157,9 +160,9 @@ void test_tiling_even(void)
for(size_t j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres;
b = aml_tiling_index(t, k, j, i);
bres = aml_tiling_index(tres, k, j, i);
aml_copy_layout_generic(bres, b);
b = aml_tiling_index(t, (size_t[]){k, j, i});
bres = aml_tiling_index(tres, (size_t[]){k, j, i});
aml_copy_layout_generic(bres, b, NULL);
free(b);
free(bres);
}
......@@ -170,23 +173,23 @@ void test_tiling_even(void)
free(t);
free(tres);
aml_layout_native_create(&a, AML_TYPE_LAYOUT_ROW_ORDER,
(void *)memory, sizeof(int), 3, dims_row,
aml_layout_dense_create(&a, memory, AML_LAYOUT_ORDER_ROW_MAJOR,
sizeof(int), 3, dims_row,
stride, dims_row);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_ROW_ORDER,
(void *)memoryres, sizeof(int), 3, dims_row,
aml_layout_dense_create(&ares, memoryres, AML_LAYOUT_ORDER_ROW_MAJOR,
sizeof(int), 3, dims_row,
stride, dims_row);
aml_tiling_resize_create(&t, AML_TYPE_TILING_ROW_ORDER,
aml_tiling_resize_create(&t, AML_TILING_ORDER_ROW_MAJOR,
a, 3, dims_tile_row);
aml_tiling_resize_create(&tres, AML_TYPE_TILING_ROW_ORDER,
aml_tiling_resize_create(&tres, AML_TILING_ORDER_ROW_MAJOR,
ares, 3, dims_tile_row);
assert(aml_tiling_order(t) == AML_TYPE_TILING_ROW_ORDER);
assert(aml_tiling_order(t) == AML_TILING_ORDER_ROW_MAJOR);
assert(aml_tiling_ndims(t) == 3);
aml_tiling_tile_adims(t, dims);
aml_tiling_tile_dims(t, dims);
assert(memcmp(dims, dims_tile_row, 3*sizeof(size_t)) == 0);
aml_tiling_dims(t, dims);
assert(memcmp(dims, expected_dims_row, 3*sizeof(size_t)) == 0);
......@@ -200,9 +203,10 @@ void test_tiling_even(void)
for(size_t j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres;
b = aml_tiling_index(t, i, j, k);
bres = aml_tiling_index(tres, i, j, k);
aml_copy_layout_generic(bres, b);
b = aml_tiling_index(t, (size_t[]){i, j, k});
bres = aml_tiling_index(tres, (size_t[]){i, j, k});
assert(b != NULL && bres != NULL);
aml_copy_layout_generic(bres, b, NULL);
free(b);
free(bres);
}
......@@ -240,26 +244,26 @@ void test_tiling_uneven(void)
}
struct aml_layout *a, *ares;
aml_layout_native_create(&a, AML_TYPE_LAYOUT_COLUMN_ORDER,
(void *)memory, sizeof(int), 3, dims_col,
aml_layout_dense_create(&a, memory, AML_LAYOUT_ORDER_COLUMN_MAJOR,
sizeof(int), 3, dims_col,
stride, dims_col);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_COLUMN_ORDER,
(void *)memoryres, sizeof(int), 3, dims_col,
aml_layout_dense_create(&ares, memoryres, AML_LAYOUT_ORDER_COLUMN_MAJOR,
sizeof(int), 3, dims_col,
stride, dims_col);
struct aml_tiling *t, *tres;
aml_tiling_resize_create(&t, AML_TYPE_TILING_COLUMN_ORDER,
aml_tiling_resize_create(&t, AML_TILING_ORDER_COLUMN_MAJOR,
a, 3, dims_tile_col);
aml_tiling_resize_create(&tres, AML_TYPE_TILING_COLUMN_ORDER,
aml_tiling_resize_create(&tres, AML_TILING_ORDER_COLUMN_MAJOR,
ares, 3, dims_tile_col);
assert(aml_tiling_order(t) == AML_TYPE_TILING_COLUMN_ORDER);
assert(aml_tiling_order(t) == AML_TILING_ORDER_COLUMN_MAJOR);
assert(aml_tiling_ndims(t) == 3);
size_t dims[3];
aml_tiling_tile_adims(t, dims);
aml_tiling_tile_dims(t, dims);
assert(memcmp(dims, dims_tile_col, 3*sizeof(size_t)) == 0);
aml_tiling_dims(t, dims);
assert(memcmp(dims, expected_dims_col, 3*sizeof(size_t)) == 0);
......@@ -268,9 +272,9 @@ void test_tiling_uneven(void)
for(size_t j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres;
b = aml_tiling_index(t, k, j, i);
bres = aml_tiling_index(tres, k, j, i);
aml_copy_layout_generic(bres, b);
b = aml_tiling_index(t, (size_t[]){k, j, i});
bres = aml_tiling_index(tres, (size_t[]){k, j, i});
aml_copy_layout_generic(bres, b, NULL);
free(b);
free(bres);
}
......@@ -281,38 +285,40 @@ void test_tiling_uneven(void)
free(t);
free(tres);
aml_layout_native_create(&a, AML_TYPE_LAYOUT_ROW_ORDER,
(void *)memory, sizeof(int), 3, dims_row,
aml_layout_dense_create(&a, memory, AML_LAYOUT_ORDER_ROW_MAJOR,
sizeof(int), 3, dims_row,
stride, dims_row);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_ROW_ORDER,
(void *)memoryres, sizeof(int), 3, dims_row,
aml_layout_dense_create(&ares, memoryres, AML_LAYOUT_ORDER_ROW_MAJOR,
sizeof(int), 3, dims_row,
stride, dims_row);
aml_tiling_resize_create(&t, AML_TYPE_TILING_ROW_ORDER,
aml_tiling_resize_create(&t, AML_TILING_ORDER_ROW_MAJOR,
a, 3, dims_tile_row);
aml_tiling_resize_create(&tres, AML_TYPE_TILING_ROW_ORDER,
aml_tiling_resize_create(&tres, AML_TILING_ORDER_ROW_MAJOR,
ares, 3, dims_tile_row);
assert(aml_tiling_order(t) == AML_TYPE_TILING_ROW_ORDER);
assert(aml_tiling_order(t) == AML_TILING_ORDER_ROW_MAJOR);
assert(aml_tiling_ndims(t) == 3);
aml_tiling_tile_adims(t, dims);
aml_tiling_tile_dims(t, dims);
assert(memcmp(dims, dims_tile_row, 3*sizeof(size_t)) == 0);
aml_tiling_dims(t, dims);
assert(memcmp(dims, expected_dims_row, 3*sizeof(size_t)) == 0);
for(size_t i = 0; i < 8; i++)
for(size_t j = 0; j < 10; j++)
for(size_t k = 0; k < 7; k++, l++)
for(size_t k = 0; k < 7; k++, l++) {
memory[i][j][k] = l;
memoryres[i][j][k] = 0.0;
}
for(size_t i = 0; i < expected_dims_col[2]; i++)
for(size_t j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres;
b = aml_tiling_index(t, i, j, k);
bres = aml_tiling_index(tres, i, j, k);
aml_copy_layout_generic(bres, b);
b = aml_tiling_index(t, (size_t[]){i, j, k});
bres = aml_tiling_index(tres, (size_t[]){i, j, k});
aml_copy_layout_generic(bres, b, NULL);
free(b);
free(bres);
}
......@@ -322,7 +328,6 @@ void test_tiling_uneven(void)
free(ares);
free(t);
free(tres);
}
int main(int argc, char *argv[])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment