complex_filters.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2019-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <starpu.h>
  17. #include "complex_interface.h"
  18. void starpu_complex_filter_block(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks)
  19. {
  20. struct starpu_complex_interface *complex_father = father_interface;
  21. struct starpu_complex_interface *complex_child = child_interface;
  22. uint32_t nx = complex_father->nx;
  23. size_t elemsize = sizeof(double);
  24. STARPU_ASSERT_MSG(nchunks <= nx, "%u parts for %u elements", nchunks, nx);
  25. uint32_t child_nx;
  26. size_t offset;
  27. /* Compute the split */
  28. starpu_filter_nparts_compute_chunk_size_and_offset(nx, nchunks, elemsize, id, 1,
  29. &child_nx, &offset);
  30. complex_child->nx = child_nx;
  31. if (complex_father->real)
  32. {
  33. complex_child->real = (void*) ((uintptr_t) complex_father->real + offset);
  34. complex_child->imaginary = (void*) ((uintptr_t) complex_father->imaginary + offset);
  35. }
  36. }
  37. void starpu_complex_filter_canonical(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks)
  38. {
  39. struct starpu_complex_interface *complex_father = father_interface;
  40. struct starpu_vector_interface *vector_child = child_interface;
  41. STARPU_ASSERT_MSG(nchunks == 2, "complex can only be split into two pieces");
  42. STARPU_ASSERT_MSG(id < 2, "complex has only two pieces");
  43. vector_child->id = STARPU_VECTOR_INTERFACE_ID;
  44. if (id == 0)
  45. vector_child->ptr = (uintptr_t) complex_father->real;
  46. else
  47. vector_child->ptr = (uintptr_t) complex_father->imaginary;
  48. /* the complex interface doesn't support dev_handle/offset */
  49. vector_child->dev_handle = vector_child->ptr;
  50. vector_child->offset = 0;
  51. vector_child->nx = complex_father->nx;
  52. vector_child->elemsize = sizeof(double);
  53. vector_child->slice_base = 0;
  54. vector_child->allocsize = vector_child->nx * vector_child->elemsize;
  55. }
  56. struct starpu_data_interface_ops *starpu_complex_filter_canonical_child_ops(STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned child)
  57. {
  58. return &starpu_interface_vector_ops;
  59. }