charm AT lists.siebelschool.illinois.edu
Subject: Charm++ parallel programming system
List archive
- From: Jonah Miller <jonah.maxwell.miller AT gmail.com>
- To: Sam White <white67 AT illinois.edu>
- Cc: "charm AT cs.uiuc.edu" <charm AT cs.uiuc.edu>
- Subject: Re: [charm] PUP and enum types
- Date: Thu, 09 Jul 2015 01:35:29 -0400
- List-archive: <http://lists.cs.uiuc.edu/pipermail/charm/>
- List-id: CHARM parallel programming system <charm.cs.uiuc.edu>
Hi Sam, Perfect. Yes, this works. Unfortunately, I do need to pass the enum type directly. The idea is to streamline a few entry methods by combining them into a single method which takes an enum type as a flag. However, this works like a charm. Thanks for your help! Best, Jonah On 15-07-09 01:24 AM, Sam White wrote:
This
should work:
inline void operator|(PUP::er &p, enum_type &s) {
pup_bytes(&p, (void *)&s,
sizeof(enum_type));
}
Also, if you are never passing a variable of this enum
type to a parameter marshalled entry method and don't need a
PUP method directly for it, and instead are only passing
this enum type around as a member in a larger struct/class,
then you can just use the pup_bytes() call above directly in
that larger struct/class's PUP method.
-Sam
On Wed, Jul 8, 2015 at 9:31 PM, Jonah
Miller <jonah.maxwell.miller AT gmail.com>
wrote:
Hi Sam, Thanks for your reply. This helps a lot. Since enum types can't have methods, I will need to overload the pipe operator, but a naive implementation results in compile time errors. Can you instruct me in the best way to overload the pipe operator for PUP? Here is my current attempt: #ifndef INCLUDED_SIDES_HPP #define INCLUDED_SIDES_HPP #include <pup.h> enum class Side{LEFT, RIGHT}; PUP::er& operator|(PUP::er& p, Side& s) { pup_bytes(&p, (void*)&s, sizeof(Side)); } #endif // INCLUDED_SIDES_HPP and this raises an error at linking time that says I've over-defined the | operator: ~/programming/charm-functional-wavetoy/Sides.hpp:14: multiple definition of `operator|(PUP::er&, Side&)' wavetoy_unit_tests.o:/home/jmiller/programming/charm-functional-wavetoy/Sides.hpp:14: first defined here unittests.o: In function `operator|(PUP::er&, Side&)': ~/programming/charm-functional-wavetoy/Sides.hpp:14: multiple definition of `operator|(PUP::er&, Side&)' wavetoy_unit_tests.o:~/programming/charm-functional-wavetoy/Sides.hpp:14: first defined here collect2: error: ld returned 1 exit status This is strange, because the compiler is pointing to the same file in both cases, which is protected by include guards. Thanks for your help! Best, Jonah On 15-07-08 11:59 AM, White, Samuel T wrote: > Hi Jonah, > > The most portable way to PUP an enumerated type is to use the pup_bytes() interface, as in: > > void pup(PUP::er &p) { > pup_bytes(&p, (void *)&enum_var, sizeof(enum_type)); > } > > -Sam > ________________________________________ > From: charm-bounces AT cs.uiuc.edu [charm-bounces AT cs.uiuc.edu] on behalf of Jonah Miller [jonah.maxwell.miller AT gmail.com] > Sent: Saturday, July 04, 2015 4:58 PM > To: charm AT cs.uiuc.edu > Subject: [charm] PUP and enum types > > Hi Everyone, > > I have a quick question about the PUP framework. What is the proper way > to pack or unpack enumerations? Under the hood, enumerations are > integers, so it seems like they should be pup-able. But I wondered if > there was a straightforward or "correct" way to do it. > > Thanks in advance for your help. > > Best, > Jonah Miller > _______________________________________________ > charm mailing list > charm AT cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/charm |
- [charm] PUP and enum types, Jonah Miller, 07/04/2015
- Re: [charm] PUP and enum types, White, Samuel T, 07/08/2015
- Re: [charm] PUP and enum types, Jonah Miller, 07/08/2015
- Message not available
- Re: [charm] PUP and enum types, Sam White, 07/09/2015
- Re: [charm] PUP and enum types, Jonah Miller, 07/09/2015
- Re: [charm] PUP and enum types, Sam White, 07/09/2015
- <Possible follow-up(s)>
- Re: [charm] PUP and enum types, meyu, 07/08/2015
- Re: [charm] PUP and enum types, meyu, 07/08/2015
- Re: [charm] PUP and enum types, meyu, 07/08/2015
- Re: [charm] PUP and enum types, meyu, 07/09/2015
- Re: [charm] PUP and enum types, meyu, 07/09/2015
- Re: [charm] PUP and enum types, meyu, 07/09/2015
- Re: [charm] PUP and enum types, meyu, 07/09/2015
- Re: [charm] PUP and enum types, White, Samuel T, 07/08/2015
Archive powered by MHonArc 2.6.16.