Getting cppsim to compile from sources alongside the MindQuantum sources#23
Getting cppsim to compile from sources alongside the MindQuantum sources#23dmikushin wants to merge 82 commits into
Conversation
…to automatic arrays type deduction for v and tmp
…arlier than the use of the parsed arguments
…n native module compilation
…n, based on the KEYWORD option
…ng string of source code. We intentionally keep the generator in Python, in order to let the people to customize it more easily.
… rebuild after resource modification
…generated kernel to the correctness test. Breaking compatibility with the original kernels API, in order to be able to supply psi and m as plain pointers
…pilation. On the other hand, we could possibly use arrays for matrix operations?
…should be able to generated vectorized matrix multiplies (given that the compiler options are set). Matrix-vector itself is not yet efficient though, moreover the gaps in 'psi' elements are bad for memory efficiency
… The compilation times with eigen are an order of magnitude faster now, feels like the time is flat
Add a check to make sure the kernelgen.py script does exists based on the input to the kernelgen() function. Also make kernelgen() a function instead of a macro and add a `COMBINATIONS` arguments
…ome Cygwin/MinGW issues
…nfigs, which somehow fail to advertise themselves as MSYS or MINGW environments
…ve without it everywhere else
This is easily fixed. As long as the corresponding folders are inside the include(compiler_has_std_filesystem)
Sure we could do that. Otherwise, we can just add
As discussed yesterday, look at the version included in HiQ-ProjectQ. |
Takishima
left a comment
There was a problem hiding this comment.
Here's a preliminary review of the code with some comments. More work is needed before we can propose this for a merge.
Also, the source code is missing the license information which might trigger some tools once we do perform the actual merge on Gitee.
| cmake_minimum_required(VERSION 3.20 FATAL_ERROR) | ||
|
|
||
| project( | ||
| cppsim | ||
| VERSION 1.0.0 | ||
| LANGUAGES C CXX) | ||
|
|
||
| # Minimum required Python version (used both in this file and in the installed CMake configuration) | ||
| set(CPPSIM_PYTHON_VERSION_MIN 3.7.0) | ||
|
|
||
| option(BUILD_TESTING "Build the test suite?" OFF) | ||
|
|
||
| if(NOT DEFINED ITERATOR_DEBUG_VALUE) | ||
| set(ITERATOR_DEBUG_VALUE 0) | ||
| endif() | ||
| option(MSVC_ITERATOR_DEBUG "Define _ITERATOR_DEBUG_LEVEL (defaults to 0, can be set using ITERATOR_DEBUG_VALUE)" OFF) |
There was a problem hiding this comment.
To match with the rest of MindQuantum, remove these lines. The CMake options and variables should be already defined by MindQuantum
| include(GNUInstallDirs) | ||
|
|
||
| set(CPPSIM_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}") | ||
| set(CPPSIM_INSTALL_SBINDIR "${CMAKE_INSTALL_SBINDIR}") | ||
| set(CPPSIM_INSTALL_SYSCONFDIR "${CMAKE_INSTALL_SYSCONFDIR}") | ||
| set(CPPSIM_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/cppsim") | ||
| set(CPPSIM_INSTALL_DATADIR "${CMAKE_INSTALL_DATADIR}/cppsim") | ||
| set(CPPSIM_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/cppsim") | ||
| set(CPPSIM_INSTALL_DOCDIR "${CMAKE_INSTALL_DATADIR}/doc/cppsim") | ||
| set(CPPSIM_INSTALL_CMAKEDIR "${CPPSIM_INSTALL_DATADIR}/cmake") | ||
| set(CPPSIM_INSTALL_3RDPARTYDIR "${CPPSIM_INSTALL_LIBDIR}/third_party") |
There was a problem hiding this comment.
Modify those so that they are using the MQ_INSTALL_XXX CMake variables.
You may redefined the CPPSIM_INSTALL_XXX to be relative to MQ_INSTALL_3RDPARTYDIR for example
| # ============================================================================== | ||
|
|
||
| # TODO | ||
| include("${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/compiler_has_std_filesystem.cmake") |
There was a problem hiding this comment.
As explained in another comment, you should be able to simply write
include(compiler_has_std_filesystem)This should work since MindQuantum modifies the CMAKE_MODULE_PATH variables elsewhere for this exact purpose.
| if(NOT DEFINED Eigen3_DIR) | ||
| FetchContent_Declare( | ||
| Eigen3 | ||
| GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git | ||
| GIT_TAG 3147391d946bb4b6c68edd901f2add6ac1f31f8c) | ||
| FetchContent_MakeAvailable(googletest Eigen3) | ||
| else() | ||
| find_package(Eigen3 CONFIG REQUIRED) | ||
| endif() |
There was a problem hiding this comment.
This should be removed since Eigen3 is found by MindQuantum in its third-party libraries directory.
You can add a short comment saying that one could want to look for Eigen3 here if it was not before.
| @@ -0,0 +1,43 @@ | |||
| #include <algorithm> | |||
There was a problem hiding this comment.
Test code should go under tests
| @@ -0,0 +1,142 @@ | |||
| // Ensure hand-written and generated kernels give equal results. | |||
There was a problem hiding this comment.
Test code should go under tests
| @@ -0,0 +1,271 @@ | |||
| #include <algorithm> | |||
There was a problem hiding this comment.
Test code should go under tests
| find_package(res_embed QUIET CONFIG) | ||
| if(NOT res_embed_FOUND) | ||
| FetchContent_Declare( | ||
| res_embed | ||
| GIT_REPOSITORY https://github.com/dmikushin/res_embed.git | ||
| GIT_TAG 93b5711070086dea53c3b535018ff34e68479242) | ||
| FetchContent_MakeAvailable(res_embed) | ||
| else() | ||
| message(STATUS "Found res_embed at ${res_embed_DIR}") | ||
| endif() |
There was a problem hiding this comment.
Like for Eigen3 these lines are not required since ResEmbed is a third-party of MindQuantum.
You can add a short comment saying that one could want to look for ResEmbed here if it was not before.
|
Also ensure that the versions of the third-party specified in the |
In principle, cppsim source is now integrated into MQ, and compiles together with it. There are several items to be addressed yet:
cmakeandcmake/commandsmodules folder should not be reached with../../.., this is ugly. But I was not able to find an example of a better way to do it in other subfolders.Accessing
../../include/cppsiminclude directory is also ugly, maybe there is a good environment variable to use instead?CppSim still deals with
dlfcn-win32by itself, while all other dependencies are brought in globally, by MQ. I guess we should move this dependency out on MQ likewise, but before that maybe it's better to use cross-platform dynalo instead?There is an issue with std::allocator, compiler complains about max_size(). Even though throw() version is not deprecated, it fails either way. Maybe we disable exceptions?