-
Notifications
You must be signed in to change notification settings - Fork 63
Separate NAMD GlobalMaster and colvarproxy_namd classes #803
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fb1356c
refactor: Begin patching GlobalMaster.h
giacomofiorin 73c6b8c
refactor: Begin separating colvarproxy_namd class from GlobalMaster p…
giacomofiorin 6411c0d
refactor: Initial implementation of GlobalMasterColvars wrapper class
giacomofiorin 305b0a7
build: Patch NAMD Makefile files
giacomofiorin 0052ed6
refactor: Use GlobalMasterColvars in colvarproxy_namd
giacomofiorin e16628d
fix: Add missing pointer for debug build, move macros to constexpr in…
giacomofiorin 26dcedd
cleanup: Use forward declaration and tidy up NAMD header includes
giacomofiorin 871037f
cleanup: Delete unused friend declaration
giacomofiorin b6cfc84
cleanup: Add .clang-format for NAMD folder
giacomofiorin 7cc73f9
fix: Remove wrong pointer from Charm++ trace functions
giacomofiorin 8866919
fix: Update NAMD patch files
giacomofiorin 4d45617
Use .patch extension for patch files to other codes, clean up updater…
giacomofiorin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| diff --git a/Make.depends b/Make.depends | ||
| index 994b3914..1d54373f 100644 | ||
| --- a/Make.depends | ||
| +++ b/Make.depends | ||
| @@ -6398,6 +6398,45 @@ obj/GlobalMasterTMD.o: \ | ||
| src/fitrms.h \ | ||
| src/Debug.h | ||
| $(CXX) $(CXXFLAGS) $(COPTO)obj/GlobalMasterTMD.o $(COPTC) src/GlobalMasterTMD.C | ||
| +obj/GlobalMasterColvars.o: \ | ||
| + obj/.exists \ | ||
| + src/GlobalMasterColvars.C \ | ||
| + src/Controller.h \ | ||
| + src/common.h \ | ||
| + src/Vector.h \ | ||
| + src/Tensor.h \ | ||
| + src/Lattice.h \ | ||
| + src/NamdTypes.h \ | ||
| + src/CudaRecord.h \ | ||
| + src/HipDefines.h \ | ||
| + src/ResizeArray.h \ | ||
| + src/ResizeArrayRaw.h \ | ||
| + src/fstream_namd.h \ | ||
| + src/DataExchanger.h \ | ||
| + src/main.h \ | ||
| + inc/DataExchanger.decl.h \ | ||
| + src/Pointer.h \ | ||
| + src/GlobalMaster.h \ | ||
| + src/GlobalMasterColvars.h \ | ||
| + src/colvarproxy_namd.h \ | ||
| + src/colvarproxy_namd_version.h \ | ||
| + src/SimParameters.h \ | ||
| + src/imd.h \ | ||
| + src/MGridforceParams.h \ | ||
| + src/GroupRestraintsParam.h \ | ||
| + src/Random.h \ | ||
| + src/ConfigList.h \ | ||
| + colvars/src/colvarmodule.h \ | ||
| + colvars/src/colvarproxy.h \ | ||
| + colvars/src/colvarmodule.h \ | ||
| + colvars/src/colvartypes.h \ | ||
| + colvars/src/colvarproxy_io.h \ | ||
| + colvars/src/colvarproxy_replicas.h \ | ||
| + colvars/src/colvarproxy_system.h \ | ||
| + colvars/src/colvarproxy_tcl.h \ | ||
| + colvars/src/colvarproxy_volmaps.h \ | ||
| + colvars/src/colvarvalue.h | ||
| + $(CXX) $(CXXFLAGS) $(COPTO)obj/GlobalMasterColvars.o $(COPTC) src/GlobalMasterColvars.C | ||
| obj/Matrix4Symmetry.o: \ | ||
| obj/.exists \ | ||
| src/Matrix4Symmetry.C \ | ||
| @@ -6637,6 +6676,8 @@ obj/colvarproxy_namd.o: \ | ||
| src/MStream.h \ | ||
| plugins/include/molfile_plugin.h \ | ||
| plugins/include/vmdplugin.h \ | ||
| + src/GlobalMasterColvars.h \ | ||
| + src/GlobalMaster.h \ | ||
| src/GridForceGrid.inl \ | ||
| src/PDB.h \ | ||
| src/parm.h \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,12 @@ | ||
| diff --git a/Makefile b/Makefile | ||
| index fb23fcac..541fe8ca 100644 | ||
| index 960f7718..85126dff 100644 | ||
| --- a/Makefile | ||
| +++ b/Makefile | ||
| @@ -446,7 +446,7 @@ CXXMICFLAGS = $(CXXBASEFLAGS) $(CXXOPTS) $(CXXMICOPTS) | ||
| CXXTHREADFLAGS = $(CXXBASEFLAGS) $(CXXTHREADOPTS) | ||
| CXXSIMPARAMFLAGS = $(CXXBASEFLAGS) $(CXXSIMPARAMOPTS) | ||
| CXXNOALIASFLAGS = $(CXXBASEFLAGS) $(CXXNOALIASOPTS) | ||
| -COLVARSCXXFLAGS = $(CXXBASEFLAGS) $(CXXOPTS) $(COPTI)$(LEPTONINCDIR) -DLEPTON -DLEPTON_USE_STATIC_LIBRARIES | ||
| +COLVARSCXXFLAGS = $(CXXBASEFLAGS) $(CXXOPTS) $(COPTI)$(LEPTONINCDIR) -DLEPTON -DLEPTON_USE_STATIC_LIBRARIES $(EXTRACOLVARSFLAGS) | ||
| GXXFLAGS = $(CXXBASEFLAGS) -DNO_STRSTREAM_H | ||
| CFLAGS = $(COPTI)$(SRCDIR) $(TCL) $(COPTS) $(RELEASE) $(EXTRADEFINES) $(TRACEOBJDEF) | ||
| PLUGINGCCFLAGS = $(COPTI)$(PLUGINSRCDIR) $(COPTI)$(PLUGININCDIR) $(COPTD)STATIC_PLUGIN | ||
| @@ -231,6 +231,7 @@ OBJS = \ | ||
| $(DSTDIR)/GlobalMasterTcl.o \ | ||
| $(DSTDIR)/GlobalMasterSMD.o \ | ||
| $(DSTDIR)/GlobalMasterTMD.o \ | ||
| + $(DSTDIR)/GlobalMasterColvars.o \ | ||
| $(DSTDIR)/Matrix4Symmetry.o \ | ||
| $(DSTDIR)/GlobalMasterSymmetry.o \ | ||
| $(DSTDIR)/GlobalMasterFreeEnergy.o \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,59 +0,0 @@ | ||
| diff --git a/config b/config | ||
| index ddf9f860..4148d87c 100755 | ||
| --- a/config | ||
| +++ b/config | ||
| @@ -57,6 +57,8 @@ function error_syntax { | ||
| echo ' --cuda-dlink arch=<arch>,code=<code> (for cuFFT, may be repeated)' | ||
| echo ' --with-cuda-profiling (enables CUDA profiling with NVTX)' | ||
| echo ' --with-rocm-profiling (enables ROCm profiling with ROCtracer API)' | ||
| + echo ' --with-colvars-torch (enables torchann in Colvars)' | ||
| + echo ' --torch-prefix <directory containing libTorch>' | ||
| echo '' | ||
| if [ -n "${PRINT_ARCH_LIST+set}" ]; then | ||
| ARCH_PAT='' | ||
| @@ -152,6 +154,7 @@ function error_exists { | ||
| use_mkl=0 | ||
| use_cuda=0 | ||
| use_hip=0 | ||
| + use_colvars_torch=0 | ||
| use_cuda_prof=0 | ||
| use_rocm_prof=0 | ||
| use_memopt=0 | ||
| @@ -257,6 +260,19 @@ function error_exists { | ||
| ARCH_SUFFIX_ARG=$ARCH_SUFFIX_ARG-$1 | ||
| ;; | ||
|
|
||
| + --with-colvars-torch) | ||
| + use_colvars_torch=1 | ||
| + ;; | ||
| + | ||
| + --torch-prefix) | ||
| + shift | ||
| + if [ ! -d "$1" ]; then | ||
| + echo "ERROR: No such directory $1" | ||
| + error_syntax | ||
| + fi | ||
| + TORCH_PREFIX=$1 | ||
| + ;; | ||
| + | ||
| --with-debug) | ||
| use_debug=1 | ||
| ;; | ||
| @@ -1015,7 +1031,16 @@ function error_exists { | ||
| if [ -n "$CC_OPTS" ]; then | ||
| echo "COPTS = $CC_OPTS" >> Make.config | ||
| fi | ||
| - | ||
| + if (( "$use_colvars_torch" )); then | ||
| + echo "TORCHDIR = $TORCH_PREFIX" >> Make.config | ||
| + echo 'TORCHINCFLAGS = $(COPTI)$(TORCHDIR)/include $(COPTI)$(TORCHDIR)/include/torch/csrc/api/include' >> Make.config | ||
| + echo 'EXTRACOLVARSFLAGS = -std=c++17 -DCOLVARS_TORCH $(TORCHINCFLAGS)' >> Make.config | ||
| + if [[ $use_cuda && -f "${TORCH_PREFIX}/lib/libtorch_cuda.so" ]]; then | ||
| + echo 'EXTRALINKLIBS = -Wl,-rpath,$(TORCHDIR)/lib -L$(TORCHDIR)/lib -ltorch -ltorch_cpu -lc10 -ltorch_cuda -lc10_cuda' >> Make.config | ||
| + else | ||
| + echo 'EXTRALINKLIBS = -Wl,-rpath,$(TORCHDIR)/lib -L$(TORCHDIR)/lib -ltorch -ltorch_cpu -lc10' >> Make.config | ||
| + fi | ||
| + fi | ||
|
|
||
| if (( $use_debug )); then | ||
| echo 'CXXOPTS = -g' >> Make.config | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
|
giacomofiorin marked this conversation as resolved.
|
||
| Language: Cpp | ||
| ColumnLimit: 100 | ||
| UseTab: Never | ||
| TabWidth: 2 | ||
| IndentWidth: 2 | ||
| ObjCBlockIndentWidth: 2 | ||
| PenaltyBreakAssignment: 2 | ||
| AccessModifierOffset: -2 | ||
| BreakBeforeBraces: WebKit | ||
| EmptyLineAfterAccessModifier: Leave | ||
| NamespaceIndentation: None | ||
| MaxEmptyLinesToKeep: 2 | ||
| ... | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // -*- c++ -*- | ||
|
|
||
| #include "GlobalMaster.h" | ||
| #include "GlobalMasterColvars.h" | ||
| #include "colvarproxy_namd.h" | ||
|
|
||
|
|
||
| GlobalMasterColvars::GlobalMasterColvars() : proxy(new colvarproxy_namd(this)) {} | ||
|
|
||
| GlobalMasterColvars::~GlobalMasterColvars() { reset(); } | ||
|
|
||
| void GlobalMasterColvars::calculate() { proxy->calculate(); } | ||
|
|
||
|
|
||
| void GlobalMasterColvars::reset() | ||
| { | ||
| // Unrequest all positions, total forces, etc from NAMD | ||
| modifyRequestedAtoms().clear(); | ||
| modifyForcedAtoms().clear(); | ||
| modifyAppliedForces().clear(); | ||
|
|
||
| modifyRequestedGroups().clear(); | ||
| modifyGroupForces().clear(); | ||
|
|
||
| #if NAMD_VERSION_NUMBER >= 34471681 | ||
| modifyRequestedGridObjects().clear(); | ||
| modifyGridObjForces().clear(); | ||
| #endif | ||
|
|
||
| requestTotalForce(false); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| #ifndef GLOBALMASTERCOLVARS_H | ||
| #define GLOBALMASTERCOLVARS_H | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "GlobalMaster.h" | ||
|
|
||
|
|
||
| class colvarproxy_namd; | ||
|
|
||
| class GlobalMasterColvars : public GlobalMaster { | ||
| public: | ||
|
|
||
| GlobalMasterColvars(); | ||
|
|
||
| ~GlobalMasterColvars(); | ||
|
|
||
| void reset(); | ||
|
|
||
| void calculate() override; | ||
|
|
||
| inline void requestTotalForcePublic(bool yesno = true) | ||
| { | ||
| requestTotalForce(yesno); | ||
| } | ||
|
|
||
| inline AtomIDList &modifyRequestedAtomsPublic() | ||
| { | ||
| return modifyRequestedAtoms(); | ||
| } | ||
|
|
||
| inline AtomIDList &modifyForcedAtomsPublic() | ||
| { | ||
| return modifyForcedAtoms(); | ||
| } | ||
|
|
||
| inline ForceList &modifyAppliedForcesPublic() | ||
| { | ||
| return modifyAppliedForces(); | ||
| } | ||
|
|
||
| inline ResizeArray<AtomIDList> &modifyRequestedGroupsPublic() | ||
| { | ||
| return modifyRequestedGroups(); | ||
| } | ||
|
|
||
| inline ForceList &modifyGroupForcesPublic() | ||
| { | ||
| return modifyGroupForces(); | ||
| } | ||
|
|
||
| inline IntList &modifyRequestedGridObjectsPublic() | ||
| { | ||
| return modifyRequestedGridObjects(); | ||
| } | ||
|
|
||
| inline BigRealList &modifyGridObjForcesPublic() | ||
| { | ||
| return modifyGridObjForces(); | ||
| } | ||
|
|
||
| inline AtomIDList::const_iterator getAtomIdBeginPublic() | ||
| { | ||
| return getAtomIdBegin(); | ||
| } | ||
|
|
||
| inline AtomIDList::const_iterator getAtomIdEndPublic() | ||
| { | ||
| return getAtomIdEnd(); | ||
| } | ||
|
|
||
| inline PositionList::const_iterator getAtomPositionBeginPublic() | ||
| { | ||
| return getAtomPositionBegin(); | ||
| } | ||
|
|
||
| inline PositionList::const_iterator getGroupPositionBeginPublic() | ||
| { | ||
| return getGroupPositionBegin(); | ||
| } | ||
|
|
||
| inline PositionList::const_iterator getGroupPositionEndPublic() | ||
| { | ||
| return getGroupPositionEnd(); | ||
| } | ||
|
|
||
| inline ForceList::const_iterator getGroupTotalForceBeginPublic() | ||
| { | ||
| return getGroupTotalForceBegin(); | ||
| } | ||
|
|
||
| inline ForceList::const_iterator getGroupTotalForceEndPublic() | ||
| { | ||
| return getGroupTotalForceEnd(); | ||
| } | ||
|
|
||
| inline IntList::const_iterator getGridObjIndexBeginPublic() | ||
| { | ||
| return getGridObjIndexBegin(); | ||
| } | ||
|
|
||
| inline IntList::const_iterator getGridObjIndexEndPublic() | ||
| { | ||
| return getGridObjIndexEnd(); | ||
| } | ||
|
|
||
| inline BigRealList::const_iterator getGridObjValueBeginPublic() | ||
| { | ||
| return getGridObjValueBegin(); | ||
| } | ||
|
|
||
| inline BigRealList::const_iterator getGridObjValueEndPublic() | ||
| { | ||
| return getGridObjValueEnd(); | ||
| } | ||
|
|
||
| inline AtomIDList::const_iterator getForceIdBeginPublic() | ||
| { | ||
| return getForceIdBegin(); | ||
| } | ||
|
|
||
| inline AtomIDList::const_iterator getForceIdEndPublic() | ||
| { | ||
| return getForceIdEnd(); | ||
| } | ||
|
|
||
| inline ForceList::const_iterator getTotalForcePublic() | ||
| { | ||
| return getTotalForce(); | ||
| } | ||
|
|
||
| inline void addReductionEnergyPublic(int reductionTag, BigReal energy) | ||
| { | ||
| addReductionEnergy(reductionTag, energy); | ||
| } | ||
|
|
||
| inline Lattice const *get_lattice() const | ||
| { | ||
| return lattice; | ||
| } | ||
|
|
||
| protected: | ||
|
|
||
| std::unique_ptr<colvarproxy_namd> proxy; | ||
| }; | ||
|
|
||
|
|
||
| namespace { | ||
| // Constants used for profiling CkLoop calls | ||
| constexpr int32_t GLOBAL_MASTER_CKLOOP_CALC_ITEM = 2000; | ||
| constexpr int32_t GLOBAL_MASTER_CKLOOP_CALC_BIASES = 2001; | ||
| constexpr int32_t GLOBAL_MASTER_CKLOOP_CALC_SCRIPTED_BIASES = 2002; | ||
| } | ||
|
|
||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.