2
$\begingroup$

I was looking at the documentation for PetscBagCreate(), and it says that

The size of the A struct must be small enough to fit in a PetscInt; by default PetscInt is > 4 bytes. The warning about casting to a shorter length can be ignored below unless your A struct is too large.

I assume that this means that a pointer to the struct must be smaller than a PetscInt, the examples use structs that contain PetscInts as well as other things. That said, I'm under the impression that pointers on 64 bit machines can be larger than the 32 bits in a PetscInt.

What does this restriction on the size of the struct mean for users?

Can PetscBags be used on 64 bit systems?

$\endgroup$

1 Answer 1

2
$\begingroup$

PetscBag is meant for holding parameters or other redundant data, so it's not a place to put huge data like distributed model state. It can be used with 64-bit integers, but unfortunately, the format is not binary-compatible with the 32-bit integer format. It could be fixed to be backward-compatible at the expense of making the format slightly more complicated, but I doubt anyone is volunteering to do that just now. As for your questions:

What does this restriction on the size of the struct mean for users?

You should put less than 2GB in a PetscBag. Since the data is loaded strictly (instead of lazily), you want this anyway to be able to load it with a reasonable amount of memory.

Can PetscBags be used on 64 bit systems?

Absolutely, and the format is compatible between 32- and 64-bit systems and big versus little endian systems.

$\endgroup$
1
  • $\begingroup$ For some reason I thought it meant that the pointer to the struct could not be larger than 32 bits. $\endgroup$
    – Dan
    Mar 14, 2012 at 0:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.