-
Notifications
You must be signed in to change notification settings - Fork 22
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
DependencyGraph Segfault (Default Constructor + GenerateLayers) #581
Conversation
Decision is to remove the default constructor, enforcing that graphs can only be created via the ModelDescription class. This will make the new test unneccesary. Swig might need some hinting that the default costructor doesn't exist for it to work (depends on order of This may just get folded into #551, and this PR closed (to avoid conflicts) The method |
4bfe432
to
dd3ce09
Compare
dd3ce09
to
9f4eb27
Compare
Some thoughts on this:
explicit ModelDescription(const std::shared_ptr<ModelData> model_data);
// ...
ModelDescription::ModelDescription(const std::shared_ptr<ModelData> model_data) : model(model_data) { } This would then allow DependencyGraph to summon the Description from the Data, as required to generate the model. This will also however require a cahnge to the DependencyGraph class, which currently has: const ModelData* model; This cannot/shouldnot be a pointer to const ModelData, as the Changing this to be a |
I didn't like the idea of giving the |
The current API makes the Old API
New API
Functionality such as generating a graphic of the In effect, this moves the |
After discussion there should remain an ability to return a const reference to the |
f34c168
to
4b9e9d1
Compare
Tasks remaining before merge
|
Want to retain use of const in CUDASimulate argument. The clone function can instead return a non const which can be modified by building the dependency layers with a const shared pointer to this then stored. |
Not as trivial as it first seemed. The dependency graph code was written based on certain facts:
As such, the dependency relations are specified directly on the I think there are two approaches here we could take:
|
Cheat then, mark layers as mutable so it can be modified when const. Or modify the gen dep graph to return the layers so you can overwrite them in the cloned model data manually. Either of these will allow you make the genLayers() method const. Both are imperfect in one way or the other, but seem viable. If you do the latter, you could make it a private method and give CUDASim/Sim friend access, which fixes the nasty of having a user exposed method which returns a vec of layer descriptions. |
Decision made to go with option 2 for now and open an issue to add automation in the future |
Updates tests accordingly.
4cafcb5
to
4a3190c
Compare
When a DependencyGraph is constructed using the default constructor, calls to
generateLayers(ModelDescription& _model)
will trigger a segfault due to a null pointer, as described in #555.This PR removes the default constructor for DependencyGraph, so that they cannot exist outside of a model.
DependencyGraph::DependencyGraph()
ModelDescription
parameter fromDependencyGraph::generateLayers
.Closes #555 (when complete).