OPAL (Object Oriented Parallel Accelerator Library)
2024.2
OPAL
Format.cpp
Go to the documentation of this file.
1
//
2
// Class Format
3
// Format class to allow serializing message objects into plain buffers
4
// to send directly with mpi calls or similar means
5
//
6
// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
7
// All rights reserved
8
//
9
// This file is part of OPAL.
10
//
11
// OPAL is free software: you can redistribute it and/or modify
12
// it under the terms of the GNU General Public License as published by
13
// the Free Software Foundation, either version 3 of the License, or
14
// (at your option) any later version.
15
//
16
// You should have received a copy of the GNU General Public License
17
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18
//
19
#include "
Message/Format.h
"
20
21
Format::Format
(
Message
*msg)
22
{
23
items
= msg->
size
();
24
size
= 0;
25
26
format_array
.resize(2*
items
);
27
for
(
unsigned
int
i=0; i<
items
; ++i)
28
{
29
Message::MsgItem
&msgitem = msg->
item
(i);
30
format_array
[2*i+0] = msgitem.
numElems
();
31
format_array
[2*i+1] = msgitem.
numBytes
();
32
size
+=
format_array
[2*i+1];
33
}
34
}
35
36
void
Format::print
()
37
{
38
std::cout <<
"size: "
<<
size
<< std::endl;
39
for
(
unsigned
int
i=0; i<
items
; ++i)
40
{
41
std::cout <<
"entry "
<< i <<
": "
<<
format_array
[2*i+0]
42
<<
" elements "
<<
format_array
[2*i+1] <<
" bytes\n"
;
43
}
44
}
Format.h
Format::Format
Format(Message *)
Definition
Format.cpp:21
Format::size
unsigned int size
Definition
Format.h:49
Format::items
unsigned int items
Definition
Format.h:49
Format::print
void print()
Definition
Format.cpp:36
Format::format_array
std::vector< unsigned int > format_array
Definition
Format.h:50
Message
Definition
Message.h:143
Message::size
size_t size() const
Definition
Message.h:292
Message::item
MsgItem & item(size_t n)
Definition
Message.h:308
Message::MsgItem
Definition
Message.h:151
Message::MsgItem::numBytes
unsigned int numBytes() const
Definition
Message.h:218
Message::MsgItem::numElems
unsigned int numElems() const
Definition
Message.h:222