{"action":"created","issue":{"url":"https://api.github.com/repos/psi4/psi4/issues/537","repository_url":"https://api.github.com/repos/psi4/psi4","labels_url":"https://api.github.com/repos/psi4/psi4/issues/537/labels{/name}","comments_url":"https://api.github.com/repos/psi4/psi4/issues/537/comments","events_url":"https://api.github.com/repos/psi4/psi4/issues/537/events","html_url":"https://github.com/psi4/psi4/issues/537","id":192973265,"number":537,"title":"FindLapack","user":{"login":"loriab","id":2314730,"avatar_url":"https://avatars.githubusercontent.com/u/2314730?v=3","gravatar_id":"","url":"https://api.github.com/users/loriab","html_url":"https://github.com/loriab","followers_url":"https://api.github.com/users/loriab/followers","following_url":"https://api.github.com/users/loriab/following{/other_user}","gists_url":"https://api.github.com/users/loriab/gists{/gist_id}","starred_url":"https://api.github.com/users/loriab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loriab/subscriptions","organizations_url":"https://api.github.com/users/loriab/orgs","repos_url":"https://api.github.com/users/loriab/repos","events_url":"https://api.github.com/users/loriab/events{/privacy}","received_events_url":"https://api.github.com/users/loriab/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-01T21:54:33Z","updated_at":"2016-12-02T14:40:14Z","closed_at":null,"body":"A number of issues have come up and been bandaid-ed over regarding detecting math libs, propagating math libs, preloading math libs, statically linking math libs, etc. This issue is mainly an FYI to all and a query to @robertodr and @bast to make sure we're not trying to solve things that they've already done.\r\n\r\n#### Current State\r\n* psi4 uses Radovan Bast's detection scheme circa 2014 or so\r\n* said scheme finds MKL just fine- usually the shared lib versions and always the layered scheme (https://software.intel.com/en-us/node/528508) rather than `libmkl_rt.so`\r\n* said scheme just uses Accelerate libs for Mac, again just fine\r\n* said scheme can find ACML after heavy hinting\r\n* there is a FindLapack CMake module, but either we haven't tried hard enough or it can't find ACML. It also will only find shared MKL libs\r\n\r\n#### Complications and Bandaids\r\n* conda pkg building needs _static_ mkl libs back from math detection (except for a couple). We've [patched this within the Bast math detection](https://github.com/psi4/psi4/blob/master/cmake/math/MathLibsFunctions.cmake#L59-L73) if triggered by a cmake var.\r\n* MKL in general needs `-Wl,--start-group` and `-Wl,--end-group` passed to the linker around the math libs to resolve circular dependencies. Supposedly this can be conveyed to cmake directly with https://cmake.org/cmake/help/v3.0/prop_tgt/LINK_INTERFACE_MULTIPLICITY.html . Problem with the start/end-group is that cmake will optimize them out of position if more than one set are included in a link line formed from cmake vars. We patched this in Psi4 by [combining blas and lapack targets](https://github.com/psi4/psi4/blob/master/cmake/math/ConfigMath.cmake#L111) so that one set can sandwich both. Supposedly if these come into the link line through a target rather than a cmake var, then cmake won't mess with them.\r\n* Even though psi4 builds and links fine, we're having to advise more and more people to LD_PRELOAD various mkl libraries or mkl_rt.so. part of the complication could be conda pkgs (even numpy) that are already in env and complicating the link loader's tasks. But we really shouldn't be telling ppl about preloading, which is bad practice for non-dire situations. @ryanmrichard [put in something](https://github.com/psi4/psi4/pull/513/files#diff-bb0d8c2ec987bfc58b4a943e453ea132L147) to preferentially detect the runtime lib as a bandaid to this.\r\n* People for whom Bast math detection works fine but cmake FindLapack doesn't (namely, @psi-rking and [this fellow](http://forum.psicode.org/t/problem-with-building-from-source-according-to-cmakelists-txt/352/10) are having problems with libefp and CheMPS2 because different (or no) math libs are being inserted from those dependencies. I can forward the Bast libs to those external projects, but that'll cause some complications with the exported targets. I can fix that, but I fear that cmake will optimize away my start/end-groups again if they appear more than once.\r\n\r\nI am _not_ working on this right now, but I will have to, at a minimum, apply more bandaids soon, so I wanted to know from @robertodr and @bast if they're any solutions from the past two years. At a maximum, I'm tempted to default to `mkl_rt`, have ConfigMath export a target, and train libefp and CheMPS2 to detect it in preference to FindLapck. This is the state of affairs."},"comment":{"url":"https://api.github.com/repos/psi4/psi4/issues/comments/264468397","html_url":"https://github.com/psi4/psi4/issues/537#issuecomment-264468397","issue_url":"https://api.github.com/repos/psi4/psi4/issues/537","id":264468397,"user":{"login":"loriab","id":2314730,"avatar_url":"https://avatars.githubusercontent.com/u/2314730?v=3","gravatar_id":"","url":"https://api.github.com/users/loriab","html_url":"https://github.com/loriab","followers_url":"https://api.github.com/users/loriab/followers","following_url":"https://api.github.com/users/loriab/following{/other_user}","gists_url":"https://api.github.com/users/loriab/gists{/gist_id}","starred_url":"https://api.github.com/users/loriab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loriab/subscriptions","organizations_url":"https://api.github.com/users/loriab/orgs","repos_url":"https://api.github.com/users/loriab/repos","events_url":"https://api.github.com/users/loriab/events{/privacy}","received_events_url":"https://api.github.com/users/loriab/received_events","type":"User","site_admin":false},"created_at":"2016-12-02T14:40:14Z","updated_at":"2016-12-02T14:40:14Z","body":"I'd like to team up on this, but Psi4 is trying to get back into the science business from having been in the infrastructure business for much of the past year, so our rewriting energies are depleted. On the monolithic vs. modular, on the whole I agree with preferring the latter, but I'm thinking that math detection is also going to have to be installed alongside packages so system dependencies can be detected from installed projects, and a single alternate file like [FindPythonLibsNew](https://github.com/pybind/pybind11/blob/master/tools/FindPythonLibsNew.cmake) (originally from numpy, i think) is more palatable than installing half-a-dozen+ files.\r\n\r\nSo I'm guessing that on the core math, we'll probably keep applying bandaids but will be glad to serve as a test bed in developing needed specs and solutions."}}
{"actor":{"display_login":"loriab"}}