Skip to content
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

Cmake build #97

Merged
merged 105 commits into from
May 9, 2019
Merged

Cmake build #97

merged 105 commits into from
May 9, 2019

Conversation

papadop
Copy link
Contributor

@papadop papadop commented Feb 20, 2019

Here is a cmake build for blitz. Minimally tested on linux (but I have in the past compiled on MacOS and Windows, so I have good hopes). There are probably some polishing to be done (notably make test which does not build dependencies and the hao-he benchmark which does not compile due to the removal of vector.h), but most of the functionality is there.

To use it:

  1. Go to a new directory.
  2. cmake path-to-the-source-directory
  3. make (or make lib)
  4. make check-{testsuite,benchmarks,examples}

This PR also contains a trivial correction for iter.cpp (elapsedSeconds->elapsed) which was needed to make teh test pass. check-testsuite and check-examples pass. check-benchmarks currently fails due to the hao-he test. I do not know whether we have to correct the test or remove it. So I left it untouched for now.

@papadop papadop mentioned this pull request Feb 20, 2019
@@ -19,7 +19,7 @@ int main() {
}
timer.stop();
double flops = 10.0*512*512*512*2;
double seconds = timer.elapsedSeconds();
double seconds = timer.elapsed();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for this? (I'm assuming that elapsed() is more standard and more likely to work on modern compilers?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well my compiler g++ 8.2.1 complained. I didi it mechanically to allow the test to compile. I must say I was even thinking it was a change internal to blitz (I though it had its own timer class)...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.... looks like it was just a bug, and nobody had bothered to compile benchmarks/iter.cpp, which depends on Blitz's timer.h.

Could we ditch timer.h and use std::chrono from C++11? In general, anything that we can get rid of in favor of now-standard C++ features is good (as long as it doesn't change the API; that is for later).

https://en.cppreference.com/w/cpp/chrono

As I said before... I don't care to maintain pre-C++11 compatibility going forward. We can go ahead and change the code along with the build system, as long as it doesn't change the API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 1
    See my comment from this morning, I even believe that we can suppress the library (or at least most of its required uses for non debugging purposes) by using constexpr... Not sure whether suppressing the need for the library counts as an API change (people can always link with a non-necessary library)...

@citibeth
Copy link
Contributor

Wow... that's quite a tour de force. But now I'm getting cold feet because it's 112 new files. I was hoping for something simpler. (I did a CMake build for Blitz in a proprietary setting for Windows, using far fewer files. Unfortunately, I cannot access or share that build. Then again, the build I made was a lot more minimal, just enough to get it working on Windows without re-generating code that someone else had already generated).

Overall, the mantra should be simplify, simplify. SOme things I can see right now I would want to remove:

  1. Remove anything having to do with Pkgconfig. That is Autotools-related stuff, and it only works if everyone uses it --- which everyone never did.

  2. Building the doc/ directory should be optional. Doc building requires a lot of extra build dependencies, and people should be able to build without first installing all that stuff. Most people will just use pre-built docs online. (This is true for almost any package that comes with docs).

  3. Put all options in the top-level CMakeLists.txt file. That way it's easy to see what options this build has. (eg: FORTRAN_BENCHMARKS in in benchmarks/CMakeLists.txt)

  4. Similarly, put all find_***() stuff in the top-level, so we can easily see what the dependencies are.

  5. Remove commented-out Autotools code.

  6. Remove bin/CMakeLists.txt, and the line that includes it.

  7. The original Autotools build checked a zillion C++ features and configured accordingly. I would like to consider whether some of those checks are no longer required, for (reasonably) modern compilers. It is now 15+ years since Blitz++ originally was released, and plenty has changed. I don't care to support ancient compilers going forward; and people who DO use those compilers can always use the existing Autotools build. If we can remove checks, then that is super. (Later, we can remove the corresponding #ifdefs) For example... we can probably get rid of BZ_HAVE_STRINGS_H and BZ_HAVE_STRING_H. And a lot more...

  8. Can we have a way to put the Blitz version number into the config.h file, coming from the top-level CMakeLists.txt file?

  9. Is it possible to remove compiler-specific configuration (BlitzconfigFileName.cmake)? Configurations for specific compilers or OS's have fallen out of favor; instead, feature-based configuration options (like those discussed above) are preferred. In any case, can we remove support for compilers that no longer exist?

  10. CheckCXXFeature: Again, let's get rid of checks for things that are now standardized. For example, HAVE_EXCEPTIONS, HAVE_NAMESPACES, HAVE_RTTI, HAVE_MEMBER_CONSTANTS, HAVE_OLD_FOR_SCOPING, HAVE_EXPLICIT, HAVE_BOOL,... Most of these (90%?) we can get rid of because they are now standard in C++. I would say, we should require C++11 (even though the current Blitz API is not C++11 compliant; I'm still not interested in having this CMake build work on any pre-C++11 compilers).

  11. Let's try to put things in the file in which they are used. For example, CHECK_ALL_CXX_FEATURES is only used once, and that's in blitz/CMakeLists.txt. The macro should therefore be defined in that file, rather than in cmake/CheckCXXFeature.cmake. In general, any macro that's used in only one file should be inlined into that file.

  12. cmake/Win32Compat.cmake: I'm happy not supporting CMake 2.6 any more. I'd be fine with requiring at least CMake 3.0. So we can get rid of extra code in the build required to support old CMake versions.

  13. cmake/XXXConfig.cmake.in: Is there any way to avoid the situation in which the CMake build auto-generates part of itself? If we are to keep this kind of complexity, I would want a good reason.

  14. Remove commented-out Autotools code from manual/CMakeLists/txt.

@papadop
Copy link
Contributor Author

papadop commented Feb 22, 2019

I just had a fast reading of your comments. I totally agree that it's more complicated than necessary nowadays. Please remember, that this was done years ago, at that time I wanted to provide the same functionality as with autotools. I just spent half an hour to separate this from other changes...

As for the goals of:

  • requiring C++-11
  • removing most of the testing macros (accidentally HAVE_STRING and HAVE_STRINGS might be the ones that we need to keep -- it is C no C++ and related to operating systems IIRC).
  • cleaning up the commented stuff in CMakeLists,txt (this was mostly reminders for eventual TODO work).

I totally agree with that (I would even go further and use #pragma once everywhere instead of include guards...). Then I'm not sure about the best strategy as doing all the work before merging might delay it for a while. I'll try to do some of the simple simplifications quickly, but my time is counted, and I'm unsure I can do all of your requests in the limited time I have. Can we find some middle ground ?

  • I'll make some initial cleanup and some of the suggested changes (the simplest ones).
  • We merge, so that the work remains synchronized with other changes and we can gather comments from users. Eventually, the testers can be extended to include a cmake build.
  • We do the remaining changes incrementally (and actually it would be nice to make them in both autotools and cmake world simultaneously).

I'll try to provide the initial cleanup over the week-end...

@citibeth
Copy link
Contributor

citibeth commented Feb 22, 2019 via email

….am). Made documentation building an option.
@papadop
Copy link
Contributor Author

papadop commented Feb 23, 2019

OK. I think I did the required changes...
By the way, I noticed various things.

  • The manual directory is mostly an old version of the doc directory. There are few differences in codes files though. I think this is confusing. The manual directory should be removed. At the very least, the all the Makefile.am(s) in this hierarchy should be removed.
  • There are bunch of .cvsignore remaining that should be suppressed.... That's an easy cleanup to do.

@youngmit
Copy link

youngmit commented Feb 23, 2019

@papadop Thanks for your work on this; I'm really excited for how much simpler Blitz++ can get once the CMake configuration is ready to replace autotools. I assume that is the plan?

  1. Get a functional CMake configuration that can do everything that the autotools config can do (that we decide we wish to preserve, anyways)
  2. Deprecate/remove the autotools build system
  3. Remove all of the preprocessor macros that guard features that are standard as of C++11
  4. Simplify the CMake config to not have to set all of those macros in the first place. e.g. remove the lion's share of the cxx_tests stuff.

edit: Sorry, used to rst

@slayoo
Copy link
Member

slayoo commented Mar 3, 2019

will try this week to add Travis and Appveyor entries to this PR so the cmake build is tested during CI on Linux, OSX and Windows

@citibeth
Copy link
Contributor

citibeth commented Mar 3, 2019 via email

@emmenlau
Copy link

Hi, just a "thumbs up" for cmake support! Is this currently still being considered? For what its worth, I agree with @citibeth that merging sooner is better than merging later, and iterative improvements can be made when more people use/test the cmake support.

@slayoo
Copy link
Member

slayoo commented Apr 29, 2019

apologies for the delay and thanks for the reminder.
Here's a first try to add CMake build to travis: papadop#2

@papadop
Copy link
Contributor Author

papadop commented May 6, 2019

As for squash, I have no experience with it. I would have say "why" if there was many pure cmake related commits, but given that most commits are only for pure travis debugging, why not...

@papadop
Copy link
Contributor Author

papadop commented May 6, 2019

OK. That leaves the argument of taking time to get some feedback for the cmake build. Not that I want to insist on keeping the autotools build, just to make sure that people can fallback on the most used build in case something goes wrong. Plus I want to take time to verify that no autotools change creeped in after my cmake work (which was a while ago) and is not taken into account with the cmake build.

So let's keep the autotools build for now, and have the following strategy (if everyone agrees with it):

  1. Advertise better the cmake build (to get more feedback).
  2. After a while announce that the cmake way is the preferred one (autotools will be deprecated).
  3. Remove the autotools (and also why not VS) files.

But, we need to agree on the plan and on a calendar !!!

@slayoo
Copy link
Member

slayoo commented May 6, 2019

Also, for the record, I've added an item mentioning your CMake contribution here: https://github.com/blitzpp/blitz/wiki/Credits


if (TEXI2PDF)
if (TEXI2PDF AND PDFLATEX)
Copy link
Contributor

@citibeth citibeth May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is what we need. To be clear, here is how these things SHOULD work: There should be a CMake option (looks like DOCS) that turns on generation of documentation. If that option is not set, then no docs are generated. If the option IS set, then docs will be generated. If the option is set and the required programs for generating docs do not exist (pdflatex and texi2pdf), then CMake should generate an error. It should NOT "automagically" decide whether or not to generate docs depending on whether it can find the required programs. That will cause people unending grief ("I set DOCS but docs weren't generated"), and is against best practices.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, I totally agree. This is a stop gap to allow compilation on travis MacOs which does not have latex and for which I do not know just like that how to install latex (+ the numerous latex packages which are needed). And I do not want to stop all documentation generation on MacOs just because of that (which would have been easier). Hence this hack.
I want to avoid adding too many documentation options, but I also want documentation building to be better tested.

I think we can revisit the problem later and just open an issue asking an enhancement for the time being.

@@ -66,8 +66,10 @@ endif()
find_program(TEXI2PDF texi2pdf
${CYGWIN_INSTALL_PATH}/bin /bin /usr/bin /usr/local/bin /sbin)
mark_as_advanced(TEXI2PDF)
find_program(PDFLATEX pdflatex
${CYGWIN_INSTALL_PATH}/bin /bin /usr/bin /usr/local/bin /sbin)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. But it's not only pdflatex, it's fonts, packages, and problems with doxygen versions which generate bad latex... Believe me it's a can of worms I spent almost two days to dissect... and the public travis interface (without debugging) is a pain...

Copy link
Contributor

@citibeth citibeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid "automagically" configuring a feature depending on whether required dependencies for that feature can be found.

@papadop
Copy link
Contributor Author

papadop commented May 6, 2019

Again, can we have an issue asking for such enhancements... As said above, the problem is much more complicated than only testing for pdflatex (in theory any other latex implementation could work too)...
Note that the autotool build does the same thing, and almost silently cancels some components when tools are missing.... or otherwise I would have not being obliged to add that many packages to the travis build. Look for the missing keyword at configuration time in the builds...

The cmake build already does much more testing than the autotools one. This is a net improvement. Let's already merge that and and create issues (not PR, sorry) for tracking required further enhancements.

@citibeth
Copy link
Contributor

citibeth commented May 6, 2019

@papadop Looks like the easiest way to get docs built will be to figure out the correct dependencies (including versions); and then make a Spack package for it, that will build all the correct versions of Doxygen, etc. At that point I'm happy with a single documentation CMake option that either builds everything or nothing. As long as the Spack build knows how to build all the required dependencies, then we at least have a way to generate docs that doesn't require humans to go to a lot of installation effort just to build docs for one package.

Copy link
Contributor

@citibeth citibeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will leave fixing doc generation for later.

@citibeth
Copy link
Contributor

citibeth commented May 6, 2019

@slayoo If you can check this over and ensure it works with Travis, I'm happy to merge.

Before removing Autotools and Visual Studio, I want to make sure this works on Windows. CMake can generate VS builds. But the CMake files need to be tweaked differently to enable Windows functionality; at least in my experience.

@slayoo
Copy link
Member

slayoo commented May 6, 2019

Re Doxygen, I'm a bit puzzled - IIUC this has nothing to do with the "good old blitz docs" that can be generated into the pdf.

It would be great to have the travis script upload somewhere the generated docs, and it's worth the effort, but of course there is no reason to wait for it in context of this PR - just created a separate issue: #122

@slayoo
Copy link
Member

slayoo commented May 6, 2019

Re Windows: currently (i.e. with the branch behind this PR), CMake generates VS project files on Windows and compilation under VS is executed, no test execution happens, I've added an issue for it: #126

@slayoo
Copy link
Member

slayoo commented May 6, 2019

@citibeth any opinion on merge vs. squash-and-merge?

@lutorm, @pguio any objections against merging it as is and continue development of further enhancements in separate branches?

I'm trying to go through all the comments above and create separate issues for the discussed features, I'll also try out the CMake build on my machine this evening and report back

@citibeth
Copy link
Contributor

citibeth commented May 6, 2019 via email

@slayoo
Copy link
Member

slayoo commented May 6, 2019

@Trophime, @tillea - if I'm not mistaken, you're listed as Blitz++ packagers in Debian. This PR includes initial version of CMake build scripts for Blitz++ intended as a replacement for autotools scripts. All thanks to @papadop!

We're in need of testing it and getting feedback from packagers - if possible, please test and report feedback. thanks!

@slayoo
Copy link
Member

slayoo commented May 7, 2019

I've noticed that repeating "make check-testsuite" repeats compilation, while one would expect only the test execution to repeat (as there was no code change)? Is it intentional?

@emmenlau
Copy link

emmenlau commented May 7, 2019

I've noticed that repeating "make check-testsuite" repeats compilation, while one would expect only the test execution to repeat (as there was no code change)? Is it intentional?

Does this hold true after a second, third and fourth time? I've seen that on complex projects, cmake can take one or two iterations until the cache does not change anymore.

@slayoo
Copy link
Member

slayoo commented May 7, 2019

I've noticed that repeating "make check-testsuite" repeats compilation, while one would expect only the test execution to repeat (as there was no code change)? Is it intentional?

Does this hold true after a second, third and fourth time? I've seen that on complex projects, cmake can take one or two iterations until the cache does not change anymore.

yes, reproduced a few times with various intervals (but just on one machine)

@slayoo
Copy link
Member

slayoo commented May 7, 2019

not sure if that matters, but in the generated install_manifest.txt file, the bzconfig.h entry is listed twice, which results in an error message when uninstalling:

$ sudo xargs rm < install_manifest.txt
rm: cannot remove '/usr/include/blitz/bzconfig.h': No such file or directory

@citibeth
Copy link
Contributor

citibeth commented May 7, 2019 via email

@emmenlau
Copy link

emmenlau commented May 9, 2019

Thanks to @papadop and all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants