<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
Tile.hpp
Go to the documentation of this file.
1
3//
4// Copyright (c) 2021-2023, University of Colorado Denver. All rights reserved.
5//
6// This file is part of <T>LAPACK.
7// <T>LAPACK is free software: you can redistribute it and/or modify it under
8// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
9
10#ifndef TLAPACK_STARPU_TILE_HH
11#define TLAPACK_STARPU_TILE_HH
12
13#include <starpu.h>
14
16
17namespace tlapack {
18namespace starpu {
19
25 struct Tile {
27 const idx_t i, j;
28 const idx_t m, n;
29
32 false;
33
39 idx_t i,
40 idx_t j,
41 idx_t m,
42 idx_t n) noexcept
43 : root_handle(tile_handle), i(i), j(j), m(m), n(n)
44 {
45 // Collect information about the tile
46 const idx_t M = starpu_matrix_get_nx(tile_handle);
47 const idx_t N = starpu_matrix_get_ny(tile_handle);
48
49 // Partition the tile if it is not a full tile
50 if (m != M || n != N) {
51 idx_t pos[4] = {i, j, m, n};
52 struct starpu_data_filter f_tile = {
53 .filter_func = filter_tile,
54 .nchildren = 1,
55 .filter_arg_ptr = (void*)pos};
56
58 partition_planned = true;
59 }
60 else {
62 }
63
65 starpu_matrix_get_ny(handle) == n && "Invalid tile size");
66 }
67
74
98 const Tile& A,
99 const Tile& B) noexcept
100 {
101 if (A.root_handle == B.root_handle) {
102 idx_t pos[8] = {A.i, A.j, A.m, A.n, B.i, B.j, B.m, B.n};
103
105 .filter_func = filter_ntiles,
106 .nchildren = 2,
107 .filter_arg_ptr = (void*)pos};
108
110
112 starpu_matrix_get_ny(handles[0]) == A.n &&
113 "Invalid tile size");
115 starpu_matrix_get_ny(handles[1]) == B.n &&
116 "Invalid tile size");
117 }
118 else {
119 handles[0] = A.handle;
120 handles[1] = B.handle;
121 }
122 }
123
133 const Tile& A,
134 const Tile& B) noexcept
135 {
136 if (A.root_handle == B.root_handle)
137 starpu_data_partition_clean(A.root_handle, 2, handles);
138 }
139
158 const Tile& A,
159 const Tile& B) const noexcept
160 {
161 if (root_handle == A.root_handle) {
162 if (root_handle == B.root_handle) {
163 idx_t pos[12] = {i, j, m, n, A.i, A.j,
164 A.m, A.n, B.i, B.j, B.m, B.n};
165
167 .filter_func = filter_ntiles,
168 .nchildren = 3,
169 .filter_arg_ptr = (void*)pos};
170
172
175 "Invalid tile size");
177 starpu_matrix_get_ny(handles[1]) == A.n &&
178 "Invalid tile size");
180 starpu_matrix_get_ny(handles[2]) == B.n &&
181 "Invalid tile size");
182 }
183 else {
185 handles[2] = B.handle;
186 }
187 }
188 else if (root_handle == B.root_handle) {
190 handles[2] = handles[1];
191 handles[1] = A.handle;
192 }
193 else {
194 handles[0] = handle;
195 handles[1] = A.handle;
196 handles[2] = B.handle;
197 }
198 }
199
209 const Tile& A,
210 const Tile& B) const noexcept
211 {
212 if (root_handle == A.root_handle) {
213 if (root_handle == B.root_handle)
215 else
217 }
218 else if (root_handle == B.root_handle) {
220 handles[1] = handles[2];
222 handles[2] = handles[1];
223 handles[1] = aux;
224 }
225 }
226 };
227
228} // namespace starpu
229} // namespace tlapack
230
231#endif // TLAPACK_STARPU_TILE_HPP
Filters for StarPU data interfaces.
void filter_ntiles(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, STARPU_ATTRIBUTE_UNUSED unsigned nparts) noexcept
StarPU filter to define a multiple submatrices of a non-tiled matrix.
Definition filters.hpp:82
void filter_tile(void *father_interface, void *child_interface, struct starpu_data_filter *f, STARPU_ATTRIBUTE_UNUSED unsigned id, STARPU_ATTRIBUTE_UNUSED unsigned nparts) noexcept
StarPU filter to define a single submatrix of a non-tiled matrix.
Definition filters.hpp:29
typename traits::real_type_traits< Types..., int >::type real_type
The common real type of the list of types.
Definition scalar_type_traits.hpp:113
Class for representing a tile of a matrix.
Definition Tile.hpp:25
void create_compatible_inout_handles(starpu_data_handle_t handles[3], const Tile &A, const Tile &B) const noexcept
Create a compatible handles between one output tile and two input tiles.
Definition Tile.hpp:157
starpu_data_handle_t handle
Tile handle possibly partitioned.
Definition Tile.hpp:30
const starpu_data_handle_t root_handle
Matrix tile handle.
Definition Tile.hpp:26
~Tile() noexcept
Destructor.
Definition Tile.hpp:69
Tile(starpu_data_handle_t tile_handle, idx_t i, idx_t j, idx_t m, idx_t n) noexcept
Construct a new Tile object using a Matrix tile handle and the local partitioning information.
Definition Tile.hpp:38
static void clean_compatible_handles(starpu_data_handle_t handles[2], const Tile &A, const Tile &B) noexcept
Clean the partition created by create_compatible_handles()
Definition Tile.hpp:132
static void create_compatible_handles(starpu_data_handle_t handles[2], const Tile &A, const Tile &B) noexcept
Create a compatible handles between two tiles.
Definition Tile.hpp:97
const idx_t j
Tile starting indices (i,j)
Definition Tile.hpp:27
bool partition_planned
True if there is a partition associated with this tile.
Definition Tile.hpp:31
const idx_t n
Tile sizes (m,n)
Definition Tile.hpp:28
void clean_compatible_inout_handles(starpu_data_handle_t handles[3], const Tile &A, const Tile &B) const noexcept
Clean the partition created by create_compatible_inout_handles()
Definition Tile.hpp:208