Guys,
I'm having trouble compiling OpenMM using the c++11 standard, on OSX 10.10. This appears by default not to be specified, but I need this for compatibility with simbody and molmodel, which apparently need to be built to this standard (I get compile errors if I try to build molmodel without -std=c++11).
The error is in one of the tests (output copied ), but even if I turn off BUILD_TESTING, it still tries to compile them. So, just figuring out how to turn off the tests would be helpful. If I build openmm without c++11, I get a seg fault when I then compile MMB. Also in openmm without c++11, the tests fail:
samuel-floress-macbook-pro-3:build Sam$ make test
Running tests...
Test project /Users/Sam/github/openmm/build
Start 1: TestOpenCLAndersenThermostatSingle
1/171 Test #1: TestOpenCLAndersenThermostatSingle ..............***Exception: Other 0.12 sec
Start 2: TestOpenCLAndersenThermostatMixed
2/171 Test #2: TestOpenCLAndersenThermostatMixed ...............***Exception: Other 0.08 sec
I believe I am working from the latest source:
samuel-floress-macbook-pro-3:build Sam$ git log ..
commit bca01957a298710ef9b9397ba66e934d6324572a
Merge: 5f5dafe 9a167d0
Author: peastman <peter.eastman@gmail.com>
Date: Fri Jun 26 14:44:17 2015 -0700
Merge pull request #993 from peastman/amoebaparams
Removed inappropriate error checks that forced all AMOEBA parameters to be in a single file
At any rate my main concern is getting openmm to compile with -std=c++11 . Can you provide any suggestions?
Many thanks
Sam
Linking CXX executable ../../../TestOpenCLSort
[ 97%] Built target TestOpenCLSort
[ 97%] Building CXX object plugins/drude/platforms/opencl/CMakeFiles/OpenMMDrudeOpenCL.dir/src/OpenCLDrudeKernelFactory.cpp.o
/Users/Sam/github/openmm/platforms/opencl/tests/TestOpenCLVirtualSites.cpp:83:9: error: expected variable name or 'this' in lambda capture
list
ASSERT_EQUAL_VEC(Vec3(), state.getPositions()[0], 0.0);
^
/Users/Sam/github/openmm/openmmapi/include/openmm/internal/AssertionUtilities.h:57:174: note: expanded from macro 'ASSERT_EQUAL_VEC'
..._norm_ = std::sqrt((expected).dot(expected)); double _scale_ = _norm_ > 1.0 ? _norm_ : 1.0; if ((std::abs(((expected)[0])-((found)[0])...
^
/Users/Sam/github/openmm/platforms/opencl/tests/TestOpenCLVirtualSites.cpp:83:9: error: expected variable name or 'this' in lambda capture
list
/Users/Sam/github/openmm/openmmapi/include/openmm/internal/AssertionUtilities.h:57:234: note: expanded from macro 'ASSERT_EQUAL_VEC'
...= _norm_ > 1.0 ? _norm_ : 1.0; if ((std::abs(((expected)[0])-((found)[0]))/_scale_ > (tol)) || (std::abs(((expected)[1])-((found)[1]))...
^
/Users/Sam/github/openmm/platforms/opencl/tests/TestOpenCLVirtualSites.cpp:83:9: error: expected variable name or 'this' in lambda capture
list
/Users/Sam/github/openmm/openmmapi/include/openmm/internal/AssertionUtilities.h:57:294: note: expanded from macro 'ASSERT_EQUAL_VEC'
...> (tol)) || (std::abs(((expected)[1])-((found)[1]))/_scale_ > (tol)) || (std::abs(((expected)[2])-((found)[2]))/_scale_ > (tol))) {std...
^
/Users/Sam/github/openmm/platforms/opencl/tests/TestOpenCLVirtualSites.cpp:587:2: error: expected '}'
}
^
/Users/Sam/github/openmm/platforms/opencl/tests/TestOpenCLVirtualSites.cpp:83:9: note: to match this '{'
ASSERT_EQUAL_VEC(Vec3(), state.getPositions()[0], 0.0);
^
/Users/Sam/github/openmm/openmmapi/include/openmm/internal/AssertionUtilities.h:57:48: note: expanded from macro 'ASSERT_EQUAL_VEC'
#define ASSERT_EQUAL_VEC(expected, found, tol) {double _norm_ = std::sqrt((expected).dot(expected)); double _scale_ = _norm_ > 1.0 ? _...
^
/Users/Sam/github/openmm/platforms/opencl/tests/TestOpenCLVirtualSites.cpp:587:2: error: expected '}'
}
^
/Users/Sam/github/openmm/platforms/opencl/tests/TestOpenCLVirtualSites.cpp:80:36: note: to match this '{'
for (int i = 0; i < 1000; ++i) {
^
/Users/Sam/github/openmm/platforms/opencl/tests/TestOpenCLVirtualSites.cpp:587:2: error: expected '}'
}
^
/Users/Sam/github/openmm/platforms/opencl/tests/TestOpenCLVirtualSites.cpp:58:29: note: to match this '{'
void testMasslessParticle() {
^
6 errors generated.
make[2]: *** [platforms/opencl/tests/CMakeFiles/TestOpenCLVirtualSites.dir/TestOpenCLVirtualSites.cpp.o] Error 1
make[1]: *** [platforms/opencl/tests/CMakeFiles/TestOpenCLVirtualSites.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 97%] Building CXX object plugins/rpmd/platforms/opencl/CMakeFiles/OpenMMRPMDOpenCL.dir/src/OpenCLRpmdKernelSources.cpp.o
compiling openmm with c++11 on OSX
- Peter Eastman
- Posts: 2564
- Joined: Thu Aug 09, 2007 1:25 pm
Re: compiling openmm with c++11 on OSX
I haven't done anything with C++11, but I thought it was supposed to be fully backward compatible. It looks like that isn't the case. This was ordinary, valid C++ code that it's now trying to interpret in a different way.
I don't know what the solution is, but if you can figure it out I'd love to know. Eventually we'll want to start supporting C++11, though I don't know how soon that will be. The requirement for compatibility with Python on Windows has forced us to keep compiling with VS2010, which doesn't support C++11.
Peter
I don't know what the solution is, but if you can figure it out I'd love to know. Eventually we'll want to start supporting C++11, though I don't know how soon that will be. The requirement for compatibility with Python on Windows has forced us to keep compiling with VS2010, which doesn't support C++11.
Peter
- Samuel Flores
- Posts: 189
- Joined: Mon Apr 30, 2007 1:06 pm
Re: compiling openmm with c++11 on OSX
Well, Simbody is now hard wired to compile to c++11. Of course, one can edit the CMakeLists.txt and turn that off. However I'm having problems with molmodel when I do that. All in all, it seems a good idea to keep up with standards, especially one that is now four years old.I think c++11 is a bit more strict about enforcing rules, for example, it seems to be more hardcore about demanding one disambiguate functions that have the same name and signature in two different namespaces, I get the impression that previously it would just use the first one it found. In any case it doesn't seem like a bad thing to comply with c++11. It also seems reasonable to be compatible with other Simbios products like Simbody. Why not compile to c++11 for the OSX (and probably Linux) releases? I believe that's what Simbody does.
In any case I downloaded the 6.2.0 OpenMM distribution package and issued:
export MACOSX_DEPLOYMENT_TARGET=10.10
sudo ./install.sh
.. and got no build errors. However the test failed:
samuel-floress-macbook-pro-3:OpenMM-6.2.0-Mac Sam$ python -m simtk.testInstallation
dyld: lazy symbol binding failed: Symbol not found: __ZN6OpenMM8Platform21registerKernelFactoryERKSsPNS_13KernelFactoryE
Referenced from: /usr/local/openmm/lib/plugins/libOpenMMOpenCL_d.dylib
Expected in: /usr/local/openmm/lib/libOpenMM_d.dylib
dyld: Symbol not found: __ZN6OpenMM8Platform21registerKernelFactoryERKSsPNS_13KernelFactoryE
Referenced from: /usr/local/openmm/lib/plugins/libOpenMMOpenCL_d.dylib
Expected in: /usr/local/openmm/lib/libOpenMM_d.dylib
Trace/BPT trap: 5
I also read that the OpenCL platform is not supported on OSX 10.10. I would be happy with the Reference platform, but I was not asked to specify this, and see no way to do so. Can you tell me how to get the reference platform?
I also tried building from source, and just setting CMAKE_CXX_FLAGS -std-c++11 in cmake, as mentioned. It seems easy enough for you to try this on yours, and tell me why it doesn't work. You are the OpenMM expert, after all. This should take you about a minute.
Many thanks
Sam
In any case I downloaded the 6.2.0 OpenMM distribution package and issued:
export MACOSX_DEPLOYMENT_TARGET=10.10
sudo ./install.sh
.. and got no build errors. However the test failed:
samuel-floress-macbook-pro-3:OpenMM-6.2.0-Mac Sam$ python -m simtk.testInstallation
dyld: lazy symbol binding failed: Symbol not found: __ZN6OpenMM8Platform21registerKernelFactoryERKSsPNS_13KernelFactoryE
Referenced from: /usr/local/openmm/lib/plugins/libOpenMMOpenCL_d.dylib
Expected in: /usr/local/openmm/lib/libOpenMM_d.dylib
dyld: Symbol not found: __ZN6OpenMM8Platform21registerKernelFactoryERKSsPNS_13KernelFactoryE
Referenced from: /usr/local/openmm/lib/plugins/libOpenMMOpenCL_d.dylib
Expected in: /usr/local/openmm/lib/libOpenMM_d.dylib
Trace/BPT trap: 5
I also read that the OpenCL platform is not supported on OSX 10.10. I would be happy with the Reference platform, but I was not asked to specify this, and see no way to do so. Can you tell me how to get the reference platform?
I also tried building from source, and just setting CMAKE_CXX_FLAGS -std-c++11 in cmake, as mentioned. It seems easy enough for you to try this on yours, and tell me why it doesn't work. You are the OpenMM expert, after all. This should take you about a minute.
Many thanks
Sam
- Peter Eastman
- Posts: 2564
- Joined: Thu Aug 09, 2007 1:25 pm
Re: compiling openmm with c++11 on OSX
You have an old version of the code. We stopped appending _d to library names a long time ago. Try updating to the latest version.
The next version of OpenMM (to be released very very soon now) will support OpenCL on OS X 10.10.3 and later.
Peter
The next version of OpenMM (to be released very very soon now) will support OpenCL on OS X 10.10.3 and later.
Peter
- Peter Eastman
- Posts: 2564
- Joined: Thu Aug 09, 2007 1:25 pm
Re: compiling openmm with c++11 on OSX
I've been discussing the C++11 issue with Sherm, and he thinks it's a bug in the compiler. It should be easy to workaround though. In the file AssertionUtilities.h, try switching to this definition for ASSERT_EQUAL_VEC:
Peter
Code: Select all
#define ASSERT_EQUAL_VEC(expected, found, tol) {Vec3 _v1_ = (expected), _v2_ = (found); double _norm_ = std::sqrt(_v1_.dot(_v1_)); double _scale_ = _norm_ > 1.0 ? _norm_ : 1.0; if ((std::abs((_v1_[0])-(_v2_[0]))/_scale_ > (tol)) || (std::abs((_v1_[1])-(_v2_[1]))/_scale_ > (tol)) || (std::abs((_v1_[2])-(_v2_[2]))/_scale_ > (tol))) {std::stringstream details; details << " Expected "<<_v1_<<", found "<<_v2_; throwException(__FILE__, __LINE__, details.str());}};
- Samuel Flores
- Posts: 189
- Joined: Mon Apr 30, 2007 1:06 pm
Re: compiling openmm with c++11 on OSX
Well I deleted two tests, TestOpenCLVirtualSites.cpp, and TestOpenCLRpmd.cpp. Then I was able to compile just fine. c++11 is a little more strict about namespaces somehow, so I had to fix an issue along those lines in MMB.
I found I didn't really need to copy ResidueInfo objects, except out of vanity. Now I just create new ones when I need them, and that way I could use the copy constructor rather than assignment operator.
I am able to compile and run MMB in Debug mode on OSX perfectly now. However I still get a seg fault in Release mode. I don't know if this is an openmm issue, I suspect it's simbody or molmodel.
I would like to try your workaround, but right now I just want to get MMB to compile in Release mode, and it's almost 24:00, a bit late for the dad of a toddler.
Thanks for your help
Sam
I found I didn't really need to copy ResidueInfo objects, except out of vanity. Now I just create new ones when I need them, and that way I could use the copy constructor rather than assignment operator.
I am able to compile and run MMB in Debug mode on OSX perfectly now. However I still get a seg fault in Release mode. I don't know if this is an openmm issue, I suspect it's simbody or molmodel.
I would like to try your workaround, but right now I just want to get MMB to compile in Release mode, and it's almost 24:00, a bit late for the dad of a toddler.
Thanks for your help
Sam