-
Notifications
You must be signed in to change notification settings - Fork 141
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
v4-CMake #430
base: v4
Are you sure you want to change the base?
v4-CMake #430
Conversation
Wew sounds good! I'm happy to cop the Windows testing. I'll setup CI too once the build is runnable (and probably a linter, since I've already slopped in some spaghetti). I agree it's clumsy/overbearing/amateurish to build the user's executable, though I suspect a good chunk of QuEST's user base have physics backgrounds and lack the requisite skills to make their own build, or integrate QuEST into a bigger stack. I want to make compilation as easy as possible for that group somehow. I'm open to better ideas! |
…threading enabled and disabled
Can confirm that I can build and run a (very simple) example code using the available new API with and without multithreading enabled (though it doesn't deploy with MT at one qubit...), so now I can get started on the fun stuff. Notes:
|
Bump to CMake 3.14 incoming for policy CMP0082. |
Ahh I'm sorry for the rebasing and conflicting the PR! I hadn't realised the source files were being modified too. I'm intending to rename some files ( Btw are the relative path includes changed in b87b7f5 essential for CMake building? I was following Kolpackov's project structure (but preserving // API
#include "quest/include/modes.h"
#include "quest/include/environment.h"
#include "quest/include/qureg.h"
#include "quest/include/structures.h"
// core
#include "quest/src/core/errors.hpp"
#include "quest/src/core/bitwise.hpp"
#include "quest/src/core/memory.hpp"
#include "quest/src/core/utilities.hpp"
#include "quest/src/comm/comm_config.hpp"
#include "quest/src/cpu/cpu_config.hpp"
#include "quest/src/gpu/gpu_config.hpp"
// external library
#include <iostream>
#include <cstdlib>
#include <vector>
#include <map> It was also consistent in that all paths were relative to the directory containing If I understand right, with the new includes, some are relative to #include "types.h" and the rest are relative to the source file location (e.g. this in #include "../core/errors.hpp" This seems less elegant and consistent - is it necessary for compilation, or offer another benefit I've missed? |
No problem! Any conflicts should be pretty trivial to resolve, as I wouldn't expect to touch anything more than includes, so happy to just keep merging as and when. Apologies, I'd assumed it was just an artifact of the make build 😅 Advantages of the way I've done it:
However, through CMake, all things are possible 😉
So very happy to change it all back, it's just a find/replace job! It's your project, so let me know which you'd prefer. |
Library renaming is now available -- the user can either just provide a custom string to produce GPU acceleration and MPI distribution are now also available, but there are two issues:
|
which progress toward making the v3 deprecated unit tests run without error. We also relax exclusivity of multithreading and GPU-acceleration, which was pointless and annoying.
This is a scratch commit and should not be merged into non-scratch branches. The final v3 tests should be committed by first git moving the old tests into v3 subfolder, and only in a subsequent commit should in-file changes be committed (preserving git blame/dif). It is possible too that we will wish to re-use `test_utilities` for the v4 tests. This commit also includes a hacky unix `compile.sh` script for compiling v3 tests
Hi @TysonRayJones! Hope you're well, and have found some time to enjoy a holiday in amongst the development work... I've marked this as ready for review now, as I think what we have is enough to be useful for your planned 'developer' release, but naturally it's your call whether you'd like to merge now or later. Note the TODOs listed below. I've added docs/cmake.md to list the new CMake options. I've got a paper to review, PhD thesis corrections to approve, and I'm getting married next week, so I probably won't be looking at this again before I'm back in the office 😅 Happy new year! 🎊 CMake TODO:
|
Wew amazing! Happy holidays to you, and a massive congratulations on your wedding!!! 🎉 🎉 I've got two items (🤞) left on my backlog before I'll start using your CMake build and test it on as many platforms as I can access. To your dot points:
Thanks very much for all your fantastic work so far! 🙌 |
Howdy! I've finally had time to use the CMake build. I get it to compile by...
Of course I'll fix these shenanigans! Disabling the tests, I can indeed compile (on my Macbook) with both The tests do not compile (except in clang 15) due to So, let's just give up on cross-platform supporting the v3 unit tests, which seek only to test the deprecation API anyway. We'll instead target new, v4, C++17 compatible unit tests, which I'll prepare. The deprecation tests can run on old clang offline, since they're inessential ¯\(ツ)/¯ Some other notes:
I channeled my |
Thanks for taking the time to give it a whirl! Glad it's mostly working on someone else's computer. It's a shame the deprecated API won't work, although reworking the tests probably is better in the long run. To your notes:
It is weird (and a shame) that _Generic support was dropped 😞 I'm back in the office now, so I'll carve out some time around reviewing QCTiP submissions to test on our AMD GPU nodes and look into CuQuantum (finally!). |
I've scaffolded the v4 unit tests here (commit) which is compiling on all my tested systems with the hacky bash script. No testing file needs an MPI compiler nor special preprocessors now 🎉 The tests temporarily use the super old Catch2 single-header, which we can trivially change to modern Catch2 when supported by the CMake build (replacing these stubs). I'll hold off on developing the new tests until the CMake build is working, because use of the bash script is nausea-inducing. Should we try to merge your build into v4 (I suppose from a fresh fork)? Totally fine if unpolished; e.g. cuStateVec or Windows aren't working, which we can sort out in another commit (and defer HIP to v4.1 if necessary). I want to experiment with using CMake to activate integration tests based on what backends got compiled (without spilling more preprocessors everywhere) 🙌 (so feel free to completely ignore the I've been recruited by Zoë to similarly review some QCTiP submissions - truly it is the universal struggle ehehe |
Hi Tyson, Nice! I've put together a CMake build for the new test structure for you. As ever it runs fine on my machine, but let me know if you encounter any issues! Would be happy to merge now and either leave this PR open, or I can open a new one to resolve remaining CMake issues. Managed to get through 3 papers while we had an electrician in earlier, only 10 to go... |
Oh! I brainfarted hard! The deprecation header contains only a single invocation of |
Compiling and (well, non-distributed CPU) passing here with g++ 11 on Ubuntu 🎉 |
Wew brilliant! There are some minor edits I'd nominate which I'll point out using the Github review system. Up to you how to continue edits after the squash-merge!
Joy :) I'll be procrastinating mine right up until Friday it seems eheuheu |
After a bit of cajoling (i.e. making INCLUDE_DEPRECATED_FUNCTIONS a private compiler flag for the library, and realising that test_utilities were actually needed 😅), I now have a working CMake build of the deprecated tests too 🥳 I need to tidy it up, and probably make all compiler flags library private because that's probably good practise anyway (NOTE TO SELF: Add something to documentation so that users know that any QuEST flags are not inherited by their application), but should be able to push it up later this afternoon! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wew lookin good! Some minor changes proposed
# author : Jacob Wilkins | ||
# author : Balint Koczor (Windows compatibility) | ||
# author : Tyson Jones (testing) | ||
# author : Oliver Thomson Brown (v4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to move your name to the top! I suppose noting v4
is unnecessary since it will likely stay the build for future versions. E.g.
# author : Oliver Thomson Brown
# contributions to previous builds from:
# author : Ania Brown
# author : Jacob Wilkins
# author : Balint Koczor (Windows compatibility)
# author : Tyson Jones (testing)
Because this comment doesn't get parsed by doxygen, you can use any format you wish to make it prettier, e.g.
# authors :
# - Oliver Thomson Brown
#
# contributions to previous builds from:
# - Ania Brown
# - Jacob Wilkins
# - Balint Koczor
# - Tyson Jones
"Whether the example programs will be built alongside the QuEST library. Turned ON by default." | ||
ON | ||
) | ||
message(STATUS "Examples are turned ${BUILD_EXAMPLES}. Set BUILD_EXAMPLES to modify.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have strong opinions on whether compiling of examples and tests should be ON
by default? I like the default compilation (= the user's first experience) to compile the minimum possible, so that:
- the compilation is faster
- the console output is readable
- the chance for exotic platform-specific warnings or compilation errors is reduced
- the user has a stronger understanding of what's going on
I'd propose the default compilation to build a single C++ example file, which we could place in like examples/tutorials/main.cpp
, and which compiles to put executable main
in the root dir. A placeholder for now could be
#include "quest.h"
int main() {
initQuESTEnv();
reportQuESTEnv();
Qureg qureg = createQureg(20);
reportQuregParams(qureg);
initPlusState(qureg);
reportQureg(qureg);
destroyQureg(qureg);
finalizeQuESTEnv();
}
What'cha think?
| `LIB_NAME` | (`QuEST`), String | The QuEST library will be named `lib${LIB_NAME}.so`. Can be used to differentiate multiple versions of QuEST which have been compiled. | | ||
| `VERBOSE_LIB_NAME` | (`OFF`), `ON` | When turned on `LIB_NAME` will be modified according to the other configuration options chosen. For example compiling QuEST with multithreading, distribution, and double precision with `VERBOSE_LIB_NAME` turned on creates `libQuEST-fp2+mt+mpi.so`. | | ||
| `FLOAT_PRECISION` | (`2`), `1`, `4` | Determines which floating-point precision QuEST will use: double, single, or quad. *Note: Quad precision is not supported when also compiling for GPU.* | | ||
| `BUILD_EXAMPLES` | (`ON`), `OFF` | Determines whether the example programs will be built alongside QuEST. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(just noting these doc'd default options would need to be change if we do end up changing the build defaults)
| `ENABLE_CUDA` | (`OFF`), `ON` | Determines whether QuEST will be built with support for NVIDIA GPU acceleration. If turned on, `CMAKE_CUDA_ARCHITECTURES` should probably also be set. | | ||
| `ENABLE_CUQUANTUM` | (`OFF`), `ON` | Determines whether QuEST will make use of the NVIDIA CuQuantum library. Cannot be turned on if `ENABLE_CUDA` is off. | | ||
| `ENABLE_HIP` | (`OFF`), `ON` | Determines whether QuEST will be built with support for AMD GPU acceleration. If turned on, `CMAKE_HIP_ARCHITECTURES` should probably also be set. | | ||
| `ENABLE_DEPRECATION` | (`OFF`), `ON` | Determines whether QuEST will be built with support for the deprecated (v3) API. *Note: will generate compiler warnings, and not supported by GCC.` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENABLE_DEPRECATION
might not be super clear - one could imagine it "enables deprecation of old functions, switching to user the new ones" so ergo has the inverse of the intended meaning.
How about ENABLE_DEPRECATED_API
? That makes it more explicit too that only the interface is changing, while the backend code is unchanged.
| `CMAKE_CXX_COMPILER` | The C++ compiler that will be used to compile QuEST. | [CMAKE_\<LANG\>_COMPILER](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html) | | ||
| `CMAKE_C_COMPILER` | The C compiler that will be used to compile QuEST. | [CMAKE_\<LANG\>_COMPILER](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html) | | ||
| `CMAKE_INSTALL_PREFIX` | The directory to which QuEST will be installed when `make install` is invoked. A standard GNU directory structure (lib, bin, include) will be used inside the prefix directory. | [CMAKE_INSTALL_PREFIX](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html) <br> [GNUInstallDirs](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html) | | ||
| `CMAKE_CUDA_ARCHITECTURES` | Used to set the value of `arch` when compiling for NVIDIA GPU. | [CMAKE_CUDA_ARCHITECTURES](https://cmake.org/cmake/help/latest/variable/CMAKE_CUDA_ARCHITECTURES.html) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding:
This is also known as the target GPU's "compute capability" and can be discovered [here](https://developer.nvidia.com/cuda-gpus)
@@ -120,6 +120,11 @@ TEST_CASE( "calcDensityInnerProduct", "[calculations]" ) { | |||
* @author Tyson Jones | |||
*/ | |||
TEST_CASE( "calcExpecDiagonalOp", "[calculations]" ) { | |||
|
|||
// TODO: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment/diff is no longer true/needed, banish it!
@@ -480,6 +485,11 @@ TEST_CASE( "calcExpecPauliProd", "[calculations]" ) { | |||
* @author Tyson Jones | |||
*/ | |||
TEST_CASE( "calcExpecPauliSum", "[calculations]" ) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to the void ye scurvy outdated comment/call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should stay as main.cpp
since I've dropped the test_
prefix convention of the v3 tests for the v4 ones. Happy to debate this though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file not needed! All utils are in utils/
now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file not needed! All utils are in utils/
now
OH we were working at the same time heh, apologies if the review is not outdated!! Also I've only just discovered I had missed your comments from 13th Sept since Github hid them behind the (imo unacceptably innocuous) "conversations hidden" button, apologies for not responding!! |
Hi @TysonRayJones,
Creating a PR to discuss and critique my work on the new build system :) I'll use this as a place to keep notes and thoughts too.
I've been through and identified the following open issues which I'll try to address, as well as my own biases:
Notes: