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) ?
"assign_value"
277 : (op == Operation::Add) ?
"add_value"
278 : (op == Operation::Subtract) ?
"subtract_value"
279 : (op == Operation::Multiply) ?
"multiply_value"
280 : (op == Operation::Divide) ?
"divide_value"
285 cl.where |= STARPU_CPU;
291 static constexpr const struct starpu_codelet cl_op_value[] = {
292 gen_cl_op_value<internal::Operation::Assign, T>(),
293 gen_cl_op_value<internal::Operation::Add, T>(),
294 gen_cl_op_value<internal::Operation::Subtract, T>(),
295 gen_cl_op_value<internal::Operation::Multiply, T>(),
296 gen_cl_op_value<internal::Operation::Divide, T>()};
297 static constexpr const struct starpu_codelet cl_op_rvalue[] = {
298 gen_cl_op_value<internal::Operation::Assign, real_type<T>>(),
299 gen_cl_op_value<internal::Operation::Add, real_type<T>>(),
300 gen_cl_op_value<internal::Operation::Subtract, real_type<T>>(),
301 gen_cl_op_value<internal::Operation::Multiply, real_type<T>>(),
302 gen_cl_op_value<internal::Operation::Divide, real_type<T>>()};
307 template <
internal::Operation op,
class U>
308 static constexpr struct starpu_codelet gen_cl_op_data() noexcept
310 using internal::Operation;
311 struct starpu_codelet cl = internal::codelet_init();
313 cl.cpu_funcs[0] = internal::data_op_data<T, U, op>;
315 cl.modes[0] = (op == Operation::Assign) ? STARPU_W : STARPU_RW;
316 cl.modes[1] = STARPU_R;
317 cl.name = (op == Operation::Assign) ?
"assign_data"
318 : (op == Operation::Add) ?
"add_data"
319 : (op == Operation::Subtract) ?
"subtract_data"
320 : (op == Operation::Multiply) ?
"multiply_data"
321 : (op == Operation::Divide) ?
"divide_data"
326 cl.where |= STARPU_CPU;
332 static constexpr const struct starpu_codelet cl_op_data[] = {
333 gen_cl_op_data<internal::Operation::Assign, T>(),
334 gen_cl_op_data<internal::Operation::Add, T>(),
335 gen_cl_op_data<internal::Operation::Subtract, T>(),
336 gen_cl_op_data<internal::Operation::Multiply, T>(),
337 gen_cl_op_data<internal::Operation::Divide, T>()};
338 static constexpr const struct starpu_codelet cl_op_rdata[] = {
339 gen_cl_op_data<internal::Operation::Assign, real_type<T>>(),
340 gen_cl_op_data<internal::Operation::Add, real_type<T>>(),
341 gen_cl_op_data<internal::Operation::Subtract, real_type<T>>(),
342 gen_cl_op_data<internal::Operation::Multiply, real_type<T>>(),
343 gen_cl_op_data<internal::Operation::Divide, real_type<T>>()};
348 template <
internal::Operation op>
349 static constexpr struct starpu_codelet gen_cl_op_entries() noexcept
351 using internal::Operation;
352 struct starpu_codelet cl = internal::codelet_init();
354 cl.cpu_funcs[0] = internal::matrixentry_op_matrixentry<T, op>;
356 cl.modes[0] = STARPU_RW;
357 cl.name = (op == Operation::Assign) ?
"copy_entry"
358 : (op == Operation::Add) ?
"add_entry"
359 : (op == Operation::Subtract) ?
"subtract_entry"
360 : (op == Operation::Multiply) ?
"multiply_entry"
361 : (op == Operation::Divide) ?
"divide_entry"
366 cl.where |= STARPU_CPU;
372 static constexpr const struct starpu_codelet cl_op_entries[] = {
373 gen_cl_op_entries<internal::Operation::Assign>(),
374 gen_cl_op_entries<internal::Operation::Add>(),
375 gen_cl_op_entries<internal::Operation::Subtract>(),
376 gen_cl_op_entries<internal::Operation::Multiply>(),
377 gen_cl_op_entries<internal::Operation::Divide>()};
388 template <internal::Operation op,
390 std::enable_if_t<(std::is_same_v<U, T> ||
391 std::is_same_v<U, real_type<T>>),
393 MatrixEntry& operate_and_assign(
const MatrixEntry<U>& x)
396 struct starpu_task* task = starpu_task_create();
398 if (this->root_handle == x.root_handle) {
403 using args_t = std::tuple<idx_t, idx_t, idx_t, idx_t>;
406 args_t* args_ptr =
new args_t;
409 std::get<0>(*args_ptr) =
pos[0];
410 std::get<1>(*args_ptr) =
pos[1];
411 std::get<2>(*args_ptr) = x.pos[0];
412 std::get<3>(*args_ptr) = x.pos[1];
415 task->cl = (
struct starpu_codelet*)&(cl_op_entries[
int(op)]);
417 task->cl_arg = (
void*)args_ptr;
418 task->cl_arg_size =
sizeof(args_t);
419 task->callback_func = [](
void* args)
noexcept {
420 delete (args_t*)args;
422 task->callback_arg = (
void*)args_ptr;
426 task->cl = (
struct starpu_codelet*)&(
427 std::is_same_v<U, T> ? cl_op_data[
int(op)]
428 : cl_op_rdata[int(op)]);
429 task->handles[0] = this->
handle;
430 task->handles[1] = x.handle;
434 const int ret = starpu_task_submit(task);
435 STARPU_CHECK_RETURN_VALUE(ret,
"starpu_task_submit");
449 template <internal::Operation op,
451 std::enable_if_t<(std::is_same_v<U, T> ||
452 std::is_same_v<U, real_type<T>>),
454 MatrixEntry& operate_and_assign(
const T& x)
460 struct starpu_task* task = starpu_task_create();
461 task->cl = (
struct starpu_codelet*)&(std::is_same_v<U, T>
462 ? cl_op_value[
int(op)]
463 : cl_op_rvalue[int(op)]);
464 task->handles[0] = this->
handle;
465 task->cl_arg = (
void*)x_ptr;
466 task->cl_arg_size =
sizeof(T);
467 task->callback_func = [](
void* arg)
noexcept {
delete (T*)arg; };
468 task->callback_arg = (
void*)x_ptr;
471 const int ret = starpu_task_submit(task);
472 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