Commit c1c23619 authored by Florence Monna's avatar Florence Monna
Browse files

Changed orders to C and Fortran in tilings.

parent f9b4185c
Pipeline #9654 passed with stages
in 3 minutes and 57 seconds
......@@ -18,7 +18,7 @@ void print_matrix(double *mat, size_t rows, size_t cols)
{
for (size_t i = 0; i < rows; i++) {
for (size_t j = 0; j < cols; j++)
fprintf(stderr, "%f ", mat[i * rows + j]);
fprintf(stderr, "%f ", mat[i * cols + j]);
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
......@@ -95,60 +95,59 @@ int main(int argc, char **argv)
fprintf(stderr, "Creating layouts...\n");
// Layout ordered columns first
struct aml_layout *layout_c, *layout_r;
size_t dims_col[3] = { x, y };
struct aml_layout *layout_c, *layout_f;
size_t dims[3] = { x, y };
assert(!aml_layout_dense_create(&layout_c, mat,
AML_LAYOUT_ORDER_COLUMN_MAJOR,
sizeof(double), 2, dims_col, NULL,
AML_LAYOUT_ORDER_C,
sizeof(double), 2, dims, NULL,
NULL));
// Layout ordered rows first, on the same area
size_t dims_row[3] = { y, x };
assert(!aml_layout_dense_create(&layout_r, mat,
AML_LAYOUT_ORDER_ROW_MAJOR,
sizeof(double), 2, dims_row, NULL,
assert(!aml_layout_dense_create(&layout_f, mat,
AML_LAYOUT_ORDER_FORTRAN,
sizeof(double), 2, dims, NULL,
NULL));
assert(layout_c != NULL && layout_r != NULL);
assert(layout_c != NULL && layout_f != NULL);
/* Tilings, both orders */
fprintf(stderr, "Creating tilings...\n");
struct aml_tiling *tiling_c, *tiling_r;
struct aml_tiling *tiling_c, *tiling_f;
size_t tile_x = 2, tile_y = 3;
assert(!aml_tiling_resize_create(&tiling_c,
AML_TILING_ORDER_COLUMN_MAJOR,
AML_TILING_ORDER_C,
layout_c, 2,
(size_t[]){tile_x, tile_y}));
assert(!aml_tiling_resize_create(&tiling_r,
AML_TILING_ORDER_ROW_MAJOR,
layout_r, 2,
(size_t[]){tile_y, tile_x}));
assert(!aml_tiling_resize_create(&tiling_f,
AML_TILING_ORDER_FORTRAN,
layout_f, 2,
(size_t[]){tile_x, tile_y}));
assert(tiling_c != NULL && tiling_r != NULL);
assert(tiling_c != NULL && tiling_f != NULL);
/* Check the difference with aml_tiling_order */
fprintf(stderr, "The first tiling has order %d: column major, ",
fprintf(stderr, "The first tiling has order %d: c, ",
aml_tiling_order(tiling_c));
fprintf(stderr, "the second tiling has order %d: row major.\n",
aml_tiling_order(tiling_r));
fprintf(stderr, "the second tiling has order %d: fortran.\n",
aml_tiling_order(tiling_f));
/* Fill them in order */
fprintf(stderr, "Going through the tilings...\n");
fill_tiling(tiling_c);
print_matrix(mat, x, y);
fprintf(stderr, "\n");
fill_tiling(tiling_r);
fill_tiling(tiling_f);
print_matrix(mat, x, y);
/* Destroy everything */
aml_tiling_resize_destroy(&tiling_c);
aml_tiling_resize_destroy(&tiling_r);
aml_tiling_resize_destroy(&tiling_f);
aml_layout_dense_destroy(&layout_c);
aml_layout_dense_destroy(&layout_r);
aml_layout_dense_destroy(&layout_f);
aml_area_munmap(area, mat, sizeof(double) * x * y);
aml_finalize();
......
......@@ -139,15 +139,15 @@ int main(int argc, char **argv)
size_t dims_c[2] = { m, n };
assert(!aml_layout_dense_create(&layout_a, a,
AML_LAYOUT_ORDER_COLUMN_MAJOR,
AML_LAYOUT_ORDER_C,
sizeof(double), 2, dims_a, NULL,
NULL));
assert(!aml_layout_dense_create(&layout_b, b,
AML_LAYOUT_ORDER_COLUMN_MAJOR,
AML_LAYOUT_ORDER_C,
sizeof(double), 2, dims_b, NULL,
NULL));
assert(!aml_layout_dense_create(&layout_c, c,
AML_LAYOUT_ORDER_COLUMN_MAJOR,
AML_LAYOUT_ORDER_C,
sizeof(double), 2, dims_c, NULL,
NULL));
......@@ -160,13 +160,13 @@ int main(int argc, char **argv)
size_t tile_c_dims[2] = { 2, 4 };
assert(!aml_tiling_resize_create(&tiling_a,
AML_TILING_ORDER_COLUMN_MAJOR,
AML_TILING_ORDER_C,
layout_a, 2, tile_a_dims));
assert(!aml_tiling_resize_create(&tiling_b,
AML_TILING_ORDER_COLUMN_MAJOR,
AML_TILING_ORDER_C,
layout_b, 2, tile_b_dims));
assert(!aml_tiling_resize_create(&tiling_c,
AML_TILING_ORDER_COLUMN_MAJOR,
AML_TILING_ORDER_C,
layout_c, 2, tile_c_dims));
// Do the matrix multiplication
......
......@@ -11,9 +11,9 @@ sizes.
As such, the main function of a tiling is to provide an index into
subcomponents of a layout.
As for the layouts, both the Fortran and C storage orders are available for the
tilings, with similar names: `AML_TILING_ORDER_COLUMN_MAJOR` and
`AML_TILING_ORDER_ROW_MAJOR`.
As for the layouts, both the C and Fortran storage orders are available for the
tilings, with similar names: `AML_TILING_ORDER_C` and
`AML_TILING_ORDER_FORTRAN`.
Creating an AML tiling
~~~~~~~~~~~~~~~~~~~~~~
......@@ -42,24 +42,24 @@ Let's do both orders:
.. code-block:: c
struct aml_layout *layout_c, *layout_r;
struct aml_layout *layout_c, *layout_f;
size_t dims_col[2] = { x, y };
aml_layout_dense_create(&layout_c, mat, AML_LAYOUT_ORDER_COLUMN_MAJOR, sizeof(double), 2, dims, NULL, NULL));
aml_layout_dense_create(&layout_c, mat, AML_LAYOUT_ORDER_C, sizeof(double), 2, dims, NULL, NULL));
aml_layout_dense_create(&layout_r, mat, AML_LAYOUT_ORDER_ROW_MAJOR, sizeof(double), 2, dims, NULL, NULL));
aml_layout_dense_create(&layout_f, mat, AML_LAYOUT_ORDER_FORTRAN, sizeof(double), 2, dims, NULL, NULL));
After that, we can finally create a tiling associated to each layout, one in
`AML_TILING_ORDER_COLUMN_MAJOR`, the other in `AML_TILING_ORDER_ROW_MAJOR`:
`AML_TILING_ORDER_C`, the other in `AML_TILING_ORDER_FORTRAN`:
.. code-block:: c
struct aml_tiling *tiling_c, *tiling_r;
struct aml_tiling *tiling_c, *tiling_f;
size_t tile_x = x/3, tile_y = y/3;
aml_tiling_resize_create(&tiling_c, AML_TILING_ORDER_COLUMN_MAJOR, layout_c, 2, (size_t[]){tile_x, tile_y}));
aml_tiling_resize_create(&tiling_c, AML_TILING_ORDER_C, layout_c, 2, (size_t[]){tile_x, tile_y}));
aml_tiling_resize_create(&tiling_r, AML_TILING_ORDER_ROW_MAJOR, layout_r, 2, (size_t[]){tile_x, tile_y}));
aml_tiling_resize_create(&tiling_f, AML_TILING_ORDER_FORTRAN, layout_f, 2, (size_t[]){tile_x, tile_y}));
We have just created two tilings on our two layouts, each with two dimensions,
`{tile_x, tile_y}` for both tilings.
......@@ -73,11 +73,11 @@ Tiling API:
.. code-block:: c
aml_tiling_order(tiling_c));
aml_tiling_order(tiling_r));
aml_tiling_order(tiling_f));
The order of the first tiling is `AML_TILING_ORDER_COLUMN_MAJOR`, which in AML
The order of the first tiling is `AML_TILING_ORDER_C`, which in AML
is represented by the value 0, and the order of the second tiling is
`AML_TILING_ORDER_ROW_MAJOR`, and the above function would return 1.
`AML_TILING_ORDER_FORTRAN`, and the above function would return 1.
Destroying an AML tiling
~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -88,7 +88,7 @@ destroy your tiling when you're done using it.
.. code-block:: c
aml_tiling_resize_destroy(&tiling_c);
aml_tiling_resize_destroy(&tiling_r);
aml_tiling_resize_destroy(&tiling_f);
Generic operations on an AML tiling
......
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