159 .filter_arg_ptr = (
void*)
pos};
164 MatrixEntry(MatrixEntry&&) =
delete;
165 MatrixEntry(
const MatrixEntry&) =
delete;
166 MatrixEntry& operator=(
const MatrixEntry&) =
delete;
186 std::enable_if_t<std::is_same_v<real_type<U>, T>,
int> = 0>
203 constexpr MatrixEntry& operator=(
const T&
x)
noexcept
209 constexpr MatrixEntry& operator+=(
const MatrixEntry<U>& x)
noexcept
211 return operate_and_assign<internal::Operation::Add, U>(x);
213 constexpr MatrixEntry& operator+=(
const T& x)
noexcept
215 return operate_and_assign<internal::Operation::Add, T>(x);
219 constexpr MatrixEntry& operator-=(
const MatrixEntry<U>& x)
noexcept
221 return operate_and_assign<internal::Operation::Subtract, U>(x);
223 constexpr MatrixEntry& operator-=(
const T& x)
noexcept
225 return operate_and_assign<internal::Operation::Subtract, T>(x);
229 constexpr MatrixEntry& operator*=(
const MatrixEntry<U>& x)
noexcept
231 return operate_and_assign<internal::Operation::Multiply, U>(x);
233 constexpr MatrixEntry& operator*=(
const T& x)
noexcept
235 return operate_and_assign<internal::Operation::Multiply, T>(x);
239 constexpr MatrixEntry& operator/=(
const MatrixEntry<U>& x)
noexcept
241 return operate_and_assign<internal::Operation::Divide, U>(x);
243 constexpr MatrixEntry& operator/=(
const T& x)
noexcept
245 return operate_and_assign<internal::Operation::Divide, T>(x);
250 constexpr friend real_type<T> abs(
const MatrixEntry& x)
noexcept
257 constexpr friend std::ostream& operator<<(std::ostream& out,
258 const MatrixEntry& x)
267 template <
internal::Operation op,
class U>
268 static constexpr struct starpu_codelet gen_cl_op_value() noexcept
270 using internal::Operation;
271 struct starpu_codelet cl = internal::codelet_init();
273 cl.cpu_funcs[0] = internal::data_op_value<T, U, op>;
275 cl.modes[0] = (op == Operation::Assign) ? STARPU_W : STARPU_RW;
276 cl.name = (op == Operation::Assign)
278 : (op == Operation::Add)
280 : (op == Operation::Subtract)
282 : (op == Operation::Multiply)
284 : (op == Operation::Divide)
290 cl.where |= STARPU_CPU;
296 static constexpr const struct starpu_codelet cl_op_value[] = {
297 gen_cl_op_value<internal::Operation::Assign, T>(),
298 gen_cl_op_value<internal::Operation::Add, T>(),
299 gen_cl_op_value<internal::Operation::Subtract, T>(),
300 gen_cl_op_value<internal::Operation::Multiply, T>(),
301 gen_cl_op_value<internal::Operation::Divide, T>()};
302 static constexpr const struct starpu_codelet cl_op_rvalue[] = {
303 gen_cl_op_value<internal::Operation::Assign, real_type<T>>(),
304 gen_cl_op_value<internal::Operation::Add, real_type<T>>(),
305 gen_cl_op_value<internal::Operation::Subtract, real_type<T>>(),
306 gen_cl_op_value<internal::Operation::Multiply, real_type<T>>(),
307 gen_cl_op_value<internal::Operation::Divide, real_type<T>>()};
312 template <
internal::Operation op,
class U>
313 static constexpr struct starpu_codelet gen_cl_op_data() noexcept
315 using internal::Operation;
316 struct starpu_codelet cl = internal::codelet_init();
318 cl.cpu_funcs[0] = internal::data_op_data<T, U, op>;
320 cl.modes[0] = (op == Operation::Assign) ? STARPU_W : STARPU_RW;
321 cl.modes[1] = STARPU_R;
322 cl.name = (op == Operation::Assign)
324 : (op == Operation::Add)
326 : (op == Operation::Subtract)
328 : (op == Operation::Multiply)
330 : (op == Operation::Divide)
336 cl.where |= STARPU_CPU;
342 static constexpr const struct starpu_codelet cl_op_data[] = {
343 gen_cl_op_data<internal::Operation::Assign, T>(),
344 gen_cl_op_data<internal::Operation::Add, T>(),
345 gen_cl_op_data<internal::Operation::Subtract, T>(),
346 gen_cl_op_data<internal::Operation::Multiply, T>(),
347 gen_cl_op_data<internal::Operation::Divide, T>()};
348 static constexpr const struct starpu_codelet cl_op_rdata[] = {
349 gen_cl_op_data<internal::Operation::Assign, real_type<T>>(),
350 gen_cl_op_data<internal::Operation::Add, real_type<T>>(),
351 gen_cl_op_data<internal::Operation::Subtract, real_type<T>>(),
352 gen_cl_op_data<internal::Operation::Multiply, real_type<T>>(),
353 gen_cl_op_data<internal::Operation::Divide, real_type<T>>()};
358 template <
internal::Operation op>
359 static constexpr struct starpu_codelet gen_cl_op_entries() noexcept
361 using internal::Operation;
362 struct starpu_codelet cl = internal::codelet_init();
364 cl.cpu_funcs[0] = internal::matrixentry_op_matrixentry<T, op>;
366 cl.modes[0] = STARPU_RW;
367 cl.name = (op == Operation::Assign)
369 : (op == Operation::Add)
371 : (op == Operation::Subtract)
373 : (op == Operation::Multiply)
375 : (op == Operation::Divide)
381 cl.where |= STARPU_CPU;
387 static constexpr const struct starpu_codelet cl_op_entries[] = {
388 gen_cl_op_entries<internal::Operation::Assign>(),
389 gen_cl_op_entries<internal::Operation::Add>(),
390 gen_cl_op_entries<internal::Operation::Subtract>(),
391 gen_cl_op_entries<internal::Operation::Multiply>(),
392 gen_cl_op_entries<internal::Operation::Divide>()};
403 template <internal::Operation op,
405 std::enable_if_t<(std::is_same_v<U, T> ||
406 std::is_same_v<U, real_type<T>>),
408 MatrixEntry& operate_and_assign(
const MatrixEntry<U>& x)
411 struct starpu_task* task = starpu_task_create();
413 if (this->root_handle == x.root_handle) {
418 using args_t = std::tuple<idx_t, idx_t, idx_t, idx_t>;
421 args_t* args_ptr =
new args_t;
424 std::get<0>(*args_ptr) =
pos[0];
425 std::get<1>(*args_ptr) =
pos[1];
426 std::get<2>(*args_ptr) = x.pos[0];
427 std::get<3>(*args_ptr) = x.pos[1];
430 task->cl = (
struct starpu_codelet*)&(cl_op_entries[
int(op)]);
432 task->cl_arg = (
void*)args_ptr;
433 task->cl_arg_size =
sizeof(args_t);
434 task->callback_func = [](
void* args)
noexcept {
435 delete (args_t*)args;
437 task->callback_arg = (
void*)args_ptr;
441 task->cl = (
struct starpu_codelet*)&(
442 std::is_same_v<U, T> ? cl_op_data[
int(op)]
443 : cl_op_rdata[int(op)]);
444 task->handles[0] = this->
handle;
445 task->handles[1] = x.handle;
449 const int ret = starpu_task_submit(task);
450 STARPU_CHECK_RETURN_VALUE(ret,
"starpu_task_submit");
464 template <internal::Operation op,
466 std::enable_if_t<(std::is_same_v<U, T> ||
467 std::is_same_v<U, real_type<T>>),
469 MatrixEntry& operate_and_assign(
const T& x)
475 struct starpu_task* task = starpu_task_create();
476 task->cl = (
struct starpu_codelet*)&(std::is_same_v<U, T>
477 ? cl_op_value[
int(op)]
478 : cl_op_rvalue[int(op)]);
479 task->handles[0] = this->
handle;
480 task->cl_arg = (
void*)x_ptr;
481 task->cl_arg_size =
sizeof(T);
482 task->callback_func = [](
void* arg)
noexcept {
delete (T*)arg; };
483 task->callback_arg = (
void*)x_ptr;
486 const int ret = starpu_task_submit(task);
487 STARPU_CHECK_RETURN_VALUE(ret,
"starpu_task_submit");
constexpr void data_op_data(void **buffers, void *args) noexcept
MatrixEntry operation with assignment using two StarPU variable buffers.
Definition MatrixEntry.hpp:49
constexpr struct starpu_codelet codelet_init() noexcept
Return an empty starpu_codelet struct.
Definition MatrixEntry.hpp:34
constexpr void matrixentry_op_matrixentry(void **buffers, void *args) noexcept
MatrixEntry operation with assignment using a two matrix entries.
Definition MatrixEntry.hpp:99
constexpr void data_op_value(void **buffers, void *args) noexcept
MatrixEntry operation with assignment using a StarPU variable buffer and a value.
Definition MatrixEntry.hpp:74
constexpr MatrixEntry(starpu_data_handle_t root_handle, const idx_t pos[2]) noexcept
MatrixEntry constructor from a variable handle.
Definition MatrixEntry.hpp:151