<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
filters.hpp
Go to the documentation of this file.
1
4//
5// Copyright (c) 2021-2023, University of Colorado Denver. All rights reserved.
6//
7// This file is part of <T>LAPACK.
8// <T>LAPACK is free software: you can redistribute it and/or modify it under
9// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
10
11#ifndef TLAPACK_STARPU_FILTERS_HH
12#define TLAPACK_STARPU_FILTERS_HH
13
14#include <starpu.h>
15
17
18namespace tlapack {
19namespace starpu {
20
29 inline void filter_tile(void* father_interface,
30 void* child_interface,
31 struct starpu_data_filter* f,
32 STARPU_ATTRIBUTE_UNUSED unsigned id,
33 STARPU_ATTRIBUTE_UNUSED unsigned nparts) noexcept
34 {
39
40 const idx_t* aux = (const idx_t*)(f->filter_arg_ptr);
41 const idx_t row0 = aux[0];
42 const idx_t col0 = aux[1];
43 const idx_t nrows = aux[2];
44 const idx_t ncols = aux[3];
45
47 matrix_child->elemsize = matrix_father->elemsize;
48 matrix_child->nx = nrows;
49 matrix_child->ny = ncols;
50
51 /* is the information on this node valid ? */
52 if (matrix_father->dev_handle) {
53 matrix_child->dev_handle = matrix_father->dev_handle;
55
56 const idx_t offset =
57 (row0 + col0 * matrix_child->ld) * matrix_child->elemsize;
58 if (matrix_father->ptr)
59 matrix_child->ptr = matrix_father->ptr + offset;
60 matrix_child->offset = matrix_father->offset + offset;
61
62 matrix_child->allocsize =
63 matrix_child->ld * matrix_child->ny * matrix_child->elemsize;
64 }
65 else
66 matrix_child->allocsize =
67 matrix_child->nx * matrix_child->ny * matrix_child->elemsize;
68 }
69
83 void* child_interface,
84 struct starpu_data_filter* f,
85 unsigned id,
86 STARPU_ATTRIBUTE_UNUSED unsigned nparts) noexcept
87 {
89 .filter_arg_ptr = (void*)((idx_t*)f->filter_arg_ptr + 4 * id),
90 };
92 }
93
105 inline void filter_rows(
106 void* father_interface,
107 void* child_interface,
109 unsigned id,
110 unsigned nparts) noexcept
111 {
116
117 const idx_t mt = f->filter_arg;
118
119 matrix_child->id = matrix_father->id;
120 matrix_child->elemsize = matrix_father->elemsize;
121 matrix_child->nx =
122 (id == nparts - 1) ? (matrix_father->nx - (mt * id)) : mt;
123 matrix_child->ny = matrix_father->ny;
124
125 /* is the information on this node valid ? */
126 if (matrix_father->dev_handle) {
127 matrix_child->dev_handle = matrix_father->dev_handle;
128 matrix_child->ld = matrix_father->ld;
129
130 const idx_t offset = matrix_child->elemsize * (mt * id);
131 if (matrix_father->ptr)
132 matrix_child->ptr = matrix_father->ptr + offset;
133 matrix_child->offset = matrix_father->offset + offset;
134
135 matrix_child->allocsize =
136 matrix_child->ld * matrix_child->ny * matrix_child->elemsize;
137 }
138 else
139 matrix_child->allocsize =
140 matrix_child->nx * matrix_child->ny * matrix_child->elemsize;
141 }
142
155 inline void filter_cols(void* father_interface,
156 void* child_interface,
157 struct starpu_data_filter* f,
158 unsigned id,
159 unsigned nparts) noexcept
160 {
165
166 const idx_t nt = f->filter_arg;
167
168 matrix_child->id = matrix_father->id;
169 matrix_child->elemsize = matrix_father->elemsize;
170 matrix_child->nx = matrix_father->nx;
171 matrix_child->ny =
172 (id == nparts - 1) ? (matrix_father->ny - (nt * id)) : nt;
173
174 /* is the information on this node valid ? */
175 if (matrix_father->dev_handle) {
176 matrix_child->dev_handle = matrix_father->dev_handle;
177 matrix_child->ld = matrix_father->ld;
178
179 const idx_t offset =
180 matrix_child->elemsize * matrix_child->ld * (nt * id);
181 if (matrix_father->ptr)
182 matrix_child->ptr = matrix_father->ptr + offset;
183 matrix_child->offset = matrix_father->offset + offset;
184
185 matrix_child->allocsize =
186 matrix_child->ld * matrix_child->ny * matrix_child->elemsize;
187 }
188 else
189 matrix_child->allocsize =
190 matrix_child->nx * matrix_child->ny * matrix_child->elemsize;
191 }
192
193} // namespace starpu
194} // namespace tlapack
195
196#endif // TLAPACK_STARPU_FILTERS_HH
void filter_cols(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts) noexcept
StarPU filter to partition a matrix along the y (column) dimension.
Definition filters.hpp:155
void filter_rows(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nparts) noexcept
StarPU filter to partition a matrix along the x (row) dimension.
Definition filters.hpp:105
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
Types for StarPU.