9template <
typename T,
typename Allocator = dr::mp::__detail::allocator<T>>
14 void broadcast_data(std::size_t height, std::size_t width, std::size_t root,
16 if (_data !=
nullptr) {
19 _data_size = height * width;
22 _data = alloc.allocate(_data_size);
23 if (comm.rank() == root) {
24 for (
auto i = 0; i < width; i++) {
26 __detail::sycl_copy(root_data[i], root_data[i] + height,
29 rng::copy(root_data[i], root_data[i] + height, _data + height * i);
33 comm.bcast(_data,
sizeof(T) * _data_size, root);
36 template <rng::input_range R>
37 void broadcast_data(std::size_t height, std::size_t width, std::size_t root,
39 if (_data !=
nullptr) {
42 _data_size = height * width;
45 _data = alloc.allocate(_data_size);
46 if (comm.rank() == root) {
48 __detail::sycl_copy(std::to_address(root_data.begin()),
49 std::to_address(root_data.end()), _data);
51 rng::copy(root_data.begin(), root_data.end(), _data);
54 std::size_t position = 0;
55 std::size_t reminder =
sizeof(T) * _data_size;
56 while (reminder > INT_MAX) {
57 comm.bcast(((uint8_t *)_data) + position, INT_MAX, root);
61 comm.bcast(((uint8_t *)_data) + position, reminder, root);
65 alloc.deallocate(_data, _data_size);
70 T *operator[](std::size_t
index) {
return _data + _height *
index; }
72 T *broadcasted_data() {
return _data; }
73 auto width() {
return _width; }
77 std::size_t _data_size = 0;
78 std::size_t _width = 0;
79 std::size_t _height = 0;
Definition: communicator.hpp:13
Definition: broadcasted_slim_matrix.hpp:10