Repository navigation
Small Refactor of MachineModel to facilitate tests - #162
Conversation
54936a0 to
9f324ad
Compare
By allowing MachineModel to be constructed by a SpecsBuffer rather than a file, we can easily get a MachineModel in any tests that have one as a dependency.
9f324ad to
f8cd35a
Compare
There was a problem hiding this comment.
I don't really have any major comments on the implementation of this PR as it largely looks fine. However, I do have a general comment that may or may not be outside the scope of this PR:
It seems to me that in order to get the most use out of this feature, we would want the model being tested to refer to the same model we are using. However, it looks that in this PR we still load the machine model from a file when constructing ScheduleDAGOptSched, therefore in order to test and run the same machine model, we would need to maintain two configs. The immediate solution that comes to mind is to construct the MM for ScheduleDAGOptSched as done in simple_machine_model_test.cpp and removing the machine model config file altogether. This, though, leads to a less friendly UI to changing machine model params (e.g. involves re-compilation), and may not be worth implementing.
|
That's an interesting and quite good idea, which is out of scope for this PR. The idea here is to make as small of a change as possible in order to enable unit tests. These unit tests often won't care about the machine model, so having a simpleMachineModel() that can be entirely different from the actual machine model can make sense. Other unit tests might care about the machine model, but then they would probably want to be able to control it to test the interaction of a feature with the machine model. I really do like the idea, though, something like: const MachineModel DefaultMachineModel = {
// Whatever struct initializer needed to set this up
};We could make it so that the file is still possible, e.g. via a commandline flag, by having a parser that outputs this |
|
I'm going to pull this idea of the ideal refactor into an issue. Is this PR good to merge? |
I like your variant which blends together the encoded This PR looks good to me. |
|
Helps enable #177 |
By allowing MachineModel to be constructed by a SpecsBuffer rather than a file, we can easily get a MachineModel in any tests that have one as a dependency.
There are bigger ways to refactor the MachineModel that would definitely improve things, but if the focus is making the minimal change needed to enable more widespread unit tests, this is probably the simplest possible change.