-
Notifications
You must be signed in to change notification settings - Fork 61
Replace static colvarmodule with class member #886
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
base: master
Are you sure you want to change the base?
Conversation
|
A lot of progress towards the goal. Some classes got access to a The main hurdle that remains is the scripts, which rely heavily on the static As a first step, we could keep a static, global |
|
This is great progress already! :-) For Tcl, we could maybe use That would only work for Tcl, but that's also where you would need it. LAMMPS scripting commands are associated to a |
|
My main concern is, all Colvars functionality relies on there being a single instance of the module. Removing static pointers would also require adding a different kind of check that there is only one |
Why does all functionality rely on being a single instance? |
Mostly for I/O: if multiple instances were allowed, each would need its own set of input and output files. |
But this is what the derived classes of |
|
In practice, the main application I've had in mind so far would be associating one colvarmodule instance with one molecule in VMD, although that would need more work because 1) VMD has a single Tcl interpreter, and 2) so far we have single proxy object - so we'd have to choose between duplicating the proxy object as well, or let a single proxy switch between molecules. Given the current architecture, I think one proxy per molecule would be simpler. Thanks to Giacomo's suggestion with You may have more ideas for using multiple instances: I'm interested. |
|
To answer @giacomofiorin 's remark about relying on there being a single instance: my goal here is that several instances could exist and that all calls are addressed to the right objects. One point to be worked out is whether they attach to the same or different proxy objects. For now, I am working under the assumption of a proxy object talking to a single colvarmodule instance. |
for which there is no short-term solution
|
Making these changes, I find that the scripting functionality would be better located in the colvarmodule class than colvarproxy. The colvarscript object is now created and used only by the module, and the proxy is just an extra level of indirection. |
|
I had to re-introduce a patch to ScriptTcl.C to pass the correct colvarscript pointer in the NAMD-defined version of the cv command. Incompatible (non-patched) NAMD will pass a wrong pointer, so I added a validation function to colvarscript to detect that and print a helpful error message. |
e7aca8f to
cf9ec7c
Compare
cf9ec7c to
ad7df73
Compare
c04c86b to
bcd4afb
Compare
Note: renaming .diff to .patch to avoid falling under .gitignore
f5fa4a5 to
efa5526
Compare
about diamond inheritance
e6f7cfe to
46122d2
Compare
thread in Gromacs
|
I think the last issue in Gromacs is fixed. Note that at present, in shared-memory settings, only one thread has a pointer to the colvarmodule object, but in principle, it could be broadcast or made static so all threads can access it if that was useful. |
|
Since this is very conflict-prone, I propose to rebase only when ready to merge. |
In a first stage, just trying to keep functionality intact, removing all static member data from class
colvarmodule.First approach: make a colvarmodule pointer a member of colvarparse, because the big classes inherit from it.
Now a number of lightweight classes (in colvartypes) or sub-classes don't have access to the pointer yet. Alternatives are to extend them with a pointer, or remove the functionality that needs it (mostly
loganderrorcalls).EDIT: because this is so far-reaching, I am turning it into a partial implementation that can be merged in finite time, leaving some of the classes to be modified later.
Namely:
colvarbias classes have been handles thanks to virtual inheritance: only the colvarbias base class constructor sets the cvmodule pointer, as passed on by the final classes. Intermediate classes don't have to worry about it.
Final status: the remaining uses of the static pointer can be tracked by looking for calls to
cvm::main(). There are new functionslog_staticanderror_staticthat make use of the static pointer only if available, and have fallbacks if not. All of these can be phased out in later PRs.