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 = \ ...@@ -20,6 +20,7 @@ AREA_TESTS = \
LAYOUT_TESTS = layout/test_layout LAYOUT_TESTS = layout/test_layout
TILING_TESTS = tiling/test_tiling
DMA_LINUX_TESTS = dma/test_dma_linux_seq \ DMA_LINUX_TESTS = dma/test_dma_linux_seq \
dma/test_dma_linux_par dma/test_dma_linux_par
...@@ -30,6 +31,7 @@ endif ...@@ -30,6 +31,7 @@ endif
# unit tests # unit tests
UNIT_TESTS = $(UTILS_TESTS) \ UNIT_TESTS = $(UTILS_TESTS) \
$(TILING_TESTS) \
$(LAYOUT_TESTS) \ $(LAYOUT_TESTS) \
$(BINDING_TESTS) \ $(BINDING_TESTS) \
$(AREA_TESTS) \ $(AREA_TESTS) \
......
...@@ -38,7 +38,7 @@ void test_slice_contiguous(void) ...@@ -38,7 +38,7 @@ void test_slice_contiguous(void)
NULL, NULL,
dims_col) == AML_SUCCESS); 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)); assert(AML_LAYOUT_ORDER_COLUMN_MAJOR == aml_layout_order(b));
...@@ -68,7 +68,7 @@ void test_slice_contiguous(void) ...@@ -68,7 +68,7 @@ void test_slice_contiguous(void)
NULL, NULL,
dims_row) == AML_SUCCESS); 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)); assert(AML_LAYOUT_ORDER_ROW_MAJOR == aml_layout_order(b));
for(size_t i = 0; i < new_dims_row[0]; i++) for(size_t i = 0; i < new_dims_row[0]; i++)
...@@ -128,7 +128,7 @@ void test_slice_strided(void) ...@@ -128,7 +128,7 @@ void test_slice_strided(void)
stride, stride,
pitch_col) == AML_SUCCESS); 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 i = 0; i < 3; i++)
for(size_t j = 0; j < 3; j++) for(size_t j = 0; j < 3; j++)
...@@ -153,7 +153,7 @@ void test_slice_strided(void) ...@@ -153,7 +153,7 @@ void test_slice_strided(void)
stride, stride,
pitch_row) == AML_SUCCESS); 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 i = 0; i < 3; i++)
for(size_t j = 0; j < 3; j++) for(size_t j = 0; j < 3; j++)
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
*******************************************************************************/ *******************************************************************************/
#include "aml.h" #include "aml.h"
#include "aml/layout/dense.h"
#include "aml/layout/native.h"
#include "aml/tiling/resize.h" #include "aml/tiling/resize.h"
#include <assert.h> #include <assert.h>
...@@ -25,7 +27,6 @@ void test_tiling_even_mixed(void) ...@@ -25,7 +27,6 @@ void test_tiling_even_mixed(void)
size_t dims_tile_row[3] = {3, 10, 4}; size_t dims_tile_row[3] = {3, 10, 4};
size_t expected_dims_col[3] = {2, 1, 3}; size_t expected_dims_col[3] = {2, 1, 3};
size_t expected_dims_row[3] = {3, 1, 2};
int l = 0; int l = 0;
for(size_t i = 0; i < 9; i++) for(size_t i = 0; i < 9; i++)
...@@ -36,18 +37,20 @@ void test_tiling_even_mixed(void) ...@@ -36,18 +37,20 @@ void test_tiling_even_mixed(void)
} }
struct aml_layout *a, *ares; struct aml_layout *a, *ares;
aml_layout_native_create(&a, AML_TYPE_LAYOUT_COLUMN_ORDER, aml_layout_dense_create(&a, (void *)memory,
(void *)memory, sizeof(int), 3, dims_col, AML_LAYOUT_ORDER_COLUMN_MAJOR,
sizeof(int), 3, dims_col,
stride, dims_col); stride, dims_col);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_ROW_ORDER, aml_layout_dense_create(&ares, (void *)memoryres,
(void *)memoryres, sizeof(int), 3, dims_row, AML_LAYOUT_ORDER_ROW_MAJOR,
sizeof(int), 3, dims_row,
stride, dims_row); stride, dims_row);
struct aml_tiling *t, *tres; 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); 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); ares, 3, dims_tile_row);
...@@ -55,9 +58,9 @@ void test_tiling_even_mixed(void) ...@@ -55,9 +58,9 @@ void test_tiling_even_mixed(void)
for(size_t j = 0; j < expected_dims_col[1]; j++) for(size_t j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) { for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres; struct aml_layout *b, *bres;
b = aml_tiling_index(t, k, j, i); b = aml_tiling_index(t, (size_t[]){k, j, i});
bres = aml_tiling_index(tres, i, j, k); bres = aml_tiling_index(tres, (size_t[]){i, j, k});
aml_copy_layout_generic(bres, b); aml_copy_layout_generic(bres, b, NULL);
free(b); free(b);
free(bres); free(bres);
} }
...@@ -68,17 +71,17 @@ void test_tiling_even_mixed(void) ...@@ -68,17 +71,17 @@ void test_tiling_even_mixed(void)
free(t); free(t);
free(tres); free(tres);
aml_layout_native_create(&a, AML_TYPE_LAYOUT_COLUMN_ORDER, aml_layout_dense_create(&a, memory, AML_LAYOUT_ORDER_COLUMN_MAJOR,
(void *)memory, sizeof(int), 3, dims_col, sizeof(int), 3, dims_col,
stride, dims_col); stride, dims_col);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_ROW_ORDER, aml_layout_dense_create(&ares, memoryres, AML_LAYOUT_ORDER_ROW_MAJOR,
(void *)memoryres, sizeof(int), 3, dims_row, sizeof(int), 3, dims_row,
stride, 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); 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); ares, 3, dims_tile_col);
for(size_t i = 0; i < 9; i++) for(size_t i = 0; i < 9; i++)
...@@ -90,9 +93,9 @@ void test_tiling_even_mixed(void) ...@@ -90,9 +93,9 @@ void test_tiling_even_mixed(void)
for(size_t j = 0; j < expected_dims_col[1]; j++) for(size_t j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) { for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres; struct aml_layout *b, *bres;
b = aml_tiling_index(t, i, j, k); b = aml_tiling_index(t, (size_t[]){i, j, k});
bres = aml_tiling_index(tres, k, j, i); bres = aml_tiling_index(tres, (size_t[]){k, j, i});
aml_copy_layout_generic(bres, b); aml_copy_layout_generic(bres, b, NULL);
free(b); free(b);
free(bres); free(bres);
} }
...@@ -129,26 +132,26 @@ void test_tiling_even(void) ...@@ -129,26 +132,26 @@ void test_tiling_even(void)
} }
struct aml_layout *a, *ares; struct aml_layout *a, *ares;
aml_layout_native_create(&a, AML_TYPE_LAYOUT_COLUMN_ORDER, aml_layout_dense_create(&a, memory, AML_LAYOUT_ORDER_COLUMN_MAJOR,
(void *)memory, sizeof(int), 3, dims_col, sizeof(int), 3, dims_col,
stride, dims_col); stride, dims_col);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_COLUMN_ORDER, aml_layout_dense_create(&ares, memoryres, AML_LAYOUT_ORDER_COLUMN_MAJOR,
(void *)memoryres, sizeof(int), 3, dims_col, sizeof(int), 3, dims_col,
stride, dims_col); stride, dims_col);
struct aml_tiling *t, *tres; 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); 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); 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); assert(aml_tiling_ndims(t) == 3);
size_t dims[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); assert(memcmp(dims, dims_tile_col, 3*sizeof(size_t)) == 0);
aml_tiling_dims(t, dims); aml_tiling_dims(t, dims);
assert(memcmp(dims, expected_dims_col, 3*sizeof(size_t)) == 0); assert(memcmp(dims, expected_dims_col, 3*sizeof(size_t)) == 0);
...@@ -157,9 +160,9 @@ void test_tiling_even(void) ...@@ -157,9 +160,9 @@ void test_tiling_even(void)
for(size_t j = 0; j < expected_dims_col[1]; j++) for(size_t j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) { for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres; struct aml_layout *b, *bres;
b = aml_tiling_index(t, k, j, i); b = aml_tiling_index(t, (size_t[]){k, j, i});
bres = aml_tiling_index(tres, k, j, i); bres = aml_tiling_index(tres, (size_t[]){k, j, i});
aml_copy_layout_generic(bres, b); aml_copy_layout_generic(bres, b, NULL);
free(b); free(b);
free(bres); free(bres);
} }
...@@ -170,23 +173,23 @@ void test_tiling_even(void) ...@@ -170,23 +173,23 @@ void test_tiling_even(void)
free(t); free(t);
free(tres); free(tres);
aml_layout_native_create(&a, AML_TYPE_LAYOUT_ROW_ORDER, aml_layout_dense_create(&a, memory, AML_LAYOUT_ORDER_ROW_MAJOR,
(void *)memory, sizeof(int), 3, dims_row, sizeof(int), 3, dims_row,
stride, dims_row); stride, dims_row);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_ROW_ORDER, aml_layout_dense_create(&ares, memoryres, AML_LAYOUT_ORDER_ROW_MAJOR,
(void *)memoryres, sizeof(int), 3, dims_row, sizeof(int), 3, dims_row,
stride, 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); 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); 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); 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); assert(memcmp(dims, dims_tile_row, 3*sizeof(size_t)) == 0);
aml_tiling_dims(t, dims); aml_tiling_dims(t, dims);
assert(memcmp(dims, expected_dims_row, 3*sizeof(size_t)) == 0); assert(memcmp(dims, expected_dims_row, 3*sizeof(size_t)) == 0);
...@@ -200,9 +203,10 @@ void test_tiling_even(void) ...@@ -200,9 +203,10 @@ void test_tiling_even(void)
for(size_t j = 0; j < expected_dims_col[1]; j++) for(size_t j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) { for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres; struct aml_layout *b, *bres;
b = aml_tiling_index(t, i, j, k); b = aml_tiling_index(t, (size_t[]){i, j, k});
bres = aml_tiling_index(tres, i, j, k); bres = aml_tiling_index(tres, (size_t[]){i, j, k});
aml_copy_layout_generic(bres, b); assert(b != NULL && bres != NULL);
aml_copy_layout_generic(bres, b, NULL);
free(b); free(b);
free(bres); free(bres);
} }
...@@ -240,26 +244,26 @@ void test_tiling_uneven(void) ...@@ -240,26 +244,26 @@ void test_tiling_uneven(void)
} }
struct aml_layout *a, *ares; struct aml_layout *a, *ares;
aml_layout_native_create(&a, AML_TYPE_LAYOUT_COLUMN_ORDER, aml_layout_dense_create(&a, memory, AML_LAYOUT_ORDER_COLUMN_MAJOR,
(void *)memory, sizeof(int), 3, dims_col, sizeof(int), 3, dims_col,
stride, dims_col); stride, dims_col);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_COLUMN_ORDER, aml_layout_dense_create(&ares, memoryres, AML_LAYOUT_ORDER_COLUMN_MAJOR,
(void *)memoryres, sizeof(int), 3, dims_col, sizeof(int), 3, dims_col,
stride, dims_col); stride, dims_col);
struct aml_tiling *t, *tres; 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); 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); 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); assert(aml_tiling_ndims(t) == 3);
size_t dims[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); assert(memcmp(dims, dims_tile_col, 3*sizeof(size_t)) == 0);
aml_tiling_dims(t, dims); aml_tiling_dims(t, dims);
assert(memcmp(dims, expected_dims_col, 3*sizeof(size_t)) == 0); assert(memcmp(dims, expected_dims_col, 3*sizeof(size_t)) == 0);
...@@ -268,9 +272,9 @@ void test_tiling_uneven(void) ...@@ -268,9 +272,9 @@ void test_tiling_uneven(void)
for(size_t j = 0; j < expected_dims_col[1]; j++) for(size_t j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) { for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres; struct aml_layout *b, *bres;
b = aml_tiling_index(t, k, j, i); b = aml_tiling_index(t, (size_t[]){k, j, i});
bres = aml_tiling_index(tres, k, j, i); bres = aml_tiling_index(tres, (size_t[]){k, j, i});
aml_copy_layout_generic(bres, b); aml_copy_layout_generic(bres, b, NULL);
free(b); free(b);
free(bres); free(bres);
} }
...@@ -281,38 +285,40 @@ void test_tiling_uneven(void) ...@@ -281,38 +285,40 @@ void test_tiling_uneven(void)
free(t); free(t);
free(tres); free(tres);
aml_layout_native_create(&a, AML_TYPE_LAYOUT_ROW_ORDER, aml_layout_dense_create(&a, memory, AML_LAYOUT_ORDER_ROW_MAJOR,
(void *)memory, sizeof(int), 3, dims_row, sizeof(int), 3, dims_row,
stride, dims_row); stride, dims_row);
aml_layout_native_create(&ares, AML_TYPE_LAYOUT_ROW_ORDER, aml_layout_dense_create(&ares, memoryres, AML_LAYOUT_ORDER_ROW_MAJOR,
(void *)memoryres, sizeof(int), 3, dims_row, sizeof(int), 3, dims_row,
stride, 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); 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); 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); 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); assert(memcmp(dims, dims_tile_row, 3*sizeof(size_t)) == 0);
aml_tiling_dims(t, dims); aml_tiling_dims(t, dims);
assert(memcmp(dims, expected_dims_row, 3*sizeof(size_t)) == 0); assert(memcmp(dims, expected_dims_row, 3*sizeof(size_t)) == 0);
for(size_t i = 0; i < 8; i++) for(size_t i = 0; i < 8; i++)
for(size_t j = 0; j < 10; j++) 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; memoryres[i][j][k] = 0.0;
}
for(size_t i = 0; i < expected_dims_col[2]; i++) 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 j = 0; j < expected_dims_col[1]; j++)
for(size_t k = 0; k < expected_dims_col[0]; k++) { for(size_t k = 0; k < expected_dims_col[0]; k++) {
struct aml_layout *b, *bres; struct aml_layout *b, *bres;
b = aml_tiling_index(t, i, j, k); b = aml_tiling_index(t, (size_t[]){i, j, k});
bres = aml_tiling_index(tres, i, j, k); bres = aml_tiling_index(tres, (size_t[]){i, j, k});
aml_copy_layout_generic(bres, b); aml_copy_layout_generic(bres, b, NULL);
free(b); free(b);
free(bres); free(bres);
} }
...@@ -322,7 +328,6 @@ void test_tiling_uneven(void) ...@@ -322,7 +328,6 @@ void test_tiling_uneven(void)
free(ares); free(ares);
free(t); free(t);
free(tres); free(tres);
} }
int main(int argc, char *argv[]) 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