Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
63e3691
Working on the nointrin generator
dmikushin Jul 25, 2022
68915d9
Working on the code generation for kernel_core
dmikushin Jul 26, 2022
48d245c
Finalizing the code generation for kernel_core
dmikushin Jul 27, 2022
6b30b41
Adding build scripts, adding test program stub
dmikushin Jul 28, 2022
7cc0b7a
Working on the test stub
dmikushin Jul 29, 2022
2b67121
Getting all 5 handwritten kernels to compile within the test, thanks …
dmikushin Jul 29, 2022
c1928b8
Finalizing the test to ensure hand-written and generated kernels give…
dmikushin Aug 8, 2022
907733a
Adding class for creating temporary files
dmikushin Aug 9, 2022
a61040d
Embedding kernel generation script as a resource
dmikushin Aug 9, 2022
dea7736
Correcting the wrong order of statements: agrument parser must come e…
dmikushin Aug 10, 2022
3d7087e
Adding the rest of the original _cppsim source code, adding the Pytho…
dmikushin Aug 10, 2022
707f6fc
Adding support for both plain and keywork link libraries specificatio…
dmikushin Aug 10, 2022
2bfe527
Working on the embedded kernel generation and a benchmark executable
dmikushin Aug 11, 2022
3e37b96
Updating the README
dmikushin Aug 11, 2022
f5996f9
Clarifying the README description
dmikushin Aug 12, 2022
6c352c5
Use embedded Python interpreter to run the script and get the resulti…
dmikushin Aug 12, 2022
befaca6
Adding intermediate files as dependencies, in order to perform proper…
dmikushin Aug 15, 2022
b6f98b1
Working on the runtime compilation support
dmikushin Aug 15, 2022
eaf5014
Getting runtime compilation to succeed
dmikushin Aug 16, 2022
908b26d
Breaking the API compatibility, in order to pass generic pointers dow…
dmikushin Aug 17, 2022
a56e5c7
Removing debug print
dmikushin Aug 18, 2022
77151ab
Getting the runtime-generated kernel executed, adding OpenMP, adding …
dmikushin Aug 18, 2022
1275bee
Adding an option to substitute ids values directly into the runtime-c…
dmikushin Aug 19, 2022
ed4a7d2
Working on a better representation of the generator script
dmikushin Aug 22, 2022
1331e41
Finalizing better representation of the generator script
dmikushin Aug 23, 2022
5b131af
Use sorted 'd' values as scalars instead of an array, in case of runt…
dmikushin Aug 24, 2022
d6c1054
Use 'v' values as scalars instead of an array, in case of runtime com…
dmikushin Aug 24, 2022
b3a7c6a
Using Eigen to do matrix-vector multiplication in kernel_core. Eigen …
dmikushin Aug 25, 2022
39af62c
Letting runtime compilation to use the system-provided eigen library.…
dmikushin Aug 25, 2022
e49fab7
Working on adding combinations headers
dmikushin Aug 26, 2022
25527d5
Preparing combinations for serving the kernels
dmikushin Aug 26, 2022
c915f44
Fixing bugs in combinations, adding a test to compare the reference k…
dmikushin Aug 29, 2022
f42e628
Importing combinations code for cpu/gpu partitioning
dmikushin Aug 30, 2022
b3fec7a
Simplifying partitioning code to handle combinations specific to cpps…
dmikushin Aug 30, 2022
77ca828
Adding popcount implementation and a correctness test
dmikushin Aug 31, 2022
a804e50
Fixing combinations partitioning code, adding partitioned version int…
dmikushin Aug 31, 2022
7b9548c
Adding the missing compiler.h
dmikushin Sep 1, 2022
eec3587
Use literals to identify a named argument ids
dmikushin Sep 1, 2022
f90b685
Adding an option to substitute the M matrix directly into the runtime…
dmikushin Sep 2, 2022
f0b8f25
Fixing the missing vids vector length spec
dmikushin Sep 6, 2022
1d14f9d
Correcting the way how the PSI length should be computed: it must be …
dmikushin Sep 6, 2022
eb5b376
Correcting the calculation of PSI length in the generator as well. In…
dmikushin Sep 7, 2022
2768b88
Compute the PSI length in the hand-written kernels as well, instead o…
dmikushin Sep 7, 2022
0447f5a
Right hand side is returned as string, so '0' must be returned intead…
dmikushin Sep 13, 2022
611dd4f
Adding a required linking against libdl library, which is used by run…
dmikushin Sep 14, 2022
9b04b02
Replace git submodules with CMake FetchContent
Takishima Oct 20, 2022
ce522a0
Add proper CMake installation files
Takishima Oct 21, 2022
6338346
Update git tag for res_embed
Takishima Oct 21, 2022
9c8c236
Fix installation target for digestpp::digestpp
Takishima Oct 21, 2022
4aefaea
Cleanup code and better handling of digestpp within installed CMake c…
Takishima Oct 21, 2022
bae78c7
Added missing find_package(res_embed) in installed CMake configuration
Takishima Oct 21, 2022
bd73c0e
Fix issues with kernelgen() macro when installed
Takishima Oct 21, 2022
7754828
Fix potential issues with paths containing spaces in installed config…
Takishima Oct 21, 2022
595d251
Fix issues with cppsim CMake installation config due to PACKAGE_PREFI…
Takishima Oct 21, 2022
81a3177
Fix error in settings target dependencies for test_nointrin
Takishima Oct 21, 2022
b436119
Add kernelgen path check and turn kernelgen into function
Takishima Oct 22, 2022
bd79df8
Fix changes missing from last commit
Takishima Oct 22, 2022
c1f5249
Add <array> and <functional> to kernels.hpp
Takishima Oct 25, 2022
f4fdf20
Improve CXX standard handling for all targets + add .cmake-format.yam…
Takishima Oct 25, 2022
44e1084
Add compatibility with Boost::Filesystem for older compilers
Takishima Oct 25, 2022
522654a
Fix compilation error on MSVC due to OpenMP
Takishima Oct 25, 2022
ec2df8a
Fix missed #include <filesystem> for compatibility with older compilers
Takishima Oct 25, 2022
0671955
Use Python.Module instead of Python.Embed
Takishima Oct 25, 2022
1668736
Fix compilation issues on various compilers
Takishima Oct 25, 2022
c6b871f
Fix compilation issues linked to <unistd.h>
Takishima Oct 26, 2022
f8e438d
Locate pybind11 after looking for Python
Takishima Oct 26, 2022
b952ff7
Use Python module instead of embed
Takishima Oct 26, 2022
7834aa2
Support dlopen on Windows
Takishima Oct 26, 2022
e08caf7
Help CMake on macOS to locate OpenMP when using HomeBrew and MacPorts
Takishima Oct 27, 2022
6dfbb9f
Add GitHub workflows
Takishima Oct 27, 2022
6881132
More verbose output
Takishima Oct 27, 2022
5779e9c
Fix typo
Takishima Oct 27, 2022
89b7dd5
Fix CMake configuration error due to dlfcn-win32
Takishima Oct 27, 2022
84f0ff4
Allow customization of the _ITERATOR_DEBUG define when compiling with…
Takishima Oct 27, 2022
2a2bd33
Use dlfcn-win32 also on MSYS
Takishima Oct 27, 2022
a313ac9
Update res_embed version
Takishima Nov 1, 2022
c8713ec
Use dmikushin/res_embed for GitHub workflows
Takishima Nov 1, 2022
c975c61
Bumping the res_embed GIT_TAG to a version, which (hopefully) fixes s…
dmikushin Nov 14, 2022
b9bcccb
Do not use .att_mnemonic, which is not supported by Clang
dmikushin Nov 14, 2022
7879110
Ensuring NO_TYPE_FOR_PECOFF reaches MSYS2 MINGW64 and MSYS2 UCRT64 co…
dmikushin Nov 14, 2022
be87a2b
Don't use .type directive unsupported on Windows at all, if we can li…
dmikushin Nov 14, 2022
7c43563
Getting cppsim to compile from sources alongside the MindQuantum sources
dmikushin Dec 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ call %SCRIPTDIR%\dos\build_cmake_option.bat BUILD_TESTING !enable_tests!
call %SCRIPTDIR%\dos\build_cmake_option.bat CLEAN_3RDPARTY_INSTALL_DIR !do_clean_3rdparty!
call %SCRIPTDIR%\dos\build_cmake_option.bat ENABLE_ANALYZER !enable_analyzer!
call %SCRIPTDIR%\dos\build_cmake_option.bat ENABLE_CMAKE_DEBUG !cmake_debug_mode!
call %SCRIPTDIR%\dos\build_cmake_option.bat ENABLE_CPPSIM !enable_cppsim!
call %SCRIPTDIR%\dos\build_cmake_option.bat ENABLE_CUDA !enable_gpu!
call %SCRIPTDIR%\dos\build_cmake_option.bat ENABLE_CXX_EXPERIMENTAL !enable_cxx!
call %SCRIPTDIR%\dos\build_cmake_option.bat ENABLE_GITEE !enable_gitee!
Expand Down Expand Up @@ -504,7 +503,6 @@ rem ============================================================================
echo /CleanBuildDir Delete build directory before building
echo /CleanCache Re-run CMake with a clean CMake cache
echo /CleanVenv Delete Python virtualenv before building
echo /CppSim (experimental) Enable the use of cppsim to generate simulation kernels
echo /Cxx (experimental) Enable MindQuantum C++ support
echo /Debug Build in debug mode
echo /Delocate Delocate the binary wheels after build is finished
Expand Down
4 changes: 0 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Param(
[switch]$CleanCache,
[switch]$CleanVenv,
[ValidateNotNullOrEmpty()][string]$Config,
[switch]$CppSim,
[ValidateNotNullOrEmpty()][string]$CudaArch,
[switch]$Cxx,
[switch]$Debug,
Expand Down Expand Up @@ -488,9 +487,6 @@ Do not use the CMake registry to find packages
.PARAMETER Config
Path to INI configuration file with default values for the parameters

.PARAMETER CppSim
(experimental) Enable the use of cppsim to generate simulation kernels

.PARAMETER Cxx
(experimental) Enable MindQuantum C++ support

Expand Down
7 changes: 0 additions & 7 deletions build_locally.bat
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,6 @@ rem ============================================================================
shift & shift & goto :initial
)

if /I "%1" == "/CppSim" (
set enable_cppsim=1
shift & goto :initial
)

if /I "%1" == "/Cxx" (
set enable_cxx=1
shift & goto :initial
Expand Down Expand Up @@ -348,7 +343,6 @@ call %SCRIPTDIR%\dos\build_locally_cmake_option.bat BUILD_TESTING !enable_tests!
call %SCRIPTDIR%\dos\build_locally_cmake_option.bat CLEAN_3RDPARTY_INSTALL_DIR !do_clean_3rdparty!
call %SCRIPTDIR%\dos\build_locally_cmake_option.bat ENABLE_ANALYZER !enable_analyzer!
call %SCRIPTDIR%\dos\build_locally_cmake_option.bat ENABLE_CMAKE_DEBUG !cmake_debug_mode!
call %SCRIPTDIR%\dos\build_locally_cmake_option.bat ENABLE_CPPSIM !enable_cppsim!
call %SCRIPTDIR%\dos\build_locally_cmake_option.bat ENABLE_CUDA !enable_gpu!
call %SCRIPTDIR%\dos\build_locally_cmake_option.bat ENABLE_CXX_EXPERIMENTAL !enable_cxx!
call %SCRIPTDIR%\dos\build_locally_cmake_option.bat ENABLE_DOCUMENTATION !do_docs!
Expand Down Expand Up @@ -546,7 +540,6 @@ exit /B 0
echo /CleanCache Re-run CMake with a clean CMake cache
echo /CleanVenv Delete Python virtualenv before building
echo /ConfigureOnly Stop after the CMake configure and generation steps (ie. before building MindQuantum)
echo /CppSim (experimental) Enable the use of cppsim to generate simulation kernels
echo /Cxx (experimental) Enable MindQuantum C++ support
echo /Debug Build in debug mode
echo /DebugCMake Enable debugging mode for CMake configuration step
Expand Down
5 changes: 0 additions & 5 deletions build_locally.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Param(
[ValidateNotNullOrEmpty()][string]$Config,
[Alias("C")][switch]$Configure,
[switch]$ConfigureOnly,
[switch]$CppSim,
[ValidateNotNullOrEmpty()][string]$CudaArch,
[switch]$Cxx,
[switch]$Debug,
Expand Down Expand Up @@ -244,7 +243,6 @@ $cmake_args = @('-DIN_PLACE_BUILD:BOOL=ON'
"-DENABLE_ANALYZER:BOOL={0}" -f $CMAKE_BOOL[$enable_analyzer]
"-DENABLE_PROJECTQ:BOOL={0}" -f $CMAKE_BOOL[$enable_projectq]
"-DENABLE_CMAKE_DEBUG:BOOL={0}" -f $CMAKE_BOOL[$cmake_debug_mode]
"-DENABLE_CPPSIM:BOOL={0}" -f $CMAKE_BOOL[$enable_cppsim]
"-DENABLE_CUDA:BOOL={0}" -f $CMAKE_BOOL[$enable_gpu]
"-DENABLE_CXX_EXPERIMENTAL:BOOL={0}" -f $CMAKE_BOOL[$enable_cxx]
"-DENABLE_DOCUMENTATION:BOOL={0}" -f $CMAKE_BOOL[$do_docs]
Expand Down Expand Up @@ -439,9 +437,6 @@ Path to INI configuration file with default values for the parameters
.PARAMETER ConfigureOnly
Stop after the CMake configure and generation steps (ie. before building MindQuantum)

.PARAMETER CppSim
(experimental) Enable the use of cppsim to generate simulation kernels

.PARAMETER Cxx
(experimental) Enable MindQuantum C++ support

Expand Down
1 change: 0 additions & 1 deletion build_locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ cmake_args=(-DIN_PLACE_BUILD:BOOL=ON
-DENABLE_PROJECTQ:BOOL="${CMAKE_BOOL[$enable_projectq]}"
-DENABLE_CMAKE_DEBUG:BOOL="${CMAKE_BOOL[$cmake_debug_mode]}"
-DENABLE_CUDA:BOOL="${CMAKE_BOOL[$enable_gpu]}"
-DENABLE_CPPSIM:BOOL="${CMAKE_BOOL[$enable_cppsim]}"
-DENABLE_CXX_EXPERIMENTAL:BOOL="${CMAKE_BOOL[$enable_cxx]}"
-DENABLE_DOCUMENTATION:BOOL="${CMAKE_BOOL[$do_docs]}"
-DENABLE_GITEE:BOOL="${CMAKE_BOOL[$enable_gitee]}"
Expand Down
185 changes: 185 additions & 0 deletions ccsrc/include/cppsim/combinations.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
#ifndef COMBINATIONS_H
#define COMBINATIONS_H

#include "gpu_support.h"

#include <algorithm>
#include <array>
#include <cstdio>
#include <stdint.h>
#include <type_traits>

// Iterate through the combinations using currying approach: https://stackoverflow.com/a/54508163/4063520
class Combinations
{
// *****************************************************************************
// Simple case: no sum constraint
// *****************************************************************************
private :

template<
uint32_t n0, uint32_t n1, uint32_t ...n, // max allowed sequence element value
class Callable
>
GPU_SUPPORT
static constexpr void _iterate(Callable&& c)
{
for (uint32_t i = 0; i < n0; i += 2 * n1)
{
auto bind_an_argument = [i, &c](auto... args)
{
c(i, args...);
};

_iterate<n1, n...>(bind_an_argument);
}
}

template<
uint32_t n0, // max allowed sequence element value
class Callable
>
GPU_SUPPORT
static constexpr void _iterate(Callable&& c)
{
for (uint32_t i = 0; i < n0; i++)
{
c(i);
}
}


public :

template<uint32_t ...n>
struct Combination
{
using type = std::array<uint32_t, sizeof...(n)>;
};

// Iterate through all combinations.
// For each combination, call a user-provided function.
template<
uint32_t ...n, // max allowed sequence element value
class Callable
>
GPU_SUPPORT
static constexpr void iterate(Callable&& c)
{
_iterate<n...>(c);
}

// Tell the length of a combination supplied by the iterator
// configured with the given set of template parameters.
template<uint32_t ...n>
static constexpr uint32_t length()
{
return sizeof...(n);
}

// Tell the number of combinations supplied by the iterator
// configured with the given set of template parameters.
template<uint32_t n0>
static uint32_t _popcount()
{
return n0;
}

// Tell the number of combinations supplied by the iterator
// configured with the given set of template parameters.
template<uint32_t n0, uint32_t n1, uint32_t ...n>
static uint32_t _popcount()
{
return (n0 / (2 * n1)) * _popcount<n1, n...>();
}

// Tell the number of combinations supplied by the iterator
// configured with the given set of template parameters.
template<uint32_t ...n>
static uint32_t popcount()
{
if (sizeof...(n) == 0) return 0;
return _popcount<n...>();
}

// Reverse the order of elements in a combination
// configured with the given set of template parameters.
template<uint32_t ...n>
static void reverse(typename Combination<n...>::type& c)
{
std::reverse(c.begin(), c.end());
}

// *****************************************************************************
// Simple case: no sum constraint with a user-defined range
// *****************************************************************************
public :

template<
uint32_t n0, uint32_t n1, uint32_t ...n, // max allowed sequence element value
class Callable
>
GPU_SUPPORT
static constexpr void _iterate(uint32_t* start, uint32_t& limit, Callable&& c)
{
for (uint32_t i = *start; (i < n0) && limit; i += 2 * n1)
{
// Flush starting point to zero, in order for all subsequent iterations
// to start from zero as usual.
*start = 0;

auto bind_an_argument = [i, &c](auto... args)
{
c(i, args...);
};

_iterate<n1, n...>(start++, limit, bind_an_argument);
}
}

template<
uint32_t n0, // max allowed sequence element value
class Callable
>
GPU_SUPPORT
static constexpr void _iterate(uint32_t* start, uint32_t& limit, Callable&& c)
{
for (uint32_t i = *start; (i < n0) && limit; i++)
{
// Flush starting point to zero, in order for all subsequent iterations
// to start from zero as usual.
*start = 0;

c(i);
limit--;
}
}

public :

// Iterate through combinations with specific starting point and duration.
// For each combination, call a user-provided function.
template<
uint32_t ...n, // max allowed sequence element value
class Callable
>
GPU_SUPPORT
static constexpr void iterate(const typename Combination<n...>::type& start_, const uint32_t limit_, Callable&& c)
{
auto start = start_;
uint32_t limit = limit_;
_iterate<n...>(start.data(), limit, c);
}

// Tell the number of combinations supplied by the iterator
// configured with the given set of template parameters.
template<uint32_t ...n>
static uint32_t popcount(const uint32_t limit)
{
// XXX Actually could be less than limit, if start is closer to the end.
return limit;
}
};

#endif // COMBINATIONS_H

19 changes: 19 additions & 0 deletions ccsrc/include/cppsim/compiler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef COMPILER_H
#define COMPILER_H

#include <string>

class Compiler
{
public :

void* codegen(int nqubits, const std::string& source, std::string& errmsg);

Compiler();

};

Compiler& get_compiler();

#endif // COMPILER_H

18 changes: 18 additions & 0 deletions ccsrc/include/cppsim/cppsim_omp.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef CPPSIM_OMP_HPP
#define CPPSIM_OMP_HPP

#include <cstdint>

#if defined(_OPENMP)
# include <omp.h>
#endif

namespace omp {
#ifdef _MSC_VER
using idx_t = int64_t;
#else
using idx_t = uint64_t;
#endif // _MSC_VER
} // namespace omp

#endif /* CPPSIM_OMP_HPP */
Loading