Re: [deal.II] Re: Broadcasting packed objects

2020-06-09 Thread Wolfgang Bangerth

On 6/9/20 2:53 PM, Maurice Rohracker wrote:

Thanks, Peter, that helped so far!

Another question would be, how would then the serialize function look like if 
one has another class as a member of a class. So, in this case, how would the 
serialize function look like if one has a class House and two of its member 
are of the type Room?

A serializing of nested objects so to speak.


The pack()/unpack() functions make use of the fact that many of the deal.II 
classes have save()/load() functions (sometimes combined into a serialize() 
function) that recursively save/load/serialize the member variables of these 
classes. Here is an example:

https://github.com/dealii/dealii/blob/master/include/deal.II/grid/tria.h#L4030-L4062

In these functions, operator& is used to serialize variables into/out of the 
given stream. If these variables are themselves classes, then that just calls 
these classes' respective save/load/serialize functions.


Best
 W.

--

Wolfgang Bangerth  email: bange...@colostate.edu
   www: http://www.math.colostate.edu/~bangerth/

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/f38c8e99-6394-923f-6efc-c7be12056bc7%40colostate.edu.


[deal.II] Re: Broadcasting packed objects

2020-06-09 Thread Maurice Rohracker
Thanks, Peter, that helped so far!

Another question would be, how would then the serialize function look like 
if one has another class as a member of a class. So, in this case, how 
would the serialize function look like if one has a class House and two of 
its member are of the type Room?
A serializing of nested objects so to speak.


Am Montag, 8. Juni 2020 14:19:25 UTC+2 schrieb peterrum:
>
> Dear Maurice,
>
> The problem is that the size of `auto buffer = 
> dealii::Utilities::pack(r1);` is not the same on all processes, which is a 
> requirement if you use `MPI_Bcast`. My suggestion would to split the 
> procedure into two steps: 1) bcast the size on rank 1; 2) bcast the actual 
> data.
>
> Peter
>
> On Monday, 8 June 2020 12:46:53 UTC+2, Maurice Rohracker wrote:
>>
>> Dear deal.II community,
>>
>> For a distributed implementation, we would like to broadcast packed data 
>> objects.
>>
>> For the beginning, we would like to understand how the serialize function 
>> for packing an object is working in the sense of the deal.II way, before it 
>> is getting more complicated.
>>
>> I created a small test with a class, which should be broadcasted. As a 
>> comparison, I took the dealii:Point, which can obviously be packed and 
>> broadcasted without any issues.
>>
>> Unfortunately, the broadcast for our class does not work. We assume that 
>> our serialize function is not in the correct manner. Is it possible to pack 
>> own objects using the dealii::Utilities:pack() function? What is the proper 
>> way defining the serialize function?
>>
>> Attached you'll find our small example code. We are using deal.II 9.0.1.
>>
>> Thank you very much in advance.
>>
>> Best regards,
>> Maurice Rohracker
>> Master Student Computational Engineering
>> FAU Erlange-Nürnberg
>>
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/31811f32-55a7-41d6-8a71-376e2a07cd76o%40googlegroups.com.


[deal.II] Re: Broadcasting packed objects

2020-06-08 Thread 'peterrum' via deal.II User Group
What you could also do is to turn compression off.

Peter

On Monday, 8 June 2020 14:19:25 UTC+2, peterrum wrote:
>
> Dear Maurice,
>
> The problem is that the size of `auto buffer = 
> dealii::Utilities::pack(r1);` is not the same on all processes, which is a 
> requirement if you use `MPI_Bcast`. My suggestion would to split the 
> procedure into two steps: 1) bcast the size on rank 1; 2) bcast the actual 
> data.
>
> Peter
>
> On Monday, 8 June 2020 12:46:53 UTC+2, Maurice Rohracker wrote:
>>
>> Dear deal.II community,
>>
>> For a distributed implementation, we would like to broadcast packed data 
>> objects.
>>
>> For the beginning, we would like to understand how the serialize function 
>> for packing an object is working in the sense of the deal.II way, before it 
>> is getting more complicated.
>>
>> I created a small test with a class, which should be broadcasted. As a 
>> comparison, I took the dealii:Point, which can obviously be packed and 
>> broadcasted without any issues.
>>
>> Unfortunately, the broadcast for our class does not work. We assume that 
>> our serialize function is not in the correct manner. Is it possible to pack 
>> own objects using the dealii::Utilities:pack() function? What is the proper 
>> way defining the serialize function?
>>
>> Attached you'll find our small example code. We are using deal.II 9.0.1.
>>
>> Thank you very much in advance.
>>
>> Best regards,
>> Maurice Rohracker
>> Master Student Computational Engineering
>> FAU Erlange-Nürnberg
>>
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/fce1fbdf-6a12-4700-82de-d6aaf0d084e4o%40googlegroups.com.


[deal.II] Re: Broadcasting packed objects

2020-06-08 Thread 'peterrum' via deal.II User Group
Dear Maurice,

The problem is that the size of `auto buffer = 
dealii::Utilities::pack(r1);` is not the same on all processes, which is a 
requirement if you use `MPI_Bcast`. My suggestion would to split the 
procedure into two steps: 1) bcast the size on rank 1; 2) bcast the actual 
data.

Peter

On Monday, 8 June 2020 12:46:53 UTC+2, Maurice Rohracker wrote:
>
> Dear deal.II community,
>
> For a distributed implementation, we would like to broadcast packed data 
> objects.
>
> For the beginning, we would like to understand how the serialize function 
> for packing an object is working in the sense of the deal.II way, before it 
> is getting more complicated.
>
> I created a small test with a class, which should be broadcasted. As a 
> comparison, I took the dealii:Point, which can obviously be packed and 
> broadcasted without any issues.
>
> Unfortunately, the broadcast for our class does not work. We assume that 
> our serialize function is not in the correct manner. Is it possible to pack 
> own objects using the dealii::Utilities:pack() function? What is the proper 
> way defining the serialize function?
>
> Attached you'll find our small example code. We are using deal.II 9.0.1.
>
> Thank you very much in advance.
>
> Best regards,
> Maurice Rohracker
> Master Student Computational Engineering
> FAU Erlange-Nürnberg
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/2b2fb018-0dfd-497a-a1df-9372f74e9e23o%40googlegroups.com.