Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STL checkpointing: an STL type within a user defined type within an STL will fail to checkpoint #1354

Open
jdeans289 opened this issue Oct 4, 2022 · 2 comments

Comments

@jdeans289
Copy link
Contributor

jdeans289 commented Oct 4, 2022

A case where STL checkpointing will fail:

A user defined class with an STL in it:

class VectorWrapper {
    int a;
    std::vector<int> vec;
}

An outer class (which is registered with the memory manager, like a member of a sim_object or something that has been explicitly declared) that has an STL container of these objects:

class MyObject {
    std::vector<VectorWrapper> vec_user_defined;
}

If MyObject is populated, it will be able to checkpoint and restore without throwing an error, and all the VectorWrapper objects will be present, but vec will not be restored (a will restore successfully). The contents of vec are never written out to the checkpoint file.

If MyObject instead has a vector of pointers to VectorWrapper, and each VectorWrapper is registered with the memory manager, vec will checkpoint and restore successfully.

class MyObject {
    std::vector<VectorWrapper *> vec_user_defined_ptr;
}
@alexlin0
Copy link
Contributor

alexlin0 commented Oct 4, 2022

I think you may have found a limitation of the initial STL checkpoint capability. I think the STL checkpointing can only handle simple types, including pointers, or nested STL types, i.e. vector of vectors. The memory allocated to composite types like classes like the vector of VectorWrapper is not controlled by the memory manager and would have to be temporarily allocated/freed during checkpoint/restore operations. I think it can be done, but I don't think it's an easy thing.

@jdeans289
Copy link
Contributor Author

Gotcha, thanks for the info! I'll get that limitation documented at least and look more into solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants