diff --git a/.clang-format b/.clang-format index 554920e01..9e377c76c 100644 --- a/.clang-format +++ b/.clang-format @@ -1,5 +1,4 @@ --- - BasedOnStyle: Google AccessModifierOffset: -3 AlignConsecutiveMacros: true @@ -42,7 +41,7 @@ IncludeCategories: # 9. Any local config header # 10. Local headers # 11. Catch2 headers - - Regex: '[<"](catch2/([A-Za-z0-9.\/\-_])+)[>"]' # Make sure Catch2 is included last + - Regex: '[<"](catch2/([A-Za-z0-9.\/\-_])+)[>"]' # Make sure Catch2 is included last Priority: 110 - Regex: '[<"]tweedledum/([A-Za-z0-9.\/\-_])+[>"]' Priority: 60 @@ -97,5 +96,13 @@ TypenameMacros: [] Standard: Latest TabWidth: 4 UseTab: Never -WhitespaceSensitiveMacros: ['CLANG_DIAG_ON', 'CLANG_DIAG_OFF', 'GCC_DIAG_ON', 'GCC_DIAG_OFF', 'MSVC_DIAG_ON', - 'MSVC_DIAG_OFF', 'MQ_DO_PRAGMA'] +WhitespaceSensitiveMacros: + [ + "CLANG_DIAG_ON", + "CLANG_DIAG_OFF", + "GCC_DIAG_ON", + "GCC_DIAG_OFF", + "MSVC_DIAG_ON", + "MSVC_DIAG_OFF", + "QUAFU_DO_PRAGMA", + ] diff --git a/.cmake-format.yaml b/.cmake-format.yaml index 85f113c29..f3118a6c8 100644 --- a/.cmake-format.yaml +++ b/.cmake-format.yaml @@ -1,5 +1,4 @@ --- - markup: first_comment_is_literal: true format: @@ -60,7 +59,7 @@ parse: pargs: flags: - CONFIGURE - - '@ONLY' + - "@ONLY" kwargs: OUTPUT: 1 CONTENT: 1 @@ -100,7 +99,7 @@ parse: RESULT_VARIABLE: 1 TIMEOUT: 1 WORKING_DIRECTORY: 1 - mindquantum_add_pkg: + quafu_add_pkg: pargs: nargs: 1 flags: @@ -141,13 +140,13 @@ parse: PRE_CONFIGURE_COMMAND: + SYSTEM_EXTRA_DEFINES: + TARGET_ALIAS: + - mq_add_compile_definitions: + quafu_add_compile_definitions: pargs: nargs: + flags: - TRYCOMPILE - TRYCOMPILE_FLAGCHECK - mq_link_libraries: + quafu_link_libraries: pargs: nargs: + flags: @@ -165,7 +164,7 @@ parse: nargs: 1+ flags: - FLAGCHECK - - NO_MQ_TARGET + - NO_QUAFU_TARGET - NO_TRYCOMPILE_FLAGCHECK_TARGET - NO_TRYCOMPILE_TARGET kwargs: @@ -178,7 +177,7 @@ parse: pargs: nargs: 1+ flags: - - NO_MQ_TARGET + - NO_QUAFU_TARGET - VERBATIM kwargs: LANGS: + @@ -199,4 +198,4 @@ lint: local_var_pattern: _?([a-z][a-z0-9_]+|[A-Z][A-Z0-9_]+) global_var_pattern: _?([a-z][a-z0-9_]+|[A-Z][A-Z0-9_]+) internal_var_pattern: _?([a-z][a-z0-9_]+|[A-Z][A-Z0-9_]+) - macro_pattern: '[0-9a-z_]+' + macro_pattern: "[0-9a-z_]+" diff --git a/.cppcheck.suppressions b/.cppcheck.suppressions index aa5732b11..e1156c93d 100644 --- a/.cppcheck.suppressions +++ b/.cppcheck.suppressions @@ -33,7 +33,7 @@ syntaxError:ccsrc/include/core/sparse/algo.h syntaxError:ccsrc/include/ops/gates/terms_operator_base_external_ops.h:92 syntaxError:ccsrc/lib/simulator/vector/detail/cpu_vector_policy.cpp syntaxError:ccsrc/lib/simulator/vector/detail/cpu_vector_policy_gate_expec.cpp -syntaxError:ccsrc/python/mqbackend/lib/details/define_terms_ops.h +syntaxError:ccsrc/python/quafubackend/lib/details/define_terms_ops.h syntaxError:ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_condition.cpp syntaxError:ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_gate_expect.cpp syntaxError:ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_dot_like.cpp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6d1b172e..78dfe0364 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,7 +93,7 @@ jobs: if: env.ACT != 'true' uses: actions/cache@v3 with: - path: build/.mqlibs + path: build/.quafulibs key: >- ${{ matrix.runs-on }}-python-${{ matrix.python }}-third-party-libs-${{ hashFiles('third_party/**') }} -${{ secrets.cache_ver }} @@ -132,7 +132,7 @@ jobs: echo $PYTHONPATH pip install -r requirements_test.txt pip install pytest - python3 -c "import mindquantum as mq;print(mq.qft(range(3)))" + python3 -c "import quafu as quafu;print(quafu.qft(range(3)))" pytest tests/st -rs # ============================================================================ @@ -194,7 +194,7 @@ jobs: if: env.ACT != 'true' uses: actions/cache@v3 with: - path: build/.mqlibs + path: build/.quafulibs key: macos-${{ matrix.xcode }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} - name: Configure @@ -220,7 +220,7 @@ jobs: echo $PYTHONPATH pip install -r requirements_test.txt pip install pytest - python3 -c "import mindquantum as mq;print(mq.qft(range(3)))" + python3 -c "import quafu as quafu;print(quafu.qft(range(3)))" pytest tests/st -rs # ============================================================================ @@ -245,7 +245,7 @@ jobs: - name: Get history and tags for SCM versioning to work run: | - git config --global --add safe.directory /__w/mindquantum/mindquantum + git config --global --add safe.directory /__w/quafu/quafu git fetch --prune --unshallow git fetch --depth=1 origin +refs/tags/*:refs/tags/* @@ -288,7 +288,7 @@ jobs: if: env.ACT != 'true' uses: actions/cache@v3 with: - path: build/.mqlibs + path: build/.quafulibs key: gcc-${{ matrix.gcc }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} - name: Configure @@ -369,7 +369,7 @@ jobs: echo $PYTHONPATH pip install -r requirements_test.txt pip install pytest - python3 -c "import mindquantum as mq;print(mq.qft(range(3)))" + python3 -c "import quafu as quafu;print(quafu.qft(range(3)))" pytest tests/st -rs # ============================================================================ @@ -410,7 +410,7 @@ jobs: run: | ls -alth # pwd - # git config --global --add safe.directory /__w/mindquantum/mindquantum + # git config --global --add safe.directory /__w/quafu/quafu # git fetch --prune --unshallow # git fetch --depth=1 origin +refs/tags/*:refs/tags/* @@ -453,7 +453,7 @@ jobs: if: env.ACT != 'true' uses: actions/cache@v3 with: - path: build/.mqlibs + path: build/.quafulibs key: clang-${{ matrix.clang }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} - name: Configure (Clang) @@ -540,7 +540,7 @@ jobs: echo $PYTHONPATH pip install -r requirements_test.txt pip install pytest - python3 -c "import mindquantum as mq;print(mq.qft(range(3)))" + python3 -c "import quafu as quafu;print(quafu.qft(range(3)))" pytest tests/st -rs # ============================================================================ @@ -600,7 +600,7 @@ jobs: if: env.ACT != 'true' uses: actions/cache@v3 with: - path: build/.mqlibs + path: build/.quafulibs key: msvc-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} - name: Configure @@ -688,7 +688,7 @@ jobs: if: env.ACT != 'true' uses: actions/cache@v3 with: - path: build/.mqlibs + path: build/.quafulibs key: clang-cl-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} - name: Configure @@ -753,7 +753,7 @@ jobs: if: env.ACT != 'true' uses: actions/cache@v3 with: - path: build/.mqlibs + path: build/.quafulibs key: mingw64-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} - name: Set up MinGW64 @@ -911,7 +911,7 @@ jobs: if: env.ACT != 'true' uses: actions/cache@v3 with: - path: build/.mqlibs + path: build/.quafulibs key: msys2-${{ matrix.msystem }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} - name: Configure @@ -1011,7 +1011,7 @@ jobs: if: env.ACT != 'true' uses: actions/cache@v3 with: - path: build/.mqlibs + path: build/.quafulibs key: cuda-${{ matrix.cuda }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} - name: Configure @@ -1038,7 +1038,7 @@ jobs: echo $PYTHONPATH pip install -r requirements_test.txt pip install pytest - python3 -c "import mindquantum as mq;print(mq.qft(range(3)))" + python3 -c "import quafu as quafu;print(quafu.qft(range(3)))" pytest tests/st -rs # ============================================================================ @@ -1104,7 +1104,7 @@ jobs: if: env.ACT != 'true' uses: actions/cache@v3 with: - path: build/.mqlibs + path: build/.quafulibs key: nvhpc-${{ matrix.nvhpc }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} - name: Configure diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 81a3d6a7f..fc9662ae4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,6 @@ # NB: this is mainly shown for illustration purposes and is not actively maintained. --- - include: .gitlab/hashes.yml variables: @@ -43,11 +42,11 @@ variables: ./build_locally.sh --cxx --debug-cmake --test --ccache --configure-only -c --clean-3rdparty --prefix=$PWD/install - ./build_locally.sh --cxx --debug-cmake --test --ccache - - ./build_locally.sh --install # NB: no need to pass the other parameters + - ./build_locally.sh --install # NB: no need to pass the other parameters .cache_paths: paths: &cache_paths - - build/.mqlibs + - build/.quafulibs - cache - venv @@ -79,7 +78,6 @@ gcc: script: - *default_script_unix - clang: image: silkeh/clang:${CLANG} inherit: diff --git a/.jenkins/check/config/filter_cmakelint.txt b/.jenkins/check/config/filter_cmakelint.txt index 832c83091..07fb4341d 100644 --- a/.jenkins/check/config/filter_cmakelint.txt +++ b/.jenkins/check/config/filter_cmakelint.txt @@ -1,5 +1,5 @@ -# MindQuantum -"mindquantum/cmake" "whitespace/indent" -"mindquantum/cmake/Modules" "whitespace/indent" -"mindquantum/cmake/Modules/apple" "whitespace/indent" -"mindquantum/ccsrc/lib/simulator/stabilizer/CMakeLists.txt" "whitespace/indent" +# quafu +"quafu/cmake" "whitespace/indent" +"quafu/cmake/Modules" "whitespace/indent" +"quafu/cmake/Modules/apple" "whitespace/indent" +"quafu/ccsrc/lib/simulator/stabilizer/CMakeLists.txt" "whitespace/indent" diff --git a/.jenkins/check/config/filter_cppcheck.txt b/.jenkins/check/config/filter_cppcheck.txt index 5aa9a05fa..552d93c27 100644 --- a/.jenkins/check/config/filter_cppcheck.txt +++ b/.jenkins/check/config/filter_cppcheck.txt @@ -2,82 +2,82 @@ "missingInclude" "missingReturn" -"mindquantum/tests/" "constParameter" -"mindquantum/tests/" "unreadVariable" - -"mindquantum/ccsrc/python/simulator/include/python/vector/bind_vec_state.h" "assignBoolToPointer" - -"mindquantum/ccsrc/lib/mq_base/gates/details/fermion_operator_term_policy.cpp" "constStatement" -"mindquantum/ccsrc/lib/mq_base/gates/details/qubit_operator_term_policy.cpp" "constStatement" - -"mindquantum/ccsrc/include/ops/gates/fermion_operator.tpp" "containerOutOfBounds" -"mindquantum/ccsrc/lib/ops/gates/fermion_operator.cpp" "containerOutOfBounds" -"mindquantum/ccsrc/lib/ops/gates/fermion_operator_parameter_resolver.cpp" "containerOutOfBounds" - -"mindquantum/ccsrc/include/core/parameter_resolver.h:707" "duplicateExpression" -"mindquantum/ccsrc/python/mqbackend/lib/binding.cc" "duplicateExpression" -"mindquantum/ccsrc/python/math/lib/bind_math.cpp" "duplicateExpression" - -"mindquantum/ccsrc/python/mqbackend/include/python/ops/basic_gate.h" "noExplicitConstructor" - -"mindquantum/ccsrc/include/config/config.h" "noValidConfiguration" -"mindquantum/ccsrc/include/config/details/cxx20_compatibility.h" "noValidConfiguration" -"mindquantum/ccsrc/include/config/type_traits.h" "noValidConfiguration" -"mindquantum/tests/decompositions/test_apply_atoms.cpp" "noValidConfiguration" - - -"mindquantum/ccsrc/include/config/details/cxx20_compatibility.h" "preprocessorErrorDirective" -"mindquantum/tests/decompositions/test_apply_atoms.cpp" "preprocessorErrorDirective" -"mindquantum/tests/ops/test_angle_parametric_gates.cpp" "preprocessorErrorDirective" - - -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_policy.cpp" "syntaxError" -"mindquantum/ccsrc/include/core/parameter_resolver_external_ops.h:90" "syntaxError" -"mindquantum/ccsrc/include/core/sparse/algo.h:73" "syntaxError" -"mindquantum/ccsrc/include/ops/gates/terms_operator_base_external_ops.h:92" "syntaxError" -"mindquantum/ccsrc/python/mqbackend/lib/binding.cc:184" "syntaxError" -"mindquantum/ccsrc/python/mqbackend/lib/details/define_terms_ops.h" "syntaxError" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_policy.cpp" "syntaxError" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_condition.cpp" "syntaxError" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_gate_expect.cpp" "syntaxError" - -"mindquantum/ccsrc/include/core/numba_wrapper.h" "uninitMemberVar" - -"mindquantum/ccsrc/include/core/sparse/paulimat.h" "unknownMacro" -"mindquantum/ccsrc/include/core/sparse/paulimat.h:58" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_matrix_gate.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_condition.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_dot_like.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_gate_expect.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_matrix_gate.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_policy.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_rot_pauli.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_swap_like.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_x_like.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_z_like.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_policy.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_z_like.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_x_like.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_channel.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_matrix_gate.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_rot_pauli.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_swap_like.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_gate_expect.cpp" "unknownMacro" -"mindquantum/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_matrix_gate.cpp" "unknownMacro" -"mindquantum/ccsrc/include/simulator/vector/detail/cpu_vector_policy.h" "unknownMacro" -"mindquantum/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" "unknownMacro" - -"mindquantum/ccsrc/include/config/tsl_ordered_map.h" "useStlAlgorithm" -"mindquantum/ccsrc/include/ops/gates/terms_coeff_dict.h" "useStlAlgorithm" -"mindquantum/ccsrc/include/ops/gates/terms_operator_base.tpp" "useStlAlgorithm" - -"mindquantum/tests/core/test_circuit_block.cpp" "ctuOneDefinitionRuleViolation" - -"mindquantum/ccsrc/include/simulator/vector/vector_state.tpp" "cppcheckError" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp" "syntaxError" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_condition.cpp" "syntaxError" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_dot_like.cpp" "syntaxError" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_gate_expect.cpp" "syntaxError" -"mindquantum/ccsrc/python/mqbackend/lib/binding.cc" "syntaxError" -"mindquantum/ccsrc/include/simulator/stabilizer/stabilizer.h" "unusedStructMember" +"quafu/tests/" "constParameter" +"quafu/tests/" "unreadVariable" + +"quafu/ccsrc/python/simulator/include/python/vector/bind_vec_state.h" "assignBoolToPointer" + +"quafu/ccsrc/lib/quafu_base/gates/details/fermion_operator_term_policy.cpp" "constStatement" +"quafu/ccsrc/lib/quafu_base/gates/details/qubit_operator_term_policy.cpp" "constStatement" + +"quafu/ccsrc/include/ops/gates/fermion_operator.tpp" "containerOutOfBounds" +"quafu/ccsrc/lib/ops/gates/fermion_operator.cpp" "containerOutOfBounds" +"quafu/ccsrc/lib/ops/gates/fermion_operator_parameter_resolver.cpp" "containerOutOfBounds" + +"quafu/ccsrc/include/core/parameter_resolver.h:707" "duplicateExpression" +"quafu/ccsrc/python/quafubackend/lib/binding.cc" "duplicateExpression" +"quafu/ccsrc/python/math/lib/bind_math.cpp" "duplicateExpression" + +"quafu/ccsrc/python/quafubackend/include/python/ops/basic_gate.h" "noExplicitConstructor" + +"quafu/ccsrc/include/config/config.h" "noValidConfiguration" +"quafu/ccsrc/include/config/details/cxx20_compatibility.h" "noValidConfiguration" +"quafu/ccsrc/include/config/type_traits.h" "noValidConfiguration" +"quafu/tests/decompositions/test_apply_atoms.cpp" "noValidConfiguration" + + +"quafu/ccsrc/include/config/details/cxx20_compatibility.h" "preprocessorErrorDirective" +"quafu/tests/decompositions/test_apply_atoms.cpp" "preprocessorErrorDirective" +"quafu/tests/ops/test_angle_parametric_gates.cpp" "preprocessorErrorDirective" + + +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_policy.cpp" "syntaxError" +"quafu/ccsrc/include/core/parameter_resolver_external_ops.h:90" "syntaxError" +"quafu/ccsrc/include/core/sparse/algo.h:73" "syntaxError" +"quafu/ccsrc/include/ops/gates/terms_operator_base_external_ops.h:92" "syntaxError" +"quafu/ccsrc/python/quafubackend/lib/binding.cc:184" "syntaxError" +"quafu/ccsrc/python/quafubackend/lib/details/define_terms_ops.h" "syntaxError" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_policy.cpp" "syntaxError" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_condition.cpp" "syntaxError" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_gate_expect.cpp" "syntaxError" + +"quafu/ccsrc/include/core/numba_wrapper.h" "uninitMemberVar" + +"quafu/ccsrc/include/core/sparse/paulimat.h" "unknownMacro" +"quafu/ccsrc/include/core/sparse/paulimat.h:58" "unknownMacro" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_matrix_gate.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_condition.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_dot_like.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_gate_expect.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_matrix_gate.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_policy.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_rot_pauli.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_swap_like.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_x_like.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_z_like.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_policy.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_z_like.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_x_like.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_channel.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_matrix_gate.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_rot_pauli.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_swap_like.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_gate_expect.cpp" "unknownMacro" +"quafu/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_matrix_gate.cpp" "unknownMacro" +"quafu/ccsrc/include/simulator/vector/detail/cpu_vector_policy.h" "unknownMacro" +"quafu/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" "unknownMacro" + +"quafu/ccsrc/include/config/tsl_ordered_map.h" "useStlAlgorithm" +"quafu/ccsrc/include/ops/gates/terms_coeff_dict.h" "useStlAlgorithm" +"quafu/ccsrc/include/ops/gates/terms_operator_base.tpp" "useStlAlgorithm" + +"quafu/tests/core/test_circuit_block.cpp" "ctuOneDefinitionRuleViolation" + +"quafu/ccsrc/include/simulator/vector/vector_state.tpp" "cppcheckError" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp" "syntaxError" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_condition.cpp" "syntaxError" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_dot_like.cpp" "syntaxError" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_gate_expect.cpp" "syntaxError" +"quafu/ccsrc/python/quafubackend/lib/binding.cc" "syntaxError" +"quafu/ccsrc/include/simulator/stabilizer/stabilizer.h" "unusedStructMember" diff --git a/.jenkins/check/config/filter_cpplint.txt b/.jenkins/check/config/filter_cpplint.txt index 91e99af89..5751d7a82 100644 --- a/.jenkins/check/config/filter_cpplint.txt +++ b/.jenkins/check/config/filter_cpplint.txt @@ -1,48 +1,48 @@ -# MindQuantum -"mindquantum/tests/cmake-ldtest" "whitespace/braces" - -"mindquantum/ccsrc" "build/include_order" -"mindquantum/ccsrc" "readability/nolint" -"mindquantum/ccsrc" "whitespace/braces" -"mindquantum/ccsrc" "whitespace/comments" - -"mindquantum/tests" "build/include_order" -"mindquantum/tests" "build/namespaces" -"mindquantum/tests" "build/namespaces_literals" -"mindquantum/tests" "readability/braces" -"mindquantum/tests" "readability/check" -"mindquantum/tests" "runtime/explicit" -"mindquantum/tests" "runtime/references" - - -"mindquantum/ccsrc" "build/include_subdir" -"mindquantum/ccsrc/gate" "build/include_subdir" -"mindquantum/ccsrc/hamiltonian" "build/include_subdir" -"mindquantum/ccsrc/matrix" "build/include_subdir" -"mindquantum/ccsrc/pr" "build/include_subdir" -"mindquantum/ccsrc/projector" "build/include_subdir" -"mindquantum/ccsrc/sparse" "build/include_subdir" - -"mindquantum/ccsrc/python/mqbackend/lib/logging.cpp" "build/namespaces_literals" -"mindquantum/ccsrc/python/mqbackend/lib/logging.cpp" "runtime/references" -"mindquantum/ccsrc/python/mqbackend/lib/binding.cc" "runtime/references" -"mindquantum/ccsrc/python/mqbackend/lib/build_env.cpp" "runtime/references" - - -"mindquantum/ccsrc/include/simulator/vector/detail/cpu_vector_policy.h" "readability/casting" -"mindquantum/ccsrc/include/core/parameter_resolver.h" "build/include" - -"mindquantum/ccsrc/include/simulator/alignedallocator.h" "whitespace/parens" -"mindquantum/ccsrc/lib/math/operators/transform/bravyi_kitaev_superfast.cpp" "runtime/references" -"mindquantum/ccsrc/python/math/lib/bind_math.cpp" "runtime/references" -"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_policy.cpp" "runtime/references" -"mindquantum/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_policy.cu" "runtime/references" -"mindquantum/ccsrc/include/simulator/vector/detail/cpu_vector_policy.h" "runtime/references" -"mindquantum/ccsrc/include/math/operators/qubit_operator_view.h" "runtime/references" -"mindquantum/tests/cmake-ldtest/shared_test.cpp" "build/include_subdir" -"mindquantum/ccsrc/include/config/format/std_complex.h" "runtime/references" -"mindquantum/ccsrc/include/device/mapping.h" "runtime/references" -"mindquantum/ccsrc/include/config/format/std_optional.h" "runtime/references" -"mindquantum/ccsrc/include/config/tsl_ordered_map.h" "runtime/references" -"mindquantum/ccsrc/include/math/operators/fermion_operator_view.h" "runtime/references" -"mindquantum/tests/cmake-ldtest/shared_lib.cpp" "build/include_subdir" +# quafu +"quafu/tests/cmake-ldtest" "whitespace/braces" + +"quafu/ccsrc" "build/include_order" +"quafu/ccsrc" "readability/nolint" +"quafu/ccsrc" "whitespace/braces" +"quafu/ccsrc" "whitespace/comments" + +"quafu/tests" "build/include_order" +"quafu/tests" "build/namespaces" +"quafu/tests" "build/namespaces_literals" +"quafu/tests" "readability/braces" +"quafu/tests" "readability/check" +"quafu/tests" "runtime/explicit" +"quafu/tests" "runtime/references" + + +"quafu/ccsrc" "build/include_subdir" +"quafu/ccsrc/gate" "build/include_subdir" +"quafu/ccsrc/hamiltonian" "build/include_subdir" +"quafu/ccsrc/matrix" "build/include_subdir" +"quafu/ccsrc/pr" "build/include_subdir" +"quafu/ccsrc/projector" "build/include_subdir" +"quafu/ccsrc/sparse" "build/include_subdir" + +"quafu/ccsrc/python/quafubackend/lib/logging.cpp" "build/namespaces_literals" +"quafu/ccsrc/python/quafubackend/lib/logging.cpp" "runtime/references" +"quafu/ccsrc/python/quafubackend/lib/binding.cc" "runtime/references" +"quafu/ccsrc/python/quafubackend/lib/build_env.cpp" "runtime/references" + + +"quafu/ccsrc/include/simulator/vector/detail/cpu_vector_policy.h" "readability/casting" +"quafu/ccsrc/include/core/parameter_resolver.h" "build/include" + +"quafu/ccsrc/include/simulator/alignedallocator.h" "whitespace/parens" +"quafu/ccsrc/lib/math/operators/transform/bravyi_kitaev_superfast.cpp" "runtime/references" +"quafu/ccsrc/python/math/lib/bind_math.cpp" "runtime/references" +"quafu/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_policy.cpp" "runtime/references" +"quafu/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_policy.cu" "runtime/references" +"quafu/ccsrc/include/simulator/vector/detail/cpu_vector_policy.h" "runtime/references" +"quafu/ccsrc/include/math/operators/qubit_operator_view.h" "runtime/references" +"quafu/tests/cmake-ldtest/shared_test.cpp" "build/include_subdir" +"quafu/ccsrc/include/config/format/std_complex.h" "runtime/references" +"quafu/ccsrc/include/device/mapping.h" "runtime/references" +"quafu/ccsrc/include/config/format/std_optional.h" "runtime/references" +"quafu/ccsrc/include/config/tsl_ordered_map.h" "runtime/references" +"quafu/ccsrc/include/math/operators/fermion_operator_view.h" "runtime/references" +"quafu/tests/cmake-ldtest/shared_lib.cpp" "build/include_subdir" diff --git a/.jenkins/check/config/filter_pylint.txt b/.jenkins/check/config/filter_pylint.txt index 981fe41cf..ef5bb3700 100644 --- a/.jenkins/check/config/filter_pylint.txt +++ b/.jenkins/check/config/filter_pylint.txt @@ -1,67 +1,67 @@ -# MindQuantum -"mindquantum" "ungrouped-imports" -"mindquantum" "bad-continuation" -"mindquantum" "bad-whitespace" -"mindquantum/mindquantum/framework" "unused-argument" -"mindquantum/mindquantum/framework" "arguments-differ" -"mindquantum/setup.py" "invalid-name" -"mindquantum/setup.py" "missing-docstring" -"mindquantum/setup.py" "wrong-import-order" -"mindquantum/mindquantum/framework/_check_qnn_input.py" "duplicate-string-formatting-argument" -"mindquantum/mindquantum/core/ops/_base_operator.py" "bare-except" -"mindquantum/mindquantum/algorithm/nisq" "arguments-differ" -"mindquantum/mindquantum/framework" "missing-docstring" -"mindquantum/mindquantum/io/display/circuit_svg_drawer.py" "abstract-method" -"mindquantum/mindquantum/core/gates" "abstract-method" -"mindquantum/mindquantum/core/gates" "unused-argument" -"mindquantum/mindquantum/core/gates" "missing-docstring" -"mindquantum/mindquantum/config/config.py" "invalid-name" -"mindquantum/mindquantum/core/gates/basicgate.py" "arguments-differ" -"mindquantum/mindquantum/core/gates/basic.py" "arguments-differ" -"mindquantum/mindquantum/io/display/bloch_plt_drawer.py" "protected-access" -"mindquantum/mindquantum/core/_arithmetic_ops_adaptor.py" "protected-access" -"mindquantum/mindquantum/core/operators/_term_value.py" "invalid-name" -"mindquantum/mindquantum/core/operators/_terms_operators.py" "no-member" -"mindquantum/mindquantum/core/operators/_terms_operators.py" "no-value-for-parameter" -"mindquantum/mindquantum/core/operators/fermion_operator.py" "unused-import" -"mindquantum/mindquantum/core/operators/qubit_operator.py" "unused-import" -"mindquantum/mindquantum/core/gates/basicgate.py" "useless-super-delegation" +# quafu +"quafu" "ungrouped-imports" +"quafu" "bad-continuation" +"quafu" "bad-whitespace" +"quafu/quafu/framework" "unused-argument" +"quafu/quafu/framework" "arguments-differ" +"quafu/setup.py" "invalid-name" +"quafu/setup.py" "missing-docstring" +"quafu/setup.py" "wrong-import-order" +"quafu/quafu/framework/_check_qnn_input.py" "duplicate-string-formatting-argument" +"quafu/quafu/core/ops/_base_operator.py" "bare-except" +"quafu/quafu/algorithm/nisq" "arguments-differ" +"quafu/quafu/framework" "missing-docstring" +"quafu/quafu/io/display/circuit_svg_drawer.py" "abstract-method" +"quafu/quafu/core/gates" "abstract-method" +"quafu/quafu/core/gates" "unused-argument" +"quafu/quafu/core/gates" "missing-docstring" +"quafu/quafu/config/config.py" "invalid-name" +"quafu/quafu/core/gates/basicgate.py" "arguments-differ" +"quafu/quafu/core/gates/basic.py" "arguments-differ" +"quafu/quafu/io/display/bloch_plt_drawer.py" "protected-access" +"quafu/quafu/core/_arithmetic_ops_adaptor.py" "protected-access" +"quafu/quafu/core/operators/_term_value.py" "invalid-name" +"quafu/quafu/core/operators/_terms_operators.py" "no-member" +"quafu/quafu/core/operators/_terms_operators.py" "no-value-for-parameter" +"quafu/quafu/core/operators/fermion_operator.py" "unused-import" +"quafu/quafu/core/operators/qubit_operator.py" "unused-import" +"quafu/quafu/core/gates/basicgate.py" "useless-super-delegation" -"mindquantum/setup.py" "deprecated-module" -"mindquantum/setup.py" "attribute-defined-outside-init" +"quafu/setup.py" "deprecated-module" +"quafu/setup.py" "attribute-defined-outside-init" # Documentation -"mindquantum/docs" "invalid-name" -"mindquantum/docs" "redefined-builtin" +"quafu/docs" "invalid-name" +"quafu/docs" "redefined-builtin" # Tests -"mindquantum/tests/st" "missing-docstring" -"mindquantum/tests/st" "pointless-statement" -"mindquantum/tests/st" "unused-variable" -"mindquantum/tests/st" "len-as-condition" -"mindquantum/tests/ut" "missing-docstring" -"mindquantum/tests/st" "wrong-import-position" -"mindquantum/tests/st" "protected-access" -"mindquantum/tests/st" "c-extension-no-member" +"quafu/tests/st" "missing-docstring" +"quafu/tests/st" "pointless-statement" +"quafu/tests/st" "unused-variable" +"quafu/tests/st" "len-as-condition" +"quafu/tests/ut" "missing-docstring" +"quafu/tests/st" "wrong-import-position" +"quafu/tests/st" "protected-access" +"quafu/tests/st" "c-extension-no-member" # Benchmarks -"mindquantum/tutorials/benchmarks" "wrong-import-position" -"mindquantum/tutorials/benchmarks" "redefined-outer-name" -"mindquantum/tutorials/benchmarks" "protected-access" -"mindquantum/tutorials/benchmarks" "missing-docstring" -"mindquantum/tutorials/benchmarks" "unused-argument" +"quafu/tutorials/benchmarks" "wrong-import-position" +"quafu/tutorials/benchmarks" "redefined-outer-name" +"quafu/tutorials/benchmarks" "protected-access" +"quafu/tutorials/benchmarks" "missing-docstring" +"quafu/tutorials/benchmarks" "unused-argument" # Tutorials -"mindquantum/tutorials" "missing-docstring" -"mindquantum/tutorials" "wrong-import-position" -"mindquantum/tutorials" "unused-argument" -"mindquantum/tutorials" "redefined-outer-name" -"mindquantum/tutorials" "pointless-statement" -"mindquantum/tutorials" "reimported" -"mindquantum/tutorials" "expression-not-assigned" -"mindquantum/tutorials" "function-redefined" -"mindquantum/tutorials" "unused-variable" -"mindquantum/tutorials" "len-as-condition" -"mindquantum/tutorials" "superfluous-parens" -"mindquantum/tutorials" "invalid-name" -"mindquantum/tutorials" "unused-import" +"quafu/tutorials" "missing-docstring" +"quafu/tutorials" "wrong-import-position" +"quafu/tutorials" "unused-argument" +"quafu/tutorials" "redefined-outer-name" +"quafu/tutorials" "pointless-statement" +"quafu/tutorials" "reimported" +"quafu/tutorials" "expression-not-assigned" +"quafu/tutorials" "function-redefined" +"quafu/tutorials" "unused-variable" +"quafu/tutorials" "len-as-condition" +"quafu/tutorials" "superfluous-parens" +"quafu/tutorials" "invalid-name" +"quafu/tutorials" "unused-import" diff --git a/.jenkins/check/config/gen_cppcheck.bash b/.jenkins/check/config/gen_cppcheck.bash index 584819ce2..949d67032 100755 --- a/.jenkins/check/config/gen_cppcheck.bash +++ b/.jenkins/check/config/gen_cppcheck.bash @@ -27,13 +27,13 @@ while read -r line; do # -> for ms-pipeline it should be sufficient to remove the trailing `*` warn_id="${BASH_REMATCH[1]}" file_location="${BASH_REMATCH[2]}/" # NB: BASH_REMATCH[2] is the folder without the trailing '/*' - file_location_print=$(printf '"%s"' "mindquantum/$file_location") + file_location_print=$(printf '"%s"' "quafu/$file_location") printf '%-90s "%s"\n' "$file_location_print" "$warn_id" elif [[ "$line" =~ ([a-zA-Z_]+):(.*) ]]; then # Match lines like this: 'XXXX:path/to/file' warn_id="${BASH_REMATCH[1]}" file_location="${BASH_REMATCH[2]}" - file_location_print=$(printf '"%s"' "mindquantum/$file_location") + file_location_print=$(printf '"%s"' "quafu/$file_location") printf '%-90s "%s"\n' "$file_location_print" "$warn_id" elif [[ "$line" =~ ([^:]+) ]]; then # Match lines like this: 'XXXX' (ie. only naked CppCheck warning) diff --git a/.jenkins/check/config/gen_lizard.bash b/.jenkins/check/config/gen_lizard.bash index c034b3494..84a04eba8 100755 --- a/.jenkins/check/config/gen_lizard.bash +++ b/.jenkins/check/config/gen_lizard.bash @@ -14,8 +14,8 @@ while read -r line; do echo '' elif [[ "$line" =~ ^#.* ]]; then echo "$line" - elif [[ "$line" =~ ^(mindquantum|ccsrc|tests)/(.*) ]]; then - printf "mindquantum/%s/%s\n" "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" + elif [[ "$line" =~ ^(quafu|ccsrc|tests)/(.*) ]]; then + printf "quafu/%s/%s\n" "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" else echo "$line" fi diff --git a/.jenkins/check/config/whitelizard.txt b/.jenkins/check/config/whitelizard.txt index 98c2336ae..1b337edf3 100644 --- a/.jenkins/check/config/whitelizard.txt +++ b/.jenkins/check/config/whitelizard.txt @@ -4,58 +4,58 @@ # file_path:function_name1, function_name2 # _build/backend.py:build_wheel -mindquantum/mindquantum/_build/backend.py:build_wheel -mindquantum/mindquantum/algorithm/nisq/chem/qubit_ucc_ansatz.py:_implement -mindquantum/mindquantum/algorithm/nisq/chem/quccsd.py:quccsd_generator -mindquantum/mindquantum/algorithm/nisq/chem/transform.py:bravyi_kitaev_superfast -mindquantum/mindquantum/algorithm/nisq/chem/uccsd.py:_para_uccsd_singlet_generator -mindquantum/mindquantum/algorithm/nisq/chem/uccsd0.py:uccsd0_singlet_generator -mindquantum/mindquantum/core/circuit/qfi.py:_qfi_matrix_base -mindquantum/mindquantum/core/gates/basicgate.py:gene_univ_parameterized_gate -mindquantum/mindquantum/io/display/bloch_plt_drawer.py:add_state -mindquantum/mindquantum/io/qasm/hiqasm.py:to_string -mindquantum/mindquantum/io/qasm/hiqasm.py:trans_v01 -mindquantum/mindquantum/io/qasm/openqasm.py:to_string -mindquantum/mindquantum/io/qasm/qcis.py:to_string -mindquantum/mindquantum/simulator/mqsim.py:get_expectation_with_grad -mindquantum/mindquantum/simulator/mqsim.py:grad_ops -mindquantum/mindquantum/simulator/simulator.py:get_expectation_with_grad -mindquantum/mindquantum/third_party/unitary_cc.py:uccsd_singlet_generator -mindquantum/mindquantum/io/display/circuit_text_drawer.py:brick_model -mindquantum/algorithm/compiler/decompose/universal_decompose/two_qubit_decompose.py:kak_decompose -mindquantum/mindquantum/io/qasm/openqasm.py:__init__ -mindquantum/mindquantum/algorithm/compiler/rules/basic_decompose.py:decom_basic_gate -mindquantum/mindquantum/algorithm/nisq/chem/reference_state.py:get_reference_circuit -mindquantum/mindquantum/io/display/circuit_text_drawer.py:rich_circuit -mindquantum/mindquantum/utils/f.py:random_insert_gates +quafu/quafu/_build/backend.py:build_wheel +quafu/quafu/algorithm/nisq/chem/qubit_ucc_ansatz.py:_implement +quafu/quafu/algorithm/nisq/chem/quccsd.py:quccsd_generator +quafu/quafu/algorithm/nisq/chem/transform.py:bravyi_kitaev_superfast +quafu/quafu/algorithm/nisq/chem/uccsd.py:_para_uccsd_singlet_generator +quafu/quafu/algorithm/nisq/chem/uccsd0.py:uccsd0_singlet_generator +quafu/quafu/core/circuit/qfi.py:_qfi_matrix_base +quafu/quafu/core/gates/basicgate.py:gene_univ_parameterized_gate +quafu/quafu/io/display/bloch_plt_drawer.py:add_state +quafu/quafu/io/qasm/hiqasm.py:to_string +quafu/quafu/io/qasm/hiqasm.py:trans_v01 +quafu/quafu/io/qasm/openqasm.py:to_string +quafu/quafu/io/qasm/qcis.py:to_string +quafu/quafu/simulator/quafusim.py:get_expectation_with_grad +quafu/quafu/simulator/quafusim.py:grad_ops +quafu/quafu/simulator/simulator.py:get_expectation_with_grad +quafu/quafu/third_party/unitary_cc.py:uccsd_singlet_generator +quafu/quafu/io/display/circuit_text_drawer.py:brick_model +quafu/algorithm/compiler/decompose/universal_decompose/two_qubit_decompose.py:kak_decompose +quafu/quafu/io/qasm/openqasm.py:__init__ +quafu/quafu/algorithm/compiler/rules/basic_decompose.py:decom_basic_gate +quafu/quafu/algorithm/nisq/chem/reference_state.py:get_reference_circuit +quafu/quafu/io/display/circuit_text_drawer.py:rich_circuit +quafu/quafu/utils/f.py:random_insert_gates -mindquantum/ccsrc/lib/simulator/stabilizer/stabilizer.cpp:mindquantum::stabilizer::StabilizerTableau::Decompose -mindquantum/ccsrc/include/simulator/vector/vector_state.tpp:mindquantum::sim::vector::detail::VectorState::GetExpectationWithGradParameterShiftOneMulti -mindquantum/ccsrc/include/ops/gates.h:mindquantum::GetGateByName -mindquantum/ccsrc/include/ops/gates/qubit_operator.tpp:mindquantum::ops::QubitOperator::sparse_matrix -mindquantum/ccsrc/include/ops/gates/qubit_operator.tpp:mindquantum::ops::mindquantum::ops::QubitOperator::get_op_matrix.QubitOperator::sparse_matrix -mindquantum/ccsrc/mindquantum/src/binding.cc:mindquantum::PYBIND11_MODULE -mindquantum/ccsrc/python/mqbackend/lib/binding.cc:PYBIND11_MODULE -mindquantum/ccsrc/python/mqbackend/lib/fermion_operators.cpp:init_fermion_operators -mindquantum/ccsrc/python/mqbackend/lib/qubit_operators.cpp:init_qubit_operators -mindquantum/ccsrc/python/mqbackend/lib/terms_operators.cpp:init_terms_operators -mindquantum/ccsrc/python/mqbackend/lib/binding.cc:BindOther -mindquantum/ccsrc/python/mqbackend/lib/binding.cc:init_fermion_operators -mindquantum/ccsrc/python/mqbackend/lib/binding.cc:init_qubit_operators -mindquantum/ccsrc/lib/simulator/vector/detail/runtime/cmd.cpp:mindquantum::sim::rt::cmd -mindquantum/ccsrc/include/math/tensor/ops_cpu/advance_math.h:tensor::ops::cpu::ElementFunc -mindquantum/mindquantum/core/parameterresolver/parameterresolver.py:__init__ -mindquantum/ccsrc/python/math/lib/bind_math.cpp:mindquantum::python::BindQubitOperator -ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp:mindquantum::sim::vector::detail::CPUVectorPolicyAvxDouble::ExpectDiffSingleQubitMatrix -mindquantum/ccsrc/lib/device/mapping.cpp:mindquantum::mapping::MQ_SABRE::InitialMapping -mindquantum/ccsrc/lib/device/mapping.cpp:mindquantum::mapping::MQ_SABRE::HeuristicSearch -mindquantum/ccsrc/lib/device/mapping.cpp:mindquantum::mapping::MQ_SABRE::MQ_SABRE +quafu/ccsrc/lib/simulator/stabilizer/stabilizer.cpp:quafu::stabilizer::StabilizerTableau::Decompose +quafu/ccsrc/include/simulator/vector/vector_state.tpp:quafu::sim::vector::detail::VectorState::GetExpectationWithGradParameterShiftOneMulti +quafu/ccsrc/include/ops/gates.h:quafu::GetGateByName +quafu/ccsrc/include/ops/gates/qubit_operator.tpp:quafu::ops::QubitOperator::sparse_matrix +quafu/ccsrc/include/ops/gates/qubit_operator.tpp:quafu::ops::quafu::ops::QubitOperator::get_op_matrix.QubitOperator::sparse_matrix +quafu/ccsrc/quafu/src/binding.cc:quafu::PYBIND11_MODULE +quafu/ccsrc/python/quafubackend/lib/binding.cc:PYBIND11_MODULE +quafu/ccsrc/python/quafubackend/lib/fermion_operators.cpp:init_fermion_operators +quafu/ccsrc/python/quafubackend/lib/qubit_operators.cpp:init_qubit_operators +quafu/ccsrc/python/quafubackend/lib/terms_operators.cpp:init_terms_operators +quafu/ccsrc/python/quafubackend/lib/binding.cc:BindOther +quafu/ccsrc/python/quafubackend/lib/binding.cc:init_fermion_operators +quafu/ccsrc/python/quafubackend/lib/binding.cc:init_qubit_operators +quafu/ccsrc/lib/simulator/vector/detail/runtime/cmd.cpp:quafu::sim::rt::cmd +quafu/ccsrc/include/math/tensor/ops_cpu/advance_math.h:tensor::ops::cpu::ElementFunc +quafu/quafu/core/parameterresolver/parameterresolver.py:__init__ +quafu/ccsrc/python/math/lib/bind_math.cpp:quafu::python::BindQubitOperator +ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp:quafu::sim::vector::detail::CPUVectorPolicyAvxDouble::ExpectDiffSingleQubitMatrix +quafu/ccsrc/lib/device/mapping.cpp:quafu::mapping::QUAFU_SABRE::InitialMapping +quafu/ccsrc/lib/device/mapping.cpp:quafu::mapping::QUAFU_SABRE::HeuristicSearch +quafu/ccsrc/lib/device/mapping.cpp:quafu::mapping::QUAFU_SABRE::QUAFU_SABRE TEST_CASE -mindquantum::sim::vector::detail::VectorState::ApplyGate -mindquantum::sim::vector::detail::VectorState::LeftSizeGradOneMulti -mindquantum::sim::densitymatrix::detail::DensityMatrixState::ApplyGate -mindquantum::sim::densitymatrix::detail::DensityMatrixState::GetExpectationWithReversibleGradOneMulti +quafu::sim::vector::detail::VectorState::ApplyGate +quafu::sim::vector::detail::VectorState::LeftSizeGradOneMulti +quafu::sim::densitymatrix::detail::DensityMatrixState::ApplyGate +quafu::sim::densitymatrix::detail::DensityMatrixState::GetExpectationWithReversibleGradOneMulti DummyOperator::TermsOperator::operator == ; } ; } using coefficient_t = DummyOperator :: coefficient_t ; using coeff_term_dict_t = DummyOperator :: coeff_term_dict_t ; TEST_CASE -mindquantum::ops::details::mindquantum::ops::details::pauli_products.QubitOperatorTermPolicy::simplify -mindquantum/tests/st/test_io/test_svg.py:test_measure_svg -mindquantum/tests/st/test_simulator/test_basic_gate_with_simulator.py:test_custom_gate_expectation_with_grad +quafu::ops::details::quafu::ops::details::pauli_products.QubitOperatorTermPolicy::simplify +quafu/tests/st/test_io/test_svg.py:test_measure_svg +quafu/tests/st/test_simulator/test_basic_gate_with_simulator.py:test_custom_gate_expectation_with_grad diff --git a/.pre-commit-config-format-gitee.yml b/.pre-commit-config-format-gitee.yml index 3e7f8b65b..749bfbea8 100644 --- a/.pre-commit-config-format-gitee.yml +++ b/.pre-commit-config-format-gitee.yml @@ -56,10 +56,10 @@ repos: alias: doc8-lint require_serial: false additional_dependencies: [tomli] - args: [--ignore-path-errors, docs/api_python/mindquantum.algorithm.nisq.uccsd0_singlet_generator.rst;D001, - --ignore-path-errors, docs/api_python/mindquantum.algorithm.nisq.quccsd_generator.rst;D001, + args: [--ignore-path-errors, docs/api_python/quafu.algorithm.nisq.uccsd0_singlet_generator.rst;D001, + --ignore-path-errors, docs/api_python/quafu.algorithm.nisq.quccsd_generator.rst;D001, --ignore-path-errors, - docs/api_python/mindquantum.algorithm.nisq.uccsd_singlet_get_packed_amplitudes.rst;D001] + docs/api_python/quafu.algorithm.nisq.uccsd_singlet_get_packed_amplitudes.rst;D001] - repo: https://gitee.com/dnguyen/shellcheck-py-mirror.git rev: v0.8.0.4 diff --git a/.pre-commit-config-format.yml b/.pre-commit-config-format.yml index 70d2f27ed..4bfa4764e 100644 --- a/.pre-commit-config-format.yml +++ b/.pre-commit-config-format.yml @@ -56,10 +56,10 @@ repos: alias: doc8-lint require_serial: false additional_dependencies: [tomli] - args: [--ignore-path-errors, docs/api_python/mindquantum.algorithm.nisq.uccsd0_singlet_generator.rst;D001, - --ignore-path-errors, docs/api_python/mindquantum.algorithm.nisq.quccsd_generator.rst;D001, + args: [--ignore-path-errors, docs/api_python/quafu.algorithm.nisq.uccsd0_singlet_generator.rst;D001, + --ignore-path-errors, docs/api_python/quafu.algorithm.nisq.quccsd_generator.rst;D001, --ignore-path-errors, - docs/api_python/mindquantum.algorithm.nisq.uccsd_singlet_get_packed_amplitudes.rst;D001] + docs/api_python/quafu.algorithm.nisq.uccsd_singlet_get_packed_amplitudes.rst;D001] - repo: https://github.com/shellcheck-py/shellcheck-py rev: v0.8.0.4 diff --git a/.pre-commit-config-gitee.yaml b/.pre-commit-config-gitee.yaml index 1df2e1298..968f20967 100644 --- a/.pre-commit-config-gitee.yaml +++ b/.pre-commit-config-gitee.yaml @@ -59,10 +59,10 @@ repos: alias: doc8-lint require_serial: false additional_dependencies: [tomli] - args: [--ignore-path-errors, docs/api_python/mindquantum.algorithm.nisq.uccsd0_singlet_generator.rst;D001, - --ignore-path-errors, docs/api_python/mindquantum.algorithm.nisq.quccsd_generator.rst;D001, + args: [--ignore-path-errors, docs/api_python/quafu.algorithm.nisq.uccsd0_singlet_generator.rst;D001, + --ignore-path-errors, docs/api_python/quafu.algorithm.nisq.quccsd_generator.rst;D001, --ignore-path-errors, - docs/api_python/mindquantum.algorithm.nisq.uccsd_singlet_get_packed_amplitudes.rst;D001] + docs/api_python/quafu.algorithm.nisq.uccsd_singlet_get_packed_amplitudes.rst;D001] - repo: https://gitee.com/dnguyen/shellcheck-py-mirror.git rev: v0.8.0.4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index faaf19a80..ba410e675 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -59,10 +59,10 @@ repos: alias: doc8-lint require_serial: false additional_dependencies: [tomli] - args: [--ignore-path-errors, docs/api_python/mindquantum.algorithm.nisq.uccsd0_singlet_generator.rst;D001, - --ignore-path-errors, docs/api_python/mindquantum.algorithm.nisq.quccsd_generator.rst;D001, + args: [--ignore-path-errors, docs/api_python/quafu.algorithm.nisq.uccsd0_singlet_generator.rst;D001, + --ignore-path-errors, docs/api_python/quafu.algorithm.nisq.quccsd_generator.rst;D001, --ignore-path-errors, - docs/api_python/mindquantum.algorithm.nisq.uccsd_singlet_get_packed_amplitudes.rst;D001] + docs/api_python/quafu.algorithm.nisq.uccsd_singlet_get_packed_amplitudes.rst;D001] - repo: https://github.com/shellcheck-py/shellcheck-py rev: v0.8.0.4 diff --git a/.whitelizard.txt b/.whitelizard.txt index 748c7a02c..4b8259966 100644 --- a/.whitelizard.txt +++ b/.whitelizard.txt @@ -4,60 +4,60 @@ # file_path:function_name1, function_name2 # _build/backend.py:build_wheel -mindquantum/_build/backend.py:build_wheel -mindquantum/algorithm/nisq/chem/qubit_ucc_ansatz.py:_implement -mindquantum/algorithm/nisq/chem/quccsd.py:quccsd_generator -mindquantum/algorithm/nisq/chem/transform.py:bravyi_kitaev_superfast -mindquantum/algorithm/nisq/chem/uccsd.py:_para_uccsd_singlet_generator -mindquantum/algorithm/nisq/chem/uccsd0.py:uccsd0_singlet_generator -mindquantum/core/circuit/qfi.py:_qfi_matrix_base -mindquantum/core/gates/basicgate.py:gene_univ_parameterized_gate -mindquantum/io/display/bloch_plt_drawer.py:add_state -mindquantum/io/qasm/hiqasm.py:to_string -mindquantum/io/qasm/hiqasm.py:trans_v01 -mindquantum/io/qasm/openqasm.py:to_string -mindquantum/io/qasm/qcis.py:to_string -mindquantum/simulator/mqsim.py:get_expectation_with_grad -mindquantum/simulator/mqsim.py:grad_ops -mindquantum/simulator/simulator.py:get_expectation_with_grad -mindquantum/third_party/unitary_cc.py:uccsd_singlet_generator -mindquantum/io/display/circuit_text_drawer.py:brick_model -mindquantum/core/parameterresolver/parameterresolver.py:__init__ -mindquantum/algorithm/compiler/decompose/universal_decompose/two_qubit_decompose.py:kak_decompose -mindquantum/simulator/mqsim.py:get_expectation_with_grad.grad_ops -mindquantum/io/qasm/openqasm.py:__init__ -mindquantum/algorithm/compiler/rules/basic_decompose.py:decom_basic_gate -mindquantum/algorithm/nisq/chem/reference_state.py:get_reference_circuit -mindquantum/io/display/circuit_text_drawer.py:rich_circuit -mindquantum/utils/f.py:random_insert_gates +quafu/_build/backend.py:build_wheel +quafu/algorithm/nisq/chem/qubit_ucc_ansatz.py:_implement +quafu/algorithm/nisq/chem/quccsd.py:quccsd_generator +quafu/algorithm/nisq/chem/transform.py:bravyi_kitaev_superfast +quafu/algorithm/nisq/chem/uccsd.py:_para_uccsd_singlet_generator +quafu/algorithm/nisq/chem/uccsd0.py:uccsd0_singlet_generator +quafu/core/circuit/qfi.py:_qfi_matrix_base +quafu/core/gates/basicgate.py:gene_univ_parameterized_gate +quafu/io/display/bloch_plt_drawer.py:add_state +quafu/io/qasm/hiqasm.py:to_string +quafu/io/qasm/hiqasm.py:trans_v01 +quafu/io/qasm/openqasm.py:to_string +quafu/io/qasm/qcis.py:to_string +quafu/simulator/quafusim.py:get_expectation_with_grad +quafu/simulator/quafusim.py:grad_ops +quafu/simulator/simulator.py:get_expectation_with_grad +quafu/third_party/unitary_cc.py:uccsd_singlet_generator +quafu/io/display/circuit_text_drawer.py:brick_model +quafu/core/parameterresolver/parameterresolver.py:__init__ +quafu/algorithm/compiler/decompose/universal_decompose/two_qubit_decompose.py:kak_decompose +quafu/simulator/quafusim.py:get_expectation_with_grad.grad_ops +quafu/io/qasm/openqasm.py:__init__ +quafu/algorithm/compiler/rules/basic_decompose.py:decom_basic_gate +quafu/algorithm/nisq/chem/reference_state.py:get_reference_circuit +quafu/io/display/circuit_text_drawer.py:rich_circuit +quafu/utils/f.py:random_insert_gates -ccsrc/lib/simulator/stabilizer/stabilizer.cpp:mindquantum::stabilizer::StabilizerTableau::Decompose -ccsrc/include/simulator/vector/vector_state.tpp:mindquantum::sim::vector::detail::VectorState::GetExpectationWithGradParameterShiftOneMulti -ccsrc/include/ops/gates.h:mindquantum::GetGateByName -ccsrc/include/ops/gates/qubit_operator.tpp:mindquantum::ops::QubitOperator::sparse_matrix -ccsrc/include/ops/gates/qubit_operator.tpp:mindquantum::ops::mindquantum::ops::QubitOperator::get_op_matrix.QubitOperator::sparse_matrix -ccsrc/mindquantum/src/binding.cc:mindquantum::PYBIND11_MODULE -ccsrc/python/mqbackend/lib/binding.cc:init_qubit_operators -ccsrc/python/mqbackend/lib/binding.cc:init_fermion_operators -ccsrc/python/mqbackend/lib/binding.cc:BindOther -ccsrc/python/mqbackend/lib/fermion_operators.cpp:init_fermion_operators -ccsrc/python/mqbackend/lib/qubit_operators.cpp:init_qubit_operators -ccsrc/python/mqbackend/lib/terms_operators.cpp:init_terms_operators -ccsrc/lib/simulator/vector/detail/runtime/cmd.cpp:mindquantum::sim::rt::cmd -ccsrc/python/math/lib/bind_math.cpp:mindquantum::python::BindQubitOperator +ccsrc/lib/simulator/stabilizer/stabilizer.cpp:quafu::stabilizer::StabilizerTableau::Decompose +ccsrc/include/simulator/vector/vector_state.tpp:quafu::sim::vector::detail::VectorState::GetExpectationWithGradParameterShiftOneMulti +ccsrc/include/ops/gates.h:quafu::GetGateByName +ccsrc/include/ops/gates/qubit_operator.tpp:quafu::ops::QubitOperator::sparse_matrix +ccsrc/include/ops/gates/qubit_operator.tpp:quafu::ops::quafu::ops::QubitOperator::get_op_matrix.QubitOperator::sparse_matrix +ccsrc/quafu/src/binding.cc:quafu::PYBIND11_MODULE +ccsrc/python/quafubackend/lib/binding.cc:init_qubit_operators +ccsrc/python/quafubackend/lib/binding.cc:init_fermion_operators +ccsrc/python/quafubackend/lib/binding.cc:BindOther +ccsrc/python/quafubackend/lib/fermion_operators.cpp:init_fermion_operators +ccsrc/python/quafubackend/lib/qubit_operators.cpp:init_qubit_operators +ccsrc/python/quafubackend/lib/terms_operators.cpp:init_terms_operators +ccsrc/lib/simulator/vector/detail/runtime/cmd.cpp:quafu::sim::rt::cmd +ccsrc/python/math/lib/bind_math.cpp:quafu::python::BindQubitOperator ccsrc/include/math/tensor/ops_cpu/advance_math.h:tensor::ops::cpu::ElementFunc -ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp:mindquantum::sim::vector::detail::CPUVectorPolicyAvxDouble::ExpectDiffSingleQubitMatrix -ccsrc/lib/device/mapping.cpp:mindquantum::mapping::MQ_SABRE::InitialMapping -ccsrc/lib/device/mapping.cpp:mindquantum::mapping::MQ_SABRE::HeuristicSearch -ccsrc/lib/device/mapping.cpp:mindquantum::mapping::MQ_SABRE::MQ_SABRE -ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_swap_like.cpp:mindquantum::sim::densitymatrix::detail::CPUDensityMatrixPolicyBase::ApplySWAP -ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_gate_expect.cpp:mindquantum::sim::densitymatrix::detail::CPUDensityMatrixPolicyBase::ExpectDiffTwoQubitsMatrix +ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp:quafu::sim::vector::detail::CPUVectorPolicyAvxDouble::ExpectDiffSingleQubitMatrix +ccsrc/lib/device/mapping.cpp:quafu::mapping::QUAFU_SABRE::InitialMapping +ccsrc/lib/device/mapping.cpp:quafu::mapping::QUAFU_SABRE::HeuristicSearch +ccsrc/lib/device/mapping.cpp:quafu::mapping::QUAFU_SABRE::QUAFU_SABRE +ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_swap_like.cpp:quafu::sim::densitymatrix::detail::CPUDensityMatrixPolicyBase::ApplySWAP +ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_gate_expect.cpp:quafu::sim::densitymatrix::detail::CPUDensityMatrixPolicyBase::ExpectDiffTwoQubitsMatrix TEST_CASE -mindquantum::sim::vector::detail::VectorState::ApplyGate -mindquantum::sim::vector::detail::VectorState::LeftSizeGradOneMulti -mindquantum::sim::densitymatrix::detail::DensityMatrixState::ApplyGate -mindquantum::sim::densitymatrix::detail::DensityMatrixState::GetExpectationWithReversibleGradOneMulti +quafu::sim::vector::detail::VectorState::ApplyGate +quafu::sim::vector::detail::VectorState::LeftSizeGradOneMulti +quafu::sim::densitymatrix::detail::DensityMatrixState::ApplyGate +quafu::sim::densitymatrix::detail::DensityMatrixState::GetExpectationWithReversibleGradOneMulti DummyOperator::TermsOperator::operator == ; } ; } using coefficient_t = DummyOperator :: coefficient_t ; using coeff_term_dict_t = DummyOperator :: coeff_term_dict_t ; TEST_CASE -mindquantum::ops::details::mindquantum::ops::details::pauli_products.QubitOperatorTermPolicy::simplify +quafu::ops::details::quafu::ops::details::pauli_products.QubitOperatorTermPolicy::simplify tests/st/test_io/test_svg.py:test_measure_svg tests/st/test_simulator/test_basic_gate_with_simulator.py:test_custom_gate_expectation_with_grad diff --git a/CMakeLists.txt b/CMakeLists.txt index f2cb82ecd..f3bfb11f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,8 +21,8 @@ cmake_minimum_required(VERSION 3.20) # mainly because of NVHPC support # ============================================================================== -# Create the MindQuantum project -project(MindQuantum LANGUAGES C CXX) +# Create the quafu project +project(quafu LANGUAGES C CXX) message(STATUS "Running using CMake ${CMAKE_VERSION}") @@ -47,15 +47,15 @@ include(cmake_configuration) include(GNUInstallDirs) set(CMAKE_INSTALL_LIBDIR "lib") -set(MQ_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}") -set(MQ_INSTALL_SBINDIR "${CMAKE_INSTALL_SBINDIR}") -set(MQ_INSTALL_SYSCONFDIR "${CMAKE_INSTALL_SYSCONFDIR}") -set(MQ_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/mindquantum") -set(MQ_INSTALL_DATADIR "${CMAKE_INSTALL_DATADIR}/mindquantum") -set(MQ_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/mindquantum") -set(MQ_INSTALL_DOCDIR "${CMAKE_INSTALL_DATADIR}/doc/mindquantum") -set(MQ_INSTALL_CMAKEDIR "${MQ_INSTALL_DATADIR}/cmake") -set(MQ_INSTALL_3RDPARTYDIR "${MQ_INSTALL_LIBDIR}/third_party") +set(QUAFU_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}") +set(QUAFU_INSTALL_SBINDIR "${CMAKE_INSTALL_SBINDIR}") +set(QUAFU_INSTALL_SYSCONFDIR "${CMAKE_INSTALL_SYSCONFDIR}") +set(QUAFU_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/quafu") +set(QUAFU_INSTALL_DATADIR "${CMAKE_INSTALL_DATADIR}/quafu") +set(QUAFU_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/quafu") +set(QUAFU_INSTALL_DOCDIR "${CMAKE_INSTALL_DATADIR}/doc/quafu") +set(QUAFU_INSTALL_CMAKEDIR "${QUAFU_INSTALL_DATADIR}/cmake") +set(QUAFU_INSTALL_3RDPARTYDIR "${QUAFU_INSTALL_LIBDIR}/third_party") # add_compile_options(-Wall -Wextra -Wfloat-equal) @@ -69,7 +69,7 @@ foreach( DOCDIR CMAKEDIR 3RDPARTYDIR) - GNUInstallDirs_get_absolute_install_dir(MQ_INSTALL_FULL_${_type} MQ_INSTALL_${_type} ${_type}) + GNUInstallDirs_get_absolute_install_dir(QUAFU_INSTALL_FULL_${_type} QUAFU_INSTALL_${_type} ${_type}) endforeach() # ============================================================================== @@ -94,20 +94,20 @@ include(compiler_flags) include(linker_flags) is_language_enabled(C, _c_enabled) -add_library(mindquantum_setup INTERFACE) -target_link_libraries(mindquantum_setup INTERFACE CXX_mindquantum $<$:C_mindquantum>) -append_to_property(mq_install_targets GLOBAL mindquantum_setup) +add_library(quafu_setup INTERFACE) +target_link_libraries(quafu_setup INTERFACE CXX_quafu $<$:C_quafu>) +append_to_property(quafu_install_targets GLOBAL quafu_setup) if(ENABLE_CMAKE_DEBUG) message(STATUS "Content of language specific targets:") list(APPEND CMAKE_MESSAGE_INDENT " ") - set(_targets CXX_mindquantum) + set(_targets CXX_quafu) if(_c_enabled) - list(APPEND _targets C_mindquantum) + list(APPEND _targets C_quafu) endif() if(ENABLE_CUDA) - list(APPEND _targets CUDA_mindquantum) + list(APPEND _targets CUDA_quafu) endif() include(CMakePrintHelpers) @@ -190,6 +190,6 @@ list(POP_FRONT CMAKE_MODULE_PATH) list(POP_FRONT CMAKE_MODULE_PATH) list(POP_FRONT CMAKE_MODULE_PATH) -if(_mq_added_nvcxx_module_path) +if(_quafu_added_nvcxx_module_path) list(POP_FRONT CMAKE_MODULE_PATH) endif() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 427a560e9..f9d0e7758 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # MindSpore Quantum Contributing Guidelines -[查看中文](https://gitee.com/mindspore/mindquantum/blob/master/CONTRIBUTING_CN.md) +[查看中文](https://gitee.com/mindspore/quafu/blob/master/CONTRIBUTING_CN.md) - [MindSpore Quantum Contributing Guidelines](#mindspore-quantum-contributing-guidelines) - [Contributor License Agreement](#contributor-license-agreement) @@ -56,10 +56,10 @@ MindSpore is a new open source deep learning training/inference framework that c #### Pip installation -- Install MindQuantum +- Install quafu ```bash -pip install mindquantum +pip install quafu ``` #### Source code installation @@ -68,54 +68,54 @@ pip install mindquantum ```bash cd ~ -git clone https://gitee.com/mindspore/mindquantum.git +git clone https://gitee.com/mindspore/quafu.git ``` -- Compile MindQuantum +- Compile quafu Make **Linux system** sure that CMake > = 3.18.3 is installed, and then run the following command: ```bash -cd ~/mindquantum +cd ~/quafu bash build.sh --gitee ``` Here `--gitee` let the script download the third-party dependencies from the gitee code hosting platform. If you need to compile the GPU version, please first install CUDA 11.x and the corresponding graphics driver, and then use the `--gpu` parameters to execute the following compilation instructions: ```bash -cd ~/mindquantum +cd ~/quafu bash build.sh --gitee --gpu ``` Make **Windows system** sure that MinGW-W64 and CMake > = 3.18.3 are installed, and then run the following command: ```bash -cd ~/mindquantum +cd ~/quafu build.bat /Gitee ``` Make **Mac system** sure that OpenMP and CMake > = 3.18.3 are installed, and then run the following command: ```bash -cd ~/mindquantum +cd ~/quafu bash build.sh --gitee ``` - Install the compiled whl package - Enter the output directory and install the compiled mindquantum whl package through the `pip` command. + Enter the output directory and install the compiled quafu whl package through the `pip` command. #### Verify installation successful -Execute the following command. If no error `No module named 'mindquantum'` is reported, the installation is successful. +Execute the following command. If no error `No module named 'quafu'` is reported, the installation is successful. ```bash -python -c 'import mindquantum' +python -c 'import quafu' ``` ### Compile -MindQuantum provides **Compile the package** and **Local compilation** two methods +quafu provides **Compile the package** and **Local compilation** two methods 1.Compile the package. If the user needs to adapt to different system environments and python versions, he can compile the source code into a package and then install it. For detailed process, please refer to the above *Source code installation* @@ -125,15 +125,15 @@ Download the source code from the code warehouse ```bash cd ~ -git clone https://gitee.com/mindspore/mindquantum.git +git clone https://gitee.com/mindspore/quafu.git ``` - **Linux** System, depending on CMake > = 3.18.3, compiled natively. - `--gitee` The parameter specifies that the script downloads third-party dependencies from the gitee code hosting platform; `export` the command adds the mindquantum source code path to the PYTHONPATH environment variable. + `--gitee` The parameter specifies that the script downloads third-party dependencies from the gitee code hosting platform; `export` the command adds the quafu source code path to the PYTHONPATH environment variable. ```bash - cd ~/mindquantum + cd ~/quafu bash build_locally.sh --gitee export PYTHONPATH=`pwd`$PYTHONPATH @@ -142,7 +142,7 @@ git clone https://gitee.com/mindspore/mindquantum.git - **Windows** system, depending on MinGW-W64 and CMake > = 3.18.3, compiled natively. ```bash - cd ~/mindquantum + cd ~/quafu build_locally.bat /Gitee -G 'MinGW Makefiles' set PYTHONPATH=%cd%;%PYTHONPATH% ``` @@ -150,7 +150,7 @@ git clone https://gitee.com/mindspore/mindquantum.git - **Mac** System, depending on OpenMP and CMake > = 3.18.3, compiled natively. ```bash - cd ~/mindquantum + cd ~/quafu bash build_locally.sh --gitee export PYTHONPATH=`pwd`$PYTHONPATH ``` @@ -160,7 +160,7 @@ git clone https://gitee.com/mindspore/mindquantum.git 1.Linux and MacOS installation - 1.1 Linux/Ubuntu/Centos systems and MacOS systems will come with versions `gcc` that meet the MindQuantum compilation. + 1.1 Linux/Ubuntu/Centos systems and MacOS systems will come with versions `gcc` that meet the quafu compilation. 1.2 Use the command to install GCC @@ -217,22 +217,22 @@ git clone https://gitee.com/mindspore/mindquantum.git ### Development -The mindquantum is mainly developed in C + + and python, the core computing unit is implemented in C/C + +, and the upper interface and peripheral modules are implemented in Python +The quafu is mainly developed in C + + and python, the core computing unit is implemented in C/C + +, and the upper interface and peripheral modules are implemented in Python The development process is mainly divided into two categories, developing new functions and fixing bugs: -- Develop new features, enter the issue page of MindQuantum, submit the issue, write new feature descriptions, categories, implementation methods, etc. Talk to the MindQuantum development team to confirm if this feature is necessary. Start the implementation locally, write the code, implement the function, write the corresponding test cases, and the corresponding documentation. Submit PR, merge into the main branch after the code passes the review, and complete the development of new functions. +- Develop new features, enter the issue page of quafu, submit the issue, write new feature descriptions, categories, implementation methods, etc. Talk to the quafu development team to confirm if this feature is necessary. Start the implementation locally, write the code, implement the function, write the corresponding test cases, and the corresponding documentation. Submit PR, merge into the main branch after the code passes the review, and complete the development of new functions. -- Fix the bug, go to the issue page of MindQuantum, read the unclosed issues, and claim the issue to solve the problem. Or if you encounter a bug when using MindQuantum, you are welcome to submit an issue to help improve the MindQuantum function module. +- Fix the bug, go to the issue page of quafu, read the unclosed issues, and claim the issue to solve the problem. Or if you encounter a bug when using quafu, you are welcome to submit an issue to help improve the quafu function module. ## Quick start -- On [Gitee](https://gitee.com/mindspore/mindquantum) the fork mind quantum code bin. -- See [README.md](https://gitee.com/mindspore/mindquantum/blob/master/README.md) for project information and build instructions. -- First experience, Build a parameterized quantum circuit. Use `mindquantum` to a quantum circuit including a H-gate, an RX gate, and an ry gate, and obtain a quantum state +- On [Gitee](https://gitee.com/mindspore/quafu) the fork mind quantum code bin. +- See [README.md](https://gitee.com/mindspore/quafu/blob/master/README.md) for project information and build instructions. +- First experience, Build a parameterized quantum circuit. Use `quafu` to a quantum circuit including a H-gate, an RX gate, and an ry gate, and obtain a quantum state ```python -from mindquantum import * +from quafu import * import numpy as np encoder = Circuit().h(0).rx({'a0': 2}, 0).ry('a1', 1) @@ -257,43 +257,43 @@ q1: ──┨ RY(a1) ┠─────────── ## Code structure -- [`ccsrc`](https://api.gitee.com/mindspore/mindquantum/tree/master/ccsrc) core computing module, using C/C + + implementation -- [`cmake`](https://api.gitee.com/mindspore/mindquantum/tree/master/cmake) cmake compiles configuration information -- [`docs`](https://api.gitee.com/mindspore/mindquantum/tree/master/docs) Mind Quantum API Documentation -- [`mindquantum`](https://api.gitee.com/mindspore/mindquantum/tree/master/mindquantum) Mind Quantum quantum computing module, implemented in Python - - [`mindquantum.dtype`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.dtype.html#module-mindquantum.dtype) MindQuantum data type simulation. - - [`mindquantum.core`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.core.html#module-mindquantum.core) Core features of MindQuantum (eDSL). - - [`gata`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/mindquantum.core.gates.html) quantum gate module providing different quantum gates. - - [`circuit`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/mindquantum.core.circuit.html) Quantum circuit module, It can easily build quantum circuits that meet the requirements, including parameterized quantum circuits. - - [`operators`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/mindquantum.core.operators.html) MindQuantum Operator library - - [`parameterresolver`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/mindquantum.core.parameterresolver.html) The parameter parser module is used for declaring the used parameters. - - [`mindquantum.simulator`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.simulator.html#module-mindquantum.simulator) A quantum simulator for simulating the evolution of a quantum system. - - [`mindquantum.framework`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.framework.html#module-mindquantum.framework) Quantum neural network operators and cell. - - [`mindquantum.algorithm`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.algorithm.html#module-mindquantum.algorithm) Quantum algorithm. - - [`compiler`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/algorithm/mindquantum.algorithm.compiler.html) Quantum circuit compiling module - - [`library`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/algorithm/mindquantum.algorithm.library.html) Common algorithm module - - [`nisq`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/algorithm/mindquantum.algorithm.nisq.html) NISQ algorithm - - [`error_mitigation`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/algorithm/mindquantum.algorithm.error_mitigation.html) Error mitigation module - - [`mapping`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/algorithm/mindquantum.algorithm.mapping.html) Bit Mapping Module - - [`mindquantum.device`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.device.html#module-mindquantum.device) Mind Quantum hardware module. - - [`mindquantum.io`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.io.html#module-mindquantum.io) Input/output module for MindQuantum. - - [`mindquantum.engine`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.engine.html#module-mindquantum.engine) MindQuantum Engine Module. - - [`mindquantum.utils`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.utils.html#module-mindquantum.utils) utility. -- [`mindquantum_config`](https://api.gitee.com/mindspore/mindquantum/tree/master/mindquantum_config) Item Configuration Information -- [`scripts`](https://api.gitee.com/mindspore/mindquantum/tree/master/scripts) Compiling a Dependent Tools Update Script -- [`tests`](https://api.gitee.com/mindspore/mindquantum/tree/master/tests) MindQuantum unit tests, based on Pytest, written in Python -- [`third_party`](https://api.gitee.com/mindspore/mindquantum/tree/master/third_party) Third-party open source packages on which MindQuantum compiles -- [`tutorials`](https://api.gitee.com/mindspore/mindquantum/tree/master/tutorials) Mind Quantum tutorial, which can be run directly with jupyter. Readable in [Official document of MindSpore](https://www.mindspore.cn/mindquantum/docs/en/master/index.html). +- [`ccsrc`](https://api.gitee.com/mindspore/quafu/tree/master/ccsrc) core computing module, using C/C + + implementation +- [`cmake`](https://api.gitee.com/mindspore/quafu/tree/master/cmake) cmake compiles configuration information +- [`docs`](https://api.gitee.com/mindspore/quafu/tree/master/docs) Mind Quantum API Documentation +- [`quafu`](https://api.gitee.com/mindspore/quafu/tree/master/quafu) Mind Quantum quantum computing module, implemented in Python + - [`quafu.dtype`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.dtype.html#module-quafu.dtype) quafu data type simulation. + - [`quafu.core`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.core.html#module-quafu.core) Core features of quafu (eDSL). + - [`gata`](https://www.mindspore.cn/quafu/docs/zh-CN/master/core/quafu.core.gates.html) quantum gate module providing different quantum gates. + - [`circuit`](https://www.mindspore.cn/quafu/docs/zh-CN/master/core/quafu.core.circuit.html) Quantum circuit module, It can easily build quantum circuits that meet the requirements, including parameterized quantum circuits. + - [`operators`](https://www.mindspore.cn/quafu/docs/zh-CN/master/core/quafu.core.operators.html) quafu Operator library + - [`parameterresolver`](https://www.mindspore.cn/quafu/docs/zh-CN/master/core/quafu.core.parameterresolver.html) The parameter parser module is used for declaring the used parameters. + - [`quafu.simulator`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.simulator.html#module-quafu.simulator) A quantum simulator for simulating the evolution of a quantum system. + - [`quafu.framework`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.framework.html#module-quafu.framework) Quantum neural network operators and cell. + - [`quafu.algorithm`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.algorithm.html#module-quafu.algorithm) Quantum algorithm. + - [`compiler`](https://www.mindspore.cn/quafu/docs/zh-CN/master/algorithm/quafu.algorithm.compiler.html) Quantum circuit compiling module + - [`library`](https://www.mindspore.cn/quafu/docs/zh-CN/master/algorithm/quafu.algorithm.library.html) Common algorithm module + - [`nisq`](https://www.mindspore.cn/quafu/docs/zh-CN/master/algorithm/quafu.algorithm.nisq.html) NISQ algorithm + - [`error_mitigation`](https://www.mindspore.cn/quafu/docs/zh-CN/master/algorithm/quafu.algorithm.error_mitigation.html) Error mitigation module + - [`mapping`](https://www.mindspore.cn/quafu/docs/zh-CN/master/algorithm/quafu.algorithm.mapping.html) Bit Mapping Module + - [`quafu.device`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.device.html#module-quafu.device) Mind Quantum hardware module. + - [`quafu.io`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.io.html#module-quafu.io) Input/output module for quafu. + - [`quafu.engine`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.engine.html#module-quafu.engine) quafu Engine Module. + - [`quafu.utils`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.utils.html#module-quafu.utils) utility. +- [`quafu_config`](https://api.gitee.com/mindspore/quafu/tree/master/quafu_config) Item Configuration Information +- [`scripts`](https://api.gitee.com/mindspore/quafu/tree/master/scripts) Compiling a Dependent Tools Update Script +- [`tests`](https://api.gitee.com/mindspore/quafu/tree/master/tests) quafu unit tests, based on Pytest, written in Python +- [`third_party`](https://api.gitee.com/mindspore/quafu/tree/master/third_party) Third-party open source packages on which quafu compiles +- [`tutorials`](https://api.gitee.com/mindspore/quafu/tree/master/tutorials) Mind Quantum tutorial, which can be run directly with jupyter. Readable in [Official document of MindSpore](https://www.mindspore.cn/quafu/docs/en/master/index.html). ## Unit testing -MindQuantum writes unit test cases based on pytest. It is recommended that developers write corresponding unit test cases after implementing a new function or module to ensure normal functions +quafu writes unit test cases based on pytest. It is recommended that developers write corresponding unit test cases after implementing a new function or module to ensure normal functions ## Write document -Instructions for writing documentation, MindQuantum has two main types of documentation: +Instructions for writing documentation, quafu has two main types of documentation: -- User-oriented documents: These are the documents that users see on [Mind Spore Quantum website](https://www.mindspore.cn/mindquantum/docs/en/master/index.html) the Internet, including the tutorial plans for circuit construction, simulator, algorithm implementation, etc., which are helpful to quickly get started and apply MindQuantum, as well as to learn quantum computing algorithms. +- User-oriented documents: These are the documents that users see on [Mind Spore Quantum website](https://www.mindspore.cn/quafu/docs/en/master/index.html) the Internet, including the tutorial plans for circuit construction, simulator, algorithm implementation, etc., which are helpful to quickly get started and apply quafu, as well as to learn quantum computing algorithms. - Documentation for developers: Documentation for developers is distributed across the code `MindQuanntum/docs` base. If you're interested in adding new developer documentation, read this page on the wiki to learn about best practices and write comments after you've written the code. The API is collated by extracting comments from the code. ## Contribution Workflow diff --git a/CONTRIBUTING_CN.md b/CONTRIBUTING_CN.md index 0cd8580a8..5c1b6bdd5 100644 --- a/CONTRIBUTING_CN.md +++ b/CONTRIBUTING_CN.md @@ -1,6 +1,6 @@ # MindSpore Quantum贡献指南 -[View English](https://gitee.com/mindspore/mindquantum/blob/master/CONTRIBUTING.md) +[View English](https://gitee.com/mindspore/quafu/blob/master/CONTRIBUTING.md) - [MindSpore Quantum贡献指南](#mindspore-quantum贡献指南) - [贡献者许可协议](#贡献者许可协议) @@ -54,10 +54,10 @@ MindSpore是一种适用于端边云场景的新型开源深度学习训练/推 #### pip安装 -- 安装MindQuantum +- 安装quafu ```bash -pip install mindquantum +pip install quafu ``` #### 源码安装 @@ -66,54 +66,54 @@ pip install mindquantum ```bash cd ~ - git clone https://gitee.com/mindspore/mindquantum.git + git clone https://gitee.com/mindspore/quafu.git ``` -2. 编译MindQuantum +2. 编译quafu **Linux系统**下请确保安装好CMake >= 3.18.3,然后运行如下命令: ```bash - cd ~/mindquantum + cd ~/quafu bash build.sh --gitee ``` 这里 `--gitee` 让脚本从gitee代码托管平台下载第三方依赖。如果需要编译GPU版本,请先安装好 CUDA 11.x,和对应的显卡驱动,然后使用`--gpu`参数,执行如下编译指令: ```bash - cd ~/mindquantum + cd ~/quafu bash build.sh --gitee --gpu ``` **Windows系统**下请确保安装好MinGW-W64和CMake >= 3.18.3,然后运行如下命令: ```bash - cd ~/mindquantum + cd ~/quafu build.bat /Gitee ``` **Mac系统**下请确保安装好openmp和CMake >= 3.18.3,然后运行如下命令: ```bash - cd ~/mindquantum + cd ~/quafu bash build.sh --gitee ``` 3. 安装编译好的whl包 - 进入output目录,通过`pip`命令安装编译好的mindquantum的whl包。 + 进入output目录,通过`pip`命令安装编译好的quafu的whl包。 #### 验证是否成功安装 -执行如下命令,如果没有报错`No module named 'mindquantum'`,则说明安装成功。 +执行如下命令,如果没有报错`No module named 'quafu'`,则说明安装成功。 ```bash -python -c 'import mindquantum' +python -c 'import quafu' ``` ### 编译 -MindQuantum提供**编译出包**和**本地编译**两种方法 +quafu提供**编译出包**和**本地编译**两种方法 1.编译出包,如果用户需要适配不同的系统环境、python版本,则可以将源码编译成wheel包,再安装,详细流程可参考上文[源码安装](# 源码安装)。 @@ -123,15 +123,15 @@ MindQuantum提供**编译出包**和**本地编译**两种方法 ```bash cd ~ -git clone https://gitee.com/mindspore/mindquantum.git +git clone https://gitee.com/mindspore/quafu.git ``` - **Linux**系统,依赖于CMake >= 3.18.3,本地编译。 - `--gitee`参数是指定脚本从gitee代码托管平台下载第三方依赖;`export`命令是添加mindquantum源码路径到PYTHONPATH环境变量里。 + `--gitee`参数是指定脚本从gitee代码托管平台下载第三方依赖;`export`命令是添加quafu源码路径到PYTHONPATH环境变量里。 ```bash - cd ~/mindquantum + cd ~/quafu bash build_locally.sh --gitee export PYTHONPATH=`pwd`$PYTHONPATH @@ -140,7 +140,7 @@ git clone https://gitee.com/mindspore/mindquantum.git - **Windows**系统,依赖于MinGW-W64和CMake >= 3.18.3,本地编译。 ```bash - cd ~/mindquantum + cd ~/quafu build_locally.bat /Gitee -G 'MinGW Makefiles' set PYTHONPATH=%cd%;%PYTHONPATH% ``` @@ -148,7 +148,7 @@ git clone https://gitee.com/mindspore/mindquantum.git - **Mac**系统,依赖于openmp和CMake >= 3.18.3,本地编译。 ```bash - cd ~/mindquantum + cd ~/quafu bash build_locally.sh --gitee export PYTHONPATH=`pwd`$PYTHONPATH ``` @@ -158,7 +158,7 @@ git clone https://gitee.com/mindspore/mindquantum.git 1.Linux和MacOS安装 - 1.1Linux/Ubuntu/Centos系统和MacOS系统会自带`gcc`,版本满足编译MindQuantum。 + 1.1Linux/Ubuntu/Centos系统和MacOS系统会自带`gcc`,版本满足编译quafu。 1.2使用命令安装gcc @@ -215,23 +215,23 @@ git clone https://gitee.com/mindspore/mindquantum.git ### 开发 -mindquantum主要使用C++和python进行开发,核心计算单元使用C/C++实现,上层接口及周边模块使用Python实现 +quafu主要使用C++和python进行开发,核心计算单元使用C/C++实现,上层接口及周边模块使用Python实现 开发流程主要分成2类,开发新功能,修复缺陷bug: -- 开发新功能,进入MindQuantum的issue页面,提交issue,编写新功能描述、类别、实现方法等。与MindQuantum开发团队交流,确认该功能是否必要。本地着手实现,编写代码,实现功能,编写相应的测试用例,相应的说明文档。提交PR,待代码通过审查后合入主分支,新功能开发完毕。 +- 开发新功能,进入quafu的issue页面,提交issue,编写新功能描述、类别、实现方法等。与quafu开发团队交流,确认该功能是否必要。本地着手实现,编写代码,实现功能,编写相应的测试用例,相应的说明文档。提交PR,待代码通过审查后合入主分支,新功能开发完毕。 -- 修复缺陷bug,进入MindQuantum的issue页面,阅读未关闭的issue,认领issue解决问题。或者平时使用MindQuantum遇到bug,欢迎提交issue,帮助完善MindQuantum功能模块。 +- 修复缺陷bug,进入quafu的issue页面,阅读未关闭的issue,认领issue解决问题。或者平时使用quafu遇到bug,欢迎提交issue,帮助完善quafu功能模块。 ## 快速入门 -- 在[Gitee](https://gitee.com/mindspore/mindquantum)上fork mindquantum代码仓。 -- 参见[README_CN.md](https://gitee.com/mindspore/mindquantum/blob/master/README_CN.md)了解项目信息和构建说明。 +- 在[Gitee](https://gitee.com/mindspore/quafu)上fork quafu代码仓。 +- 参见[README_CN.md](https://gitee.com/mindspore/quafu/blob/master/README_CN.md)了解项目信息和构建说明。 - 初体验-搭建参数化量子线路 - 使用 `mindquantum`搭建包括H门、RX门和RY门的量子线路,并得到量子态 + 使用 `quafu`搭建包括H门、RX门和RY门的量子线路,并得到量子态 ```python -from mindquantum import * +from quafu import * import numpy as np encoder = Circuit().h(0).rx({'a0': 2}, 0).ry('a1', 1) @@ -256,43 +256,43 @@ q1: ──┨ RY(a1) ┠─────────── ## 代码结构 -- [`ccsrc`](https://api.gitee.com/mindspore/mindquantum/tree/master/ccsrc) 核心运算模块,使用C/C++实现 -- [`cmake`](https://api.gitee.com/mindspore/mindquantum/tree/master/cmake) cmake编译配置信息 -- [`docs`](https://api.gitee.com/mindspore/mindquantum/tree/master/docs) MindQuantum API文档 -- [`mindquantum`](https://api.gitee.com/mindspore/mindquantum/tree/master/mindquantum) MindQuantum量子计算模块,使用Python实现 - - [`mindquantum.dtype`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.dtype.html#module-mindquantum.dtype) MindQuantum 数据类型模拟。 - - [`mindquantum.core`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.core.html#module-mindquantum.core) MindQuantum的核心特性(eDSL)。 - - [`gata`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/mindquantum.core.gates.html) 量子门模块,提供不同的量子门。 - - [`circuit`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/mindquantum.core.circuit.html) 量子线路模块,可以轻松地搭建出符合要求的量子线路,包括参数化量子线路。 - - [`operators`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/mindquantum.core.operators.html) MindQuantum 算子库 - - [`parameterresolver`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/mindquantum.core.parameterresolver.html) 参数解析器模块,用于声明使用到的参数。 - - [`mindquantum.simulator`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.simulator.html#module-mindquantum.simulator) 模拟量子系统演化的量子模拟器。 - - [`mindquantum.framework`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.framework.html#module-mindquantum.framework) 量子神经网络算子和cell。 - - [`mindquantum.algorithm`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.algorithm.html#module-mindquantum.algorithm) 量子算法。 - - [`compiler`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/algorithm/mindquantum.algorithm.compiler.html) 量子线路编译模块 - - [`library`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/algorithm/mindquantum.algorithm.library.html) 常用算法模块 - - [`nisq`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/algorithm/mindquantum.algorithm.nisq.html) NISQ算法 - - [`error_mitigation`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/algorithm/mindquantum.algorithm.error_mitigation.html) 误差缓解模块 - - [`mapping`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/algorithm/mindquantum.algorithm.mapping.html) 比特映射模块 - - [`mindquantum.device`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.device.html#module-mindquantum.device) MindQuantum 硬件模块。 - - [`mindquantum.io`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.io.html#module-mindquantum.io) MindQuantum的输入/输出模块。 - - [`mindquantum.engine`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.engine.html#module-mindquantum.engine) MindQuantum引擎模块。 - - [`mindquantum.utils`](https://mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.utils.html#module-mindquantum.utils) 实用工具。 -- [`mindquantum_config`](https://api.gitee.com/mindspore/mindquantum/tree/master/mindquantum_config) 项目配置信息 -- [`scripts`](https://api.gitee.com/mindspore/mindquantum/tree/master/scripts) 编译依赖工具更新脚本 -- [`tests`](https://api.gitee.com/mindspore/mindquantum/tree/master/tests) MindQuantum 单元测试,基于Pytest,使用Python编写 -- [`third_party`](https://api.gitee.com/mindspore/mindquantum/tree/master/third_party) MindQuantum编译依赖的第三方开源包 -- [`tutorials`](https://api.gitee.com/mindspore/mindquantum/tree/master/tutorials) MindQuantum 教程教案,使用jupyter可以直接运行,在[mindspore官方文档](https://mindspore.cn/mindquantum/docs/zh-CN/master/index.html)可阅读。 +- [`ccsrc`](https://api.gitee.com/mindspore/quafu/tree/master/ccsrc) 核心运算模块,使用C/C++实现 +- [`cmake`](https://api.gitee.com/mindspore/quafu/tree/master/cmake) cmake编译配置信息 +- [`docs`](https://api.gitee.com/mindspore/quafu/tree/master/docs) quafu API文档 +- [`quafu`](https://api.gitee.com/mindspore/quafu/tree/master/quafu) quafu量子计算模块,使用Python实现 + - [`quafu.dtype`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.dtype.html#module-quafu.dtype) quafu 数据类型模拟。 + - [`quafu.core`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.core.html#module-quafu.core) quafu的核心特性(eDSL)。 + - [`gata`](https://www.mindspore.cn/quafu/docs/zh-CN/master/core/quafu.core.gates.html) 量子门模块,提供不同的量子门。 + - [`circuit`](https://www.mindspore.cn/quafu/docs/zh-CN/master/core/quafu.core.circuit.html) 量子线路模块,可以轻松地搭建出符合要求的量子线路,包括参数化量子线路。 + - [`operators`](https://www.mindspore.cn/quafu/docs/zh-CN/master/core/quafu.core.operators.html) quafu 算子库 + - [`parameterresolver`](https://www.mindspore.cn/quafu/docs/zh-CN/master/core/quafu.core.parameterresolver.html) 参数解析器模块,用于声明使用到的参数。 + - [`quafu.simulator`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.simulator.html#module-quafu.simulator) 模拟量子系统演化的量子模拟器。 + - [`quafu.framework`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.framework.html#module-quafu.framework) 量子神经网络算子和cell。 + - [`quafu.algorithm`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.algorithm.html#module-quafu.algorithm) 量子算法。 + - [`compiler`](https://www.mindspore.cn/quafu/docs/zh-CN/master/algorithm/quafu.algorithm.compiler.html) 量子线路编译模块 + - [`library`](https://www.mindspore.cn/quafu/docs/zh-CN/master/algorithm/quafu.algorithm.library.html) 常用算法模块 + - [`nisq`](https://www.mindspore.cn/quafu/docs/zh-CN/master/algorithm/quafu.algorithm.nisq.html) NISQ算法 + - [`error_mitigation`](https://www.mindspore.cn/quafu/docs/zh-CN/master/algorithm/quafu.algorithm.error_mitigation.html) 误差缓解模块 + - [`mapping`](https://www.mindspore.cn/quafu/docs/zh-CN/master/algorithm/quafu.algorithm.mapping.html) 比特映射模块 + - [`quafu.device`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.device.html#module-quafu.device) quafu 硬件模块。 + - [`quafu.io`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.io.html#module-quafu.io) quafu的输入/输出模块。 + - [`quafu.engine`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.engine.html#module-quafu.engine) quafu引擎模块。 + - [`quafu.utils`](https://mindspore.cn/quafu/docs/zh-CN/master/quafu.utils.html#module-quafu.utils) 实用工具。 +- [`quafu_config`](https://api.gitee.com/mindspore/quafu/tree/master/quafu_config) 项目配置信息 +- [`scripts`](https://api.gitee.com/mindspore/quafu/tree/master/scripts) 编译依赖工具更新脚本 +- [`tests`](https://api.gitee.com/mindspore/quafu/tree/master/tests) quafu 单元测试,基于Pytest,使用Python编写 +- [`third_party`](https://api.gitee.com/mindspore/quafu/tree/master/third_party) quafu编译依赖的第三方开源包 +- [`tutorials`](https://api.gitee.com/mindspore/quafu/tree/master/tutorials) quafu 教程教案,使用jupyter可以直接运行,在[mindspore官方文档](https://mindspore.cn/quafu/docs/zh-CN/master/index.html)可阅读。 ## 单元测试 -mindquantum基于pytest编写单元测试用例,建议开发者在实现一个新的功能、模块后,编写对应的单元测试用例,保证功能正常 +quafu基于pytest编写单元测试用例,建议开发者在实现一个新的功能、模块后,编写对应的单元测试用例,保证功能正常 ## 编写文档 -编写文档的说明指南,MindQuantum 有两种主要类型的文档: +编写文档的说明指南,quafu 有两种主要类型的文档: -- 面向用户的文档:这些是用户在[MindSpore Quantum网站](https://mindspore.cn/mindquantum/docs/zh-CN/master/index.html)上看到的文档,包括线路构建,模拟器,算法实现等教程教案,有助于快速入手并应用MindQuantum,也有利于学习量子计算算法。 +- 面向用户的文档:这些是用户在[MindSpore Quantum网站](https://mindspore.cn/quafu/docs/zh-CN/master/index.html)上看到的文档,包括线路构建,模拟器,算法实现等教程教案,有助于快速入手并应用quafu,也有利于学习量子计算算法。 - 面向开发人员的文档:面向开发人员的文档分布在代码库`MindQuanntum/docs`中。如果有兴趣添加新的开发人员文档,请阅读wiki 上的此页面,了解最佳实践,并在编写代码后及时书写注释,API是通过抽取代码中的注释信息整理而成。 ## 贡献流程 @@ -331,7 +331,7 @@ mindquantum基于pytest编写单元测试用例,建议开发者在实现一个 ```shell # 在Gitee上 - git clone https://gitee.com/{insert_your_forked_repo}/mindquantum.git + git clone https://gitee.com/{insert_your_forked_repo}/quafu.git ``` - 本地开发代码。 @@ -400,7 +400,7 @@ git push origin {新分支名称} ### 提交PR -- 在[Gitee](https://api.gitee.com/mindspore/mindquantum/issues)上通过issue提出您的想法。 +- 在[Gitee](https://api.gitee.com/mindspore/quafu/issues)上通过issue提出您的想法。 - 如果是需要大量设计细节的新功能,还应提交设计方案。 diff --git a/INSTALL.md b/INSTALL.md index fad8fa108..fcdc4b2a8 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,15 +1,15 @@ # Installation -This file is designed to get you started with building and installing MindQuantum. +This file is designed to get you started with building and installing quafu. ## Quick-start ### Build a binary Python wheel -In order to generate binary wheels of MindQuantum, we recommend that you use the `build` package from Pypa: +In order to generate binary wheels of quafu, we recommend that you use the `build` package from Pypa: ```bash -cd mindquantum +cd quafu python3 -m build . ``` @@ -24,14 +24,14 @@ In order to make sure that all the required external library dependencies are co This is the preferred way of building binary wheels as it relies on Docker images (on Linux only) or the standard Python distribution on MacOS and Windows. ```bash -cd mindquantum +cd quafu python3 -m cibuildwheel . ``` you might need to specify your platform if `cibuildwheel` is not able to automatically detect your platform or if you want to build Linux wheel on MacOS for example: ```bash -cd mindquantum +cd quafu python3 -m cibuildwheel --platform linux . ``` @@ -51,18 +51,18 @@ On Windows, cibuildwheel will install the official Python distribution using NuG ##### On your local machine -If you do not want to rely on the `cibuildwheel` machinery (e.g. on MacOS) you can also automatically call `auditwheel` or `delocate` after building the wheel by specifying the `MQ_DELOCATE_WHEEL` environment variable, like so: +If you do not want to rely on the `cibuildwheel` machinery (e.g. on MacOS) you can also automatically call `auditwheel` or `delocate` after building the wheel by specifying the `QUAFU_DELOCATE_WHEEL` environment variable, like so: ```bash -cd mindquantum -MQ_DELOCATE_WHEEL=1 python3 -m build . +cd quafu +QUAFU_DELOCATE_WHEEL=1 python3 -m build . ``` -If you plan on distributing the wheel to other people that might not have the same system as yours, we highly recommend that you try to specify the `MQ_DELOCATE_WHEEL_PLAT` environment variable. By default, the setup scripts assumes 'linux_x86_64' on 64 bits machines but you may specify any platforms supported by [auditwheel](https://github.com/pypa/auditwheel). In order to distribute your wheels to a larger audience, we would recomment setting `MQ_DELOCATE_WHEEL_PLAT=manylinux2010_x86_64`, although this might result in an error when delocating the wheel if the version of your compiler is too recent. +If you plan on distributing the wheel to other people that might not have the same system as yours, we highly recommend that you try to specify the `QUAFU_DELOCATE_WHEEL_PLAT` environment variable. By default, the setup scripts assumes 'linux_x86_64' on 64 bits machines but you may specify any platforms supported by [auditwheel](https://github.com/pypa/auditwheel). In order to distribute your wheels to a larger audience, we would recomment setting `QUAFU_DELOCATE_WHEEL_PLAT=manylinux2010_x86_64`, although this might result in an error when delocating the wheel if the version of your compiler is too recent. -### Build MindQuantum locally +### Build quafu locally -You can setup MindQuantum for local development by using one of the local build scripts: +You can setup quafu for local development by using one of the local build scripts: - `build_locally.bat` (MS-DOS BATCH script) - `build_locally.ps1` (PowerShell script) @@ -72,12 +72,12 @@ Except a few minor differences [1]_, the functionalities of all three scripts ar 1. Setup a Python virtual environment 2. Update the virtual environment's packages and install some required dependencies -3. Add a PTH-file to the Python virtual environment to make sure that MindQuantum will be detected +3. Add a PTH-file to the Python virtual environment to make sure that quafu will be detected 4. Create a build directory and run CMake within it -5. Compile MindQuantum in-place +5. Compile quafu in-place The next time you run the script, unless you specify one of the cleaning options or force a CMake configuration step, -the script will only re-compile MindQuantum. +the script will only re-compile quafu. For more information, have a look at the help message of the scripts which you can access using `./build_locally.sh -h` or `./build_locally.sh --help`. The output is shown below for reference. @@ -87,38 +87,38 @@ For more information, have a look at the help message of the scripts which you c Here is an exhaustive list of all CMake options available for customization -| Option name | Description | Default value | -|---------------------------------|-----------------------------------------------------------------------|---------------------| -| BUILD_SHARED_LIBS | Build shared libs | OFF | -| BUILD_TESTING | Enable building the test suite | OFF | -| CLEAN_3RDPARTY_INSTALL_DIR | Clean third-party installation directory | OFF | -| CUDA_ALLOW_UNSUPPORTED_COMPILER | Allow the use of an unsupported comipler version for CUDA | OFF | -| CUDA_STATIC | Use static versions of the Nvidia CUDA libraries | OFF | -| DISABLE_FORTRAN_COMPILER | Forcefully disable the Fortran compiler for some 3rd party libraries | ON | -| ENABLE_CMAKE_DEBUG | Enable verbose output to debug CMake issues | OFF | -| ENABLE_CUDA | Enable the use of CUDA code | OFF | -| ENABLE_GITEE | Use Gitee instead of GitHub for (some) third-party dependencies | OFF | -| ENABLE_MD | Use /MD, /MDd flags when compiling (MSVC only) | OFF | -| ENABLE_MT | Use /MT, /MTd flags when compiling (MSVC only) | OFF | -| ENABLE_PROFILING | Enable compilation with profiling flags | OFF | -| ENABLE_RUNPATH | Prefer RUNPATH over RPATH when linking | ON | -| ENABLE_STACK_PROTECTION | Enable stack protection during compilation | ON | -| IN_PLACE_BUILD | Build the C++ MindQuantum libraries in-place | OFF | -| IS_PYTHON_BUILD | Whether CMake is called from setup.py | OFF | -| LINKER_DTAGS | Enable --enable-new-dtags (else use --disable-new-dtags) when linking | ON | -| LINKER_NOEXECSTACK | Use `-z,noexecstack` during linking (if supported) | ON | -| LINKER_RELRO | Use `-z,relro` during linking (if supported) | ON | -| LINKER_RPATH | Use RUNPATH/RPATH related flags when compiling | ON | -| LINKER_STRIP_ALL | Use `--strip-all` during linking (if supported) | ON | -| USE_OPENMP | Use the OpenMP library for parallelisation | ON | -| USE_PARALLEL_STL | Use the parallel STL for parallelisation (using TBB or else) | OFF | -| USE_VERBOSE_MAKEFILE | Generate verbose Makefiles (if supported) | ON | +| Option name | Description | Default value | +| ------------------------------- | --------------------------------------------------------------------- | ------------- | +| BUILD_SHARED_LIBS | Build shared libs | OFF | +| BUILD_TESTING | Enable building the test suite | OFF | +| CLEAN_3RDPARTY_INSTALL_DIR | Clean third-party installation directory | OFF | +| CUDA_ALLOW_UNSUPPORTED_COMPILER | Allow the use of an unsupported comipler version for CUDA | OFF | +| CUDA_STATIC | Use static versions of the Nvidia CUDA libraries | OFF | +| DISABLE_FORTRAN_COMPILER | Forcefully disable the Fortran compiler for some 3rd party libraries | ON | +| ENABLE_CMAKE_DEBUG | Enable verbose output to debug CMake issues | OFF | +| ENABLE_CUDA | Enable the use of CUDA code | OFF | +| ENABLE_GITEE | Use Gitee instead of GitHub for (some) third-party dependencies | OFF | +| ENABLE_MD | Use /MD, /MDd flags when compiling (MSVC only) | OFF | +| ENABLE_MT | Use /MT, /MTd flags when compiling (MSVC only) | OFF | +| ENABLE_PROFILING | Enable compilation with profiling flags | OFF | +| ENABLE_RUNPATH | Prefer RUNPATH over RPATH when linking | ON | +| ENABLE_STACK_PROTECTION | Enable stack protection during compilation | ON | +| IN_PLACE_BUILD | Build the C++ quafu libraries in-place | OFF | +| IS_PYTHON_BUILD | Whether CMake is called from setup.py | OFF | +| LINKER_DTAGS | Enable --enable-new-dtags (else use --disable-new-dtags) when linking | ON | +| LINKER_NOEXECSTACK | Use `-z,noexecstack` during linking (if supported) | ON | +| LINKER_RELRO | Use `-z,relro` during linking (if supported) | ON | +| LINKER_RPATH | Use RUNPATH/RPATH related flags when compiling | ON | +| LINKER_STRIP_ALL | Use `--strip-all` during linking (if supported) | ON | +| USE_OPENMP | Use the OpenMP library for parallelisation | ON | +| USE_PARALLEL_STL | Use the parallel STL for parallelisation (using TBB or else) | OFF | +| USE_VERBOSE_MAKEFILE | Generate verbose Makefiles (if supported) | ON | Here are some more precisions on some of the above options: #### `CLEAN_3RDPARTY_INSTALL_DIR` -This will delete any pre-existing installations within the local installation directory (by default `/path/to/build/.mqlibs`) _except_ the ones that are currently needed based on the hashes of the third-party libraries. +This will delete any pre-existing installations within the local installation directory (by default `/path/to/build/.quafulibs`) _except_ the ones that are currently needed based on the hashes of the third-party libraries. #### `DISABLE_FORTRAN_COMPILER` @@ -128,15 +128,15 @@ This currently only has an effect when installing Eigen3. In addition to the above CMake options, you may pass certain special CMake variables in order to customize your build. These are described below in more details. -#### `MQ_FORCE_LOCAL_PKGS` +#### `QUAFU_FORCE_LOCAL_PKGS` This variable's value is case-insensitive. It may be either of: - a single string (`all`) -- a comma-separated list of CMake package names for one or more of MindQuantum's third-party dependencies (e.g. `gmp,eigen3`) +- a comma-separated list of CMake package names for one or more of quafu's third-party dependencies (e.g. `gmp,eigen3`) Any or all packages listed will be compiled locally during the CMake configuration process. -#### `MQ_XXX_FORCE_LOCAL` +#### `QUAFU_XXX_FORCE_LOCAL` -Setting this to a truthful value for one of MindQuantum's third-party dependencies will result in that/these packages to be compiled locally during the CMake configuration process. Note that the package name `XXX` must be all caps. +Setting this to a truthful value for one of quafu's third-party dependencies will result in that/these packages to be compiled locally during the CMake configuration process. Note that the package name `XXX` must be all caps. diff --git a/INSTALL_cn.md b/INSTALL_cn.md index 1fb8b3925..61bbdd127 100644 --- a/INSTALL_cn.md +++ b/INSTALL_cn.md @@ -1,15 +1,15 @@ # 安装 -该文件旨在帮助您构建和安装 MindQuantum。 +该文件旨在帮助您构建和安装 quafu。 ## 快速开始 ### 构建二进制 Python wheel -为了生成 MindQuantum 的二进制 wheel,我们建议您使用 Pypa 中的 `build`: +为了生成 quafu 的二进制 wheel,我们建议您使用 Pypa 中的 `build`: ```bash -cd mindquantum +cd quafu python3 -m build . ``` @@ -24,14 +24,14 @@ python3 -m build . 这是构建二进制wheel的首选方法,因为它依赖于Docker镜像(仅在Linux上)或MacOS和Windows上的标准Python发行版。 ```bash -cd mindquantum +cd quafu python3 -m cibuildwheel . ``` 如果 `cibuildwheel` 无法自动检测您的平台,或者例如你想要在MacOS上构建Linux wheel,则可能需要指定平台: ```bash -cd mindquantum +cd quafu python3 -m cibuildwheel --platform linux . ``` @@ -51,18 +51,18 @@ python3 -m cibuildwheel --platform linux . ##### 在你的本地设备上 -如果您不想依靠 `cibuildwheel` (例如在MacOS上),也可以自动调用 `auditwheel` 或 `delocate`,通过指定 `MQ_DELOCATE_WHEEL` 环境变量来构建wheel之后。例如这样: +如果您不想依靠 `cibuildwheel` (例如在MacOS上),也可以自动调用 `auditwheel` 或 `delocate`,通过指定 `QUAFU_DELOCATE_WHEEL` 环境变量来构建wheel之后。例如这样: ```bash -cd mindquantum -MQ_DELOCATE_WHEEL=1 python3 -m build . +cd quafu +QUAFU_DELOCATE_WHEEL=1 python3 -m build . ``` -如果您打算将wheel分发给可能与您拥有不同系统的人,我们强烈建议您尝试指定 `MQ_DELOCATE_WHEEL_PLAT` 环境变量。默认情况下,setup脚本在64位计算机上假设 `'Linux_x86_64'`,但您可以指定[auditwheel](https://github.com/pypa/auditwheel)支持的任何平台。为了将wheel分发给更多的受众,我们推荐设置 `MQ_DELOCATE_WHEEL_PLAT=manylinux2010_x86_64`,尽管如果您的编译器版本太新,则在delocate wheel时可能会导致错误。 +如果您打算将wheel分发给可能与您拥有不同系统的人,我们强烈建议您尝试指定 `QUAFU_DELOCATE_WHEEL_PLAT` 环境变量。默认情况下,setup脚本在64位计算机上假设 `'Linux_x86_64'`,但您可以指定[auditwheel](https://github.com/pypa/auditwheel)支持的任何平台。为了将wheel分发给更多的受众,我们推荐设置 `QUAFU_DELOCATE_WHEEL_PLAT=manylinux2010_x86_64`,尽管如果您的编译器版本太新,则在delocate wheel时可能会导致错误。 -### 本地构建 MindQuantum +### 本地构建 quafu -您可以通过使用本地构建脚本之一来为本地开发设置MindQuantum: +您可以通过使用本地构建脚本之一来为本地开发设置quafu: - `build_locally.bat` (MS-DOS BATCH script) - `build_locally.ps1` (PowerShell script) @@ -72,9 +72,9 @@ MQ_DELOCATE_WHEEL=1 python3 -m build . 1. 设置Python虚拟环境; 2. 更新虚拟环境的软件包并安装一些必需的依赖; -3. 在Python虚拟环境中添加PTH文件,以确保MindQuantum能检测到; +3. 在Python虚拟环境中添加PTH文件,以确保quafu能检测到; 4. 创建一个 `build` 目录并在其中运行 CMake; -5. 原地编译 MindQuantum。 +5. 原地编译 quafu。 下次运行脚本时,除非指定清洁选项之一或强制CMAKE配置步骤,否则该脚本只会重新编译Mindquantum。 @@ -86,38 +86,38 @@ MQ_DELOCATE_WHEEL=1 python3 -m build . 这是所有可用于自定义的CMake选项的详尽列表: -| Option name | Description | Default value | -|---------------------------------|-----------------------------------------------------------------------|---------------------| -| BUILD_SHARED_LIBS | 构建共享的libs | OFF | -| BUILD_TESTING | 启用构建测试套件 | OFF | -| CLEAN_3RDPARTY_INSTALL_DIR | 清除第三方安装目录 | OFF | -| CUDA_ALLOW_UNSUPPORTED_COMPILER | 允许使用CUDA不支持的编译器版本 | OFF | -| CUDA_STATIC | 使用 Nvidia CUDA 库的静态版本 | OFF | -| DISABLE_FORTRAN_COMPILER | 对于一些第三方库,强制禁止 Fortran 编译器 | ON | -| ENABLE_CMAKE_DEBUG | 启用详细输出来调试CMAKE | OFF | -| ENABLE_CUDA | 启用使用CUDA代码 | OFF | -| ENABLE_GITEE | 使用gitee代替github作为(某些)第三方依赖 | OFF | -| ENABLE_MD | 编译时使用 /MD, /MDd 标志 (仅MSVC) | OFF | -| ENABLE_MT | 编译时使用 /MT, /MTd 标志 (仅MSVC) | OFF | -| ENABLE_PROFILING | 启用编译分析标志 | OFF | -| ENABLE_RUNPATH | link时优先使用 RUNPATH 而不是 RPATH | ON | -| ENABLE_STACK_PROTECTION | 启用 编译期栈保护 | ON | -| IN_PLACE_BUILD | 原地构建 C++ MindQuantum 库 | OFF | -| IS_PYTHON_BUILD | 是否 CMake 被 setup.py 调用 | OFF | -| LINKER_DTAGS | link期间启用 --enable-new-dtags (或者使用 --disable-new-dtags) | ON | -| LINKER_NOEXECSTACK | link期间使用 `-z,noexecstack` (如果支持的话) | ON | -| LINKER_RELRO | link期间使用 `-z,relro` (如果支持的话) | ON | -| LINKER_RPATH | 编译期间使用 RUNPATH/RPATH 相关的标志 | ON | -| LINKER_STRIP_ALL | link期间使用 `--strip-all` (如果支持的话) | ON | -| USE_OPENMP | 使用 OpenMP 用于并行计算 | ON | -| USE_PARALLEL_STL | 使用 parallel STL 用于并行计算 (使用 TBB 或者别的) | OFF | -| USE_VERBOSE_MAKEFILE | 生成详细 Makefiles (如果支持的话) | ON | +| Option name | Description | Default value | +| ------------------------------- | -------------------------------------------------------------- | ------------- | +| BUILD_SHARED_LIBS | 构建共享的libs | OFF | +| BUILD_TESTING | 启用构建测试套件 | OFF | +| CLEAN_3RDPARTY_INSTALL_DIR | 清除第三方安装目录 | OFF | +| CUDA_ALLOW_UNSUPPORTED_COMPILER | 允许使用CUDA不支持的编译器版本 | OFF | +| CUDA_STATIC | 使用 Nvidia CUDA 库的静态版本 | OFF | +| DISABLE_FORTRAN_COMPILER | 对于一些第三方库,强制禁止 Fortran 编译器 | ON | +| ENABLE_CMAKE_DEBUG | 启用详细输出来调试CMAKE | OFF | +| ENABLE_CUDA | 启用使用CUDA代码 | OFF | +| ENABLE_GITEE | 使用gitee代替github作为(某些)第三方依赖 | OFF | +| ENABLE_MD | 编译时使用 /MD, /MDd 标志 (仅MSVC) | OFF | +| ENABLE_MT | 编译时使用 /MT, /MTd 标志 (仅MSVC) | OFF | +| ENABLE_PROFILING | 启用编译分析标志 | OFF | +| ENABLE_RUNPATH | link时优先使用 RUNPATH 而不是 RPATH | ON | +| ENABLE_STACK_PROTECTION | 启用 编译期栈保护 | ON | +| IN_PLACE_BUILD | 原地构建 C++ quafu 库 | OFF | +| IS_PYTHON_BUILD | 是否 CMake 被 setup.py 调用 | OFF | +| LINKER_DTAGS | link期间启用 --enable-new-dtags (或者使用 --disable-new-dtags) | ON | +| LINKER_NOEXECSTACK | link期间使用 `-z,noexecstack` (如果支持的话) | ON | +| LINKER_RELRO | link期间使用 `-z,relro` (如果支持的话) | ON | +| LINKER_RPATH | 编译期间使用 RUNPATH/RPATH 相关的标志 | ON | +| LINKER_STRIP_ALL | link期间使用 `--strip-all` (如果支持的话) | ON | +| USE_OPENMP | 使用 OpenMP 用于并行计算 | ON | +| USE_PARALLEL_STL | 使用 parallel STL 用于并行计算 (使用 TBB 或者别的) | OFF | +| USE_VERBOSE_MAKEFILE | 生成详细 Makefiles (如果支持的话) | ON | 下面是以上一些选项的更明确的描述: #### `CLEAN_3RDPARTY_INSTALL_DIR` -这将删除本地安装目录中的任何预先存在的安装(默认情况下 `/path/to/build/.mqlibs`) _除了_ 当前基于第三方库的哈希当前所需的安装。 +这将删除本地安装目录中的任何预先存在的安装(默认情况下 `/path/to/build/.quafulibs`) _除了_ 当前基于第三方库的哈希当前所需的安装。 #### `DISABLE_FORTRAN_COMPILER` @@ -127,7 +127,7 @@ MQ_DELOCATE_WHEEL=1 python3 -m build . 除上述CMAKE选项外,您还可以通过某些特殊的CMAKE变量来自定义构建。这些细节在下面描述。 -#### `MQ_FORCE_LOCAL_PKGS` +#### `QUAFU_FORCE_LOCAL_PKGS` 该变量的值对大小写不敏感。它可能是: @@ -136,6 +136,6 @@ MQ_DELOCATE_WHEEL=1 python3 -m build . 列出的所有软件包将在CMAKE配置过程中本地编译。 -#### `MQ_XXX_FORCE_LOCAL` +#### `QUAFU_XXX_FORCE_LOCAL` 将其设置为Mindquantum的第三方依赖之一,将导致在CMake配置过程中本地编译这些软件包。请注意,软件包名称 `XXX` 必须全部是大写字母。 diff --git a/MANIFEST.in b/MANIFEST.in index b9eb679d6..e150b0d7b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,7 +5,7 @@ recursive-include _build *.py recursive-include cmake *.cmake recursive-include tests *.txt* *.py *.hpp *.cpp *.hdf5 *.sh recursive-include third_party *.patch* -recursive-include mindquantum *.txt *.h *.hpp *.cc *.cpp +recursive-include quafu *.txt *.h *.hpp *.cc *.cpp exclude .clang-format *.yaml *.allow *.bat *.md *.sh *.suppressions diff --git a/NOTICE b/NOTICE index fd00f5349..936da0ce6 100644 --- a/NOTICE +++ b/NOTICE @@ -1,2 +1,2 @@ -MindSpore MindQuantum +MindSpore quafu Copyright 2019-2021 Huawei Technologies Co., Ltd diff --git a/README.md b/README.md index 620339643..cd2c61427 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ ## What is pyquafu -pyquafu is forked from [MindQuantum](https://gitee.com/mindspore/mindquantum/). Based on MindQuantum, pyquafu can run quantum algorithm directly on the quantum cloud developed by Beijing Academy of Quantum Information Sciences. +pyquafu is forked from [MindQuantum](https://gitee.com/mindspore/quafu/). Based on MindQuantum, pyquafu can run quantum algorithm directly on the quantum cloud developed by Beijing Academy of Quantum Information Sciences. ## First experience diff --git a/README_CN.md b/README_CN.md index 236d5b3d5..a2cfec723 100644 --- a/README_CN.md +++ b/README_CN.md @@ -24,7 +24,7 @@ ## pyquafu介绍 -pyquafu 从 [MindQuantum](https://gitee.com/mindspore/mindquantum/) fork而来,在此基础上,pyquafu可以直接在北京量子信息科学研究院所搭建的quafu量子计算云平台上执行量子算法。 +pyquafu 从 [MindQuantum](https://gitee.com/mindspore/quafu/) fork而来,在此基础上,pyquafu可以直接在北京量子信息科学研究院所搭建的quafu量子计算云平台上执行量子算法。 ## 初体验 diff --git a/build.bat b/build.bat index ddc59f97a..5cc958de9 100644 --- a/build.bat +++ b/build.bat @@ -1,5 +1,5 @@ @echo off -@title mindquantum_build +@title quafu_build @rem Copyright 2020 Huawei Technologies Co., Ltd @rem @@ -49,7 +49,7 @@ set _IS_MINDSPORE_CI=0 goto :CI_DONE :CI_TRUE -echo Detected MindSpore/MindQuantum CI +echo Detected MindSpore/quafu CI set _IS_MINDSPORE_CI=1 :CI_DONE @@ -398,10 +398,10 @@ if NOT !n_jobs! == -1 ( if "!build_type!" == "Debug" set args=!args! -C--global-option=build -C--global-option=--debug if !force_local_pkgs! == 1 ( - set args=!args! -C--global-option=--var -C--global-option=MQ_FORCE_LOCAL_PKGS -C--global-option=all + set args=!args! -C--global-option=--var -C--global-option=QUAFU_FORCE_LOCAL_PKGS -C--global-option=all ) else ( if NOT "!local_pkgs!" == "" ( - set args=!args! -C--global-option=--var -C--global-option=MQ_FORCE_LOCAL_PKGS -C--global-option=!local_pkgs! + set args=!args! -C--global-option=--var -C--global-option=QUAFU_FORCE_LOCAL_PKGS -C--global-option=!local_pkgs! ) ) @@ -446,29 +446,29 @@ if !has_build_dir! == 1 ( ) if !delocate_wheel! == 1 ( - set MQ_DELOCATE_WHEEL=1 - set MQ_DELOCATE_WHEEL_PLAT= - if NOT "!platform_name!" == "" set MQ_DELOCATE_WHEEL_PLAT=!platform_name! + set QUAFU_DELOCATE_WHEEL=1 + set QUAFU_DELOCATE_WHEEL_PLAT= + if NOT "!platform_name!" == "" set QUAFU_DELOCATE_WHEEL_PLAT=!platform_name! if !has_build_dir! == 1 ( set build_dir_for_env=!build_dir! ) else ( if "!fast_build_dir!" == "" ( - for /F "delims=" %%i IN ('!PYTHON! -m mindquantum_config --tempdir') DO set build_dir_for_env=%%i + for /F "delims=" %%i IN ('!PYTHON! -m quafu_config --tempdir') DO set build_dir_for_env=%%i ) else ( set build_dir_for_env=!fast_build_dir! ) ) if !_IS_MINDSPORE_CI! == 1 ( - set MQ_LIB_PATHS=!ROOTDIR!\ld_library_paths.txt + set QUAFU_LIB_PATHS=!ROOTDIR!\ld_library_paths.txt ) else ( - set MQ_LIB_PATHS=!build_dir_for_env!\ld_library_paths.txt + set QUAFU_LIB_PATHS=!build_dir_for_env!\ld_library_paths.txt ) - set MQ_BUILD_DIR=!build_dir_for_env! + set QUAFU_BUILD_DIR=!build_dir_for_env! - echo MQ_LIB_PATHS = !MQ_LIB_PATHS! - echo MQ_BUILD_DIR = !MQ_BUILD_DIR! + echo QUAFU_LIB_PATHS = !QUAFU_LIB_PATHS! + echo QUAFU_BUILD_DIR = !QUAFU_BUILD_DIR! ) call %SCRIPTDIR%\dos\call_cmd.bat !PYTHON! -m build !args! !unparsed_args! @@ -476,10 +476,10 @@ call %SCRIPTDIR%\dos\call_cmd.bat !PYTHON! -m build !args! !unparsed_args! if DEFINED args set args= if DEFINED unparsed_args set unparsed_args= -if DEFINED MQ_DELOCATE_WHEEL set MQ_DELOCATE_WHEEL= -if DEFINED MQ_DELOCATE_WHEEL_PLAT set MQ_DELOCATE_WHEEL_PLAT= -if DEFINED MQ_LIB_PATHS set MQ_LIB_PATHS= -if DEFINED MQ_BUILD_DIR set MQ_BUILD_DIR= +if DEFINED QUAFU_DELOCATE_WHEEL set QUAFU_DELOCATE_WHEEL= +if DEFINED QUAFU_DELOCATE_WHEEL_PLAT set QUAFU_DELOCATE_WHEEL_PLAT= +if DEFINED QUAFU_LIB_PATHS set QUAFU_LIB_PATHS= +if DEFINED QUAFU_BUILD_DIR set QUAFU_BUILD_DIR= rem ----------------------------------------------------------------------------- rem Move the wheels to the output directory @@ -490,7 +490,7 @@ IF NOT EXIST "!output_path!" ( call %SCRIPTDIR%\dos\call_cmd.bat move /Y %ROOTDIR%\dist\* %output_path% -echo ------Successfully created mindquantum package------ +echo ------Successfully created quafu package------ goto :END @@ -499,11 +499,11 @@ rem ============================================================================ :help_message echo Build binary Python wheel for MindQunantum echo: - echo This is mainly relevant for developers that want to deploy MindQuantum + echo This is mainly relevant for developers that want to deploy quafu echo on machines other than their own. echo: - echo This script will create a Python virtualenv in the MindQuantum root - echo directory and then build a binary Python wheel of MindQuantum. + echo This script will create a Python virtualenv in the quafu root + echo directory and then build a binary Python wheel of quafu. echo: echo Usage: echo %PROGRAM% [options] diff --git a/build.ps1 b/build.ps1 index cc4326522..303efb7e1 100644 --- a/build.ps1 +++ b/build.ps1 @@ -64,11 +64,11 @@ $PARAMETERLIST = (Get-Command -Name ".\$PROGRAM").Parameters # Test for MindSpore CI $_IS_MINDSPORE_CI = $false if ("$Env:JENKINS_URL" -Match 'https?://build.mindspore.cn' -And [bool]$Env:CI -And $Env:CI -eq 1) { - Write-Output "Detected MindSpore/MindQuantum CI" + Write-Output "Detected MindSpore/quafu CI" $_IS_MINDSPORE_CI = $true } if ([bool]$Env:DEVCLOUD_CI -And $Env:DEVCLOUD_CI -eq 1) { - Write-Output "Detected MindSpore/MindQuantum CI" + Write-Output "Detected MindSpore/quafu CI" $_IS_MINDSPORE_CI = $true } @@ -103,11 +103,11 @@ if ($_IS_MINDSPORE_CI ) { function Help-Header { Write-Output 'Build binary Python wheel for MindQunantum' Write-Output '' - Write-Output 'This is mainly relevant for developers that want to deploy MindQuantum ' + Write-Output 'This is mainly relevant for developers that want to deploy quafu ' Write-Output 'on machines other than their own.' Write-Output '' - Write-Output 'This script will create a Python virtualenv in the MindQuantum root' - Write-Output 'directory and then build a binary Python wheel of MindQuantum.' + Write-Output 'This script will create a Python virtualenv in the quafu root' + Write-Output 'directory and then build a binary Python wheel of quafu.' } function Extra-Help { @@ -317,10 +317,10 @@ if ($_build_dir_was_set) { } if ($force_local_pkgs) { - $build_args += '--var', 'MQ_FORCE_LOCAL_PKGS', 'all' + $build_args += '--var', 'QUAFU_FORCE_LOCAL_PKGS', 'all' } elseif ([bool]"$local_pkgs") { - $build_args += '--var', 'MQ_FORCE_LOCAL_PKGS', "`"$local_pkgs`"" + $build_args += '--var', 'QUAFU_FORCE_LOCAL_PKGS', "`"$local_pkgs`"" } # -------------------------------------- @@ -411,10 +411,10 @@ if ($_build_dir_was_set) { } if ($delocate_wheel) { - $Env:MQ_DELOCATE_WHEEL = 1 + $Env:QUAFU_DELOCATE_WHEEL = 1 if ([bool]$platform_name) { - $Env:MQ_DELOCATE_WHEEL_PLAT = "$platform_name" + $Env:QUAFU_DELOCATE_WHEEL_PLAT = "$platform_name" } if ([bool]$_build_dir_was_set -Or [bool]$fast_build) { @@ -424,27 +424,27 @@ if ($delocate_wheel) { $build_dir_for_env = $fast_build_dir } else { - $build_dir_for_env = (&"$PYTHON" -m mindquantum_config --tempdir) + $build_dir_for_env = (&"$PYTHON" -m quafu_config --tempdir) } if ($_IS_MINDSPORE_CI) { - $Env:MQ_LIB_PATHS = "$ROOTDIR/ld_library_paths.txt" + $Env:QUAFU_LIB_PATHS = "$ROOTDIR/ld_library_paths.txt" } else { - $Env:MQ_LIB_PATHS = "$build_dir_for_env/ld_library_paths.txt" + $Env:QUAFU_LIB_PATHS = "$build_dir_for_env/ld_library_paths.txt" } - $Env:MQ_BUILD_DIR = "$build_dir_for_env" + $Env:QUAFU_BUILD_DIR = "$build_dir_for_env" - Write-Debug "MQ_LIB_PATHS = $Env:MQ_LIB_PATHS" - Write-Debug "MQ_BUILD_DIR = $Env:MQ_BUILD_DIR" + Write-Debug "QUAFU_LIB_PATHS = $Env:QUAFU_LIB_PATHS" + Write-Debug "QUAFU_BUILD_DIR = $Env:QUAFU_BUILD_DIR" } else { - $Env:MQ_DELOCATE_WHEEL = 0 + $Env:QUAFU_DELOCATE_WHEEL = 0 } Call-Cmd "$PYTHON" -m build @build_args @fixed_args -$Env:MQ_LIB_PATHS = '' -$Env:MQ_BUILD_DIR = '' +$Env:QUAFU_LIB_PATHS = '' +$Env:QUAFU_BUILD_DIR = '' if ($LastExitCode -ne 0) { exit $LastExitCode } @@ -459,7 +459,7 @@ Call-Cmd New-Item -Path "'$output_path'" -ItemType "directory" Call-Cmd Move-Item -Path "'$ROOTDIR\dist\*.whl'" -Destination "$output_path" -Call-Cmd Write-Output "------Successfully created mindquantum package------" +Call-Cmd Write-Output "------Successfully created quafu package------" # ============================================================================== @@ -474,11 +474,11 @@ Build MindQunantum locally (in-source build) This is mainly relevant for developers that do not want to always have to reinstall the Python package -This script will create a Python virtualenv in the MindQuantum root directory and then build all the C++ Python -modules and place the generated libraries in their right locations within the MindQuantum folder hierarchy so Python +This script will create a Python virtualenv in the quafu root directory and then build all the C++ Python +modules and place the generated libraries in their right locations within the quafu folder hierarchy so Python knows how to find them. -A pth-file will be created in the virtualenv site-packages directory so that the MindQuantum root folder will be added +A pth-file will be created in the virtualenv site-packages directory so that the quafu root folder will be added to the Python PATH without the need to modify PYTHONPATH. .PARAMETER Analyzer diff --git a/build.sh b/build.sh index 85ecb93f0..acf665e48 100755 --- a/build.sh +++ b/build.sh @@ -24,11 +24,11 @@ echo "Called with: $*" # Test for MindSpore CI _IS_MINDSPORE_CI=0 if [[ "${JENKINS_URL:-0}" =~ https?://build.mindspore.cn && ! "${CI:-0}" =~ ^(false|0)$ ]]; then - echo "Detected MindSpore/MindQuantum CI" + echo "Detected MindSpore/quafu CI" _IS_MINDSPORE_CI=1 fi if [[ "${DEVCLOUD_CI:-0}" == "1" ]]; then - echo "Detected MindSpore/MindQuantum CI" + echo "Detected MindSpore/quafu CI" _IS_MINDSPORE_CI=1 fi # ============================================================================== @@ -112,11 +112,11 @@ fi function help_header() { echo 'Build binary Python wheel for MindQunantum' echo '' - echo 'This is mainly relevant for developers that want to deploy MindQuantum ' + echo 'This is mainly relevant for developers that want to deploy quafu ' echo 'on machines other than their own.' echo '' - echo 'This script will create a Python virtualenv in the MindQuantum root' - echo 'directory and then build a binary Python wheel of MindQuantum.' + echo 'This script will create a Python virtualenv in the quafu root' + echo 'directory and then build a binary Python wheel of quafu.' } function extra_help() { @@ -285,9 +285,9 @@ fi local_pkgs_str=$(join_by , "${local_pkgs[@]}") if [[ "$force_local_pkgs" -eq 1 ]]; then - args+=(--var MQ_FORCE_LOCAL_PKGS all) + args+=(--var QUAFU_FORCE_LOCAL_PKGS all) elif [ -n "$local_pkgs_str" ]; then - args+=(--var MQ_FORCE_LOCAL_PKGS "$local_pkgs_str") + args+=(--var QUAFU_FORCE_LOCAL_PKGS "$local_pkgs_str") fi # -------------------------------------- @@ -356,7 +356,7 @@ fi # ------------------------------------------------------------------------------ # Clean build directory if requested and possible -temp_build_dir=$("$PYTHON" -m mindquantum_config --tempdir) +temp_build_dir=$("$PYTHON" -m quafu_config --tempdir) if [ "${_build_dir_was_set:-0}" -eq 1 ]; then build_dir_for_cleaning="$build_dir" elif [ -d "$temp_build_dir" ]; then @@ -382,11 +382,11 @@ fi env_vars=() if [[ "$cmake_generator" == "Ninja" || "$cmake_generator" == "Ninja Multi-Config" ]]; then - env_vars+=(MQ_USE_NINJA=1) + env_vars+=(QUAFU_USE_NINJA=1) fi if [ "$delocate_wheel" -eq 1 ]; then - env_vars+=(MQ_DELOCATE_WHEEL=1 + env_vars+=(QUAFU_DELOCATE_WHEEL=1 "${LD_PATH_VAR}=${!LD_PATH_VAR}") if [[ "${_build_dir_was_set:-0}" -eq 1 || "${fast_build:-0}" -eq 1 ]]; then @@ -394,19 +394,19 @@ if [ "$delocate_wheel" -eq 1 ]; then elif [ "${_fast_build_dir_was_set:-0}" -eq 1 ]; then build_dir_for_env="$fast_build_dir" else - build_dir_for_env=$("$PYTHON" -m mindquantum_config --tempdir) + build_dir_for_env=$("$PYTHON" -m quafu_config --tempdir) fi if [ "$_IS_MINDSPORE_CI" -eq 1 ]; then - env_vars+=(MQ_LIB_PATHS="$ROOTDIR/ld_library_paths.txt") + env_vars+=(QUAFU_LIB_PATHS="$ROOTDIR/ld_library_paths.txt") else - env_vars+=(MQ_LIB_PATHS="$build_dir_for_env/ld_library_paths.txt") + env_vars+=(QUAFU_LIB_PATHS="$build_dir_for_env/ld_library_paths.txt") fi - env_vars+=(MQ_BUILD_DIR="$build_dir_for_env") + env_vars+=(QUAFU_BUILD_DIR="$build_dir_for_env") if [ -n "$platform_name" ]; then - env_vars+=(MQ_DELOCATE_WHEEL_PLAT="$platform_name") + env_vars+=(QUAFU_DELOCATE_WHEEL_PLAT="$platform_name") fi fi @@ -432,4 +432,4 @@ if [[ "$_IS_MINDSPORE_CI" -eq 1 && "$(uname)" == 'Linux' ]]; then done fi -echo "------Successfully created mindquantum package------" +echo "------Successfully created quafu package------" diff --git a/build_locally.bat b/build_locally.bat index 1cb56db08..7f14c14b7 100644 --- a/build_locally.bat +++ b/build_locally.bat @@ -301,7 +301,7 @@ if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL% if NOT !dry_run! == 1 ( rem Make sure the root directory is in the virtualenv PATH for /F %%i in ('!PYTHON! -c "import site; print(site.getsitepackages()[0])"') do set site_pkg_dir=%%i - set pth_file=!site_pkg_dir!\mindquantum_local.pth + set pth_file=!site_pkg_dir!\quafu_local.pth if NOT exist !pth_file! ( echo Creating pth-file in !pth_file! @@ -355,9 +355,9 @@ if !cmake_make_silent! == 1 ( ) if !force_local_pkgs! == 1 ( - set cmake_args=!cmake_args! -DMQ_FORCE_LOCAL_PKGS=all + set cmake_args=!cmake_args! -DQUAFU_FORCE_LOCAL_PKGS=all ) else ( - if NOT "!local_pkgs!" == "" set cmake_args=!cmake_args! -DMQ_FORCE_LOCAL_PKGS=!local_pkgs! + if NOT "!local_pkgs!" == "" set cmake_args=!cmake_args! -DQUAFU_FORCE_LOCAL_PKGS=!local_pkgs! ) if NOT "!prefix_dir!" == "" set cmake_args=!cmake_args! -DCMAKE_INSTALL_PREFIX:FILEPATH=!prefix_dir! @@ -507,13 +507,13 @@ exit /B 0 echo This is mainly relevant for developers that do not want to always echo have to reinstall the Python package echo: - echo This script will create a Python virtualenv in the MindQuantum root + echo This script will create a Python virtualenv in the quafu root echo directory and then build all the C++ Python modules and place the - echo generated libraries in their right locations within the MindQuantum + echo generated libraries in their right locations within the quafu echo folder hierarchy so Python knows how to find them. echo: echo A pth-file will be created in the virtualenv site-packages directory - echo so that the MindQuantum root folder will be added to the Python PATH + echo so that the quafu root folder will be added to the Python PATH echo without the need to modify PYTHONPATH. echo: echo Usage: @@ -532,7 +532,7 @@ exit /B 0 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 /ConfigureOnly Stop after the CMake configure and generation steps (ie. before building MindQuantum) + echo /ConfigureOnly Stop after the CMake configure and generation steps (ie. before building quafu) echo /Debug Build in debug mode echo /DebugCMake Enable debugging mode for CMake configuration step echo /Doc, /Docs Setup the Python virtualenv for building the documentation and ask CMake to build the diff --git a/build_locally.ps1 b/build_locally.ps1 index 7863bfbba..0a04865d0 100644 --- a/build_locally.ps1 +++ b/build_locally.ps1 @@ -64,7 +64,7 @@ $PARAMETERLIST = (Get-Command -Name ".\$PROGRAM").Parameters # Test for MindSpore CI $_IS_MINDSPORE_CI=$false if ("$Env:JENKINS_URL" -Match 'https?://build.mindspore.cn' -And [bool]$Env:CI) { - Write-Output "Detected MindSpore/MindQuantum CI" + Write-Output "Detected MindSpore/quafu CI" $_IS_MINDSPORE_CI=$true } @@ -83,13 +83,13 @@ function Help-Header { Write-Output 'This is mainly relevant for developers that do not want to always ' Write-Output 'have to reinstall the Python package' Write-Output '' - Write-Output 'This script will create a Python virtualenv in the MindQuantum root' + Write-Output 'This script will create a Python virtualenv in the quafu root' Write-Output 'directory and then build all the C++ Python modules and place the' - Write-Output 'generated libraries in their right locations within the MindQuantum' + Write-Output 'generated libraries in their right locations within the quafu' Write-Output 'folder hierarchy so Python knows how to find them.' Write-Output '' Write-Output 'A pth-file will be created in the virtualenv site-packages directory' - Write-Output 'so that the MindQuantum root folder will be added to the Python PATH' + Write-Output 'so that the quafu root folder will be added to the Python PATH' Write-Output 'without the need to modify PYTHONPATH.' } @@ -98,7 +98,7 @@ function Extra-Help { Write-Output ' -CCache If ccache or sccache are found within the PATH, use them with CMake' Write-Output ' -Clean Run make clean before building' Write-Output ' -C,-Configure Force running the CMake configure step' - Write-Output ' -ConfigureOnly Stop after the CMake configure and generation steps (ie. before building MindQuantum)' + Write-Output ' -ConfigureOnly Stop after the CMake configure and generation steps (ie. before building quafu)' Write-Output ' -Doc, -Docs Setup the Python virtualenv for building the documentation and ask CMake to build the' Write-Output ' documentation' Write-Output ' -Install Build the ´install´ target' @@ -189,7 +189,7 @@ if ($LastExitCode -ne 0) { if ($dry_run -ne 1) { # Make sure the root directory is in the virtualenv PATH $site_pkg_dir = Invoke-Expression -Command "$PYTHON -c 'import site; print(site.getsitepackages()[0])'" - $pth_file = "$site_pkg_dir\mindquantum_local.pth" + $pth_file = "$site_pkg_dir\quafu_local.pth" if (-Not (Test-Path -Path "$pth_file" -PathType leaf)) { Write-Output "Creating pth-file in $pth_file" @@ -285,10 +285,10 @@ if ($enable_gpu -and [bool]$cuda_arch) { } if ($force_local_pkgs) { - $cmake_args += "-DMQ_FORCE_LOCAL_PKGS=all" + $cmake_args += "-DQUAFU_FORCE_LOCAL_PKGS=all" } elseif ([bool]"$local_pkgs") { - $cmake_args += "-DMQ_FORCE_LOCAL_PKGS=`"$local_pkgs`"" + $cmake_args += "-DQUAFU_FORCE_LOCAL_PKGS=`"$local_pkgs`"" } if($n_jobs -ne -1) { @@ -388,11 +388,11 @@ Build MindQunantum locally (in-source build) This is mainly relevant for developers that do not want to always have to reinstall the Python package -This script will create a Python virtualenv in the MindQuantum root directory and then build all the C++ Python -modules and place the generated libraries in their right locations within the MindQuantum folder hierarchy so Python +This script will create a Python virtualenv in the quafu root directory and then build all the C++ Python +modules and place the generated libraries in their right locations within the quafu folder hierarchy so Python knows how to find them. -A pth-file will be created in the virtualenv site-packages directory so that the MindQuantum root folder will be added +A pth-file will be created in the virtualenv site-packages directory so that the quafu root folder will be added to the Python PATH without the need to modify PYTHONPATH. .PARAMETER Analyzer @@ -436,7 +436,7 @@ Force running the CMake configure step 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) +Stop after the CMake configure and generation steps (ie. before building quafu) .PARAMETER Debug Build in debug mode diff --git a/build_locally.sh b/build_locally.sh index 21afc7468..e100bb25b 100755 --- a/build_locally.sh +++ b/build_locally.sh @@ -22,7 +22,7 @@ PROGRAM=$(basename "${BASH_SOURCE[0]:-$0}") # Test for MindSpore CI _IS_MINDSPORE_CI=0 if [[ "${JENKINS_URL:-0}" =~ https?://build.mindspore.cn && ! "${CI:-0}" =~ ^(false|0)$ ]]; then - echo "Detected MindSpore/MindQuantum CI" + echo "Detected MindSpore/quafu CI" # shellcheck disable=SC2034 _IS_MINDSPORE_CI=1 fi @@ -42,13 +42,13 @@ function help_header() { echo 'This is mainly relevant for developers that do not want to always ' echo 'have to reinstall the Python package' echo '' - echo 'This script will create a Python virtualenv in the MindQuantum root' + echo 'This script will create a Python virtualenv in the quafu root' echo 'directory and then build all the C++ Python modules and place the' - echo 'generated libraries in their right locations within the MindQuantum' + echo 'generated libraries in their right locations within the quafu' echo 'folder hierarchy so Python knows how to find them.' echo '' echo 'A pth-file will be created in the virtualenv site-packages directory' - echo 'so that the MindQuantum root folder will be added to the Python PATH' + echo 'so that the quafu root folder will be added to the Python PATH' echo 'without the need to modify PYTHONPATH.' } @@ -56,7 +56,7 @@ function extra_help() { echo 'Extra options:' echo ' --clean Run make clean before building' echo ' -c,--configure Force running the CMake configure step' - echo ' --configure-only Stop after the CMake configure and generation steps (ie. before building MindQuantum)' + echo ' --configure-only Stop after the CMake configure and generation steps (ie. before building quafu)' echo ' --doc,--docs Setup the Python virtualenv for building the documentation and ask CMake to build the' echo ' documentation' echo ' --install Build the ´install´ target' @@ -129,7 +129,7 @@ fi if [ "$dry_run" -ne 1 ]; then # Make sure the root directory is in the virtualenv PATH site_pkg_dir=$("$PYTHON" -c 'import site; print(site.getsitepackages()[0])') - pth_file="$site_pkg_dir/mindquantum_local.pth" + pth_file="$site_pkg_dir/quafu_local.pth" if [ ! -e "$pth_file" ]; then echo "Creating pth-file in $pth_file" @@ -211,9 +211,9 @@ fi local_pkgs_str=$(join_by , "${local_pkgs[@]}") if [[ "$force_local_pkgs" -eq 1 ]]; then - cmake_args+=(-DMQ_FORCE_LOCAL_PKGS=all) + cmake_args+=(-DQUAFU_FORCE_LOCAL_PKGS=all) elif [ -n "$local_pkgs_str" ]; then - cmake_args+=(-DMQ_FORCE_LOCAL_PKGS="$local_pkgs_str") + cmake_args+=(-DQUAFU_FORCE_LOCAL_PKGS="$local_pkgs_str") fi if [ "$n_jobs" -ne -1 ]; then diff --git a/ccsrc/CMakeLists.txt b/ccsrc/CMakeLists.txt index 70d4e137c..e6e0a1852 100644 --- a/ccsrc/CMakeLists.txt +++ b/ccsrc/CMakeLists.txt @@ -16,21 +16,21 @@ # lint_cmake: -whitespace/indent -add_library(mq_base STATIC) -set_target_properties(mq_base PROPERTIES POSITION_INDEPENDENT_CODE TRUE) -target_compile_features(mq_base PUBLIC $,cxx_std_20,cxx_std_17>) -append_to_property(mq_install_targets GLOBAL mq_base) -force_at_least_cxx17_workaround(mq_base) +add_library(quafu_base STATIC) +set_target_properties(quafu_base PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +target_compile_features(quafu_base PUBLIC $,cxx_std_20,cxx_std_17>) +append_to_property(quafu_install_targets GLOBAL quafu_base) +force_at_least_cxx17_workaround(quafu_base) target_link_libraries( - mq_base - PUBLIC ${MQ_OPENMP_TARGET} + quafu_base + PUBLIC ${QUAFU_OPENMP_TARGET} cxx20_compat cmake_config - mq_math - mindquantum::fmt - mindquantum::json - mindquantum_setup - $<$:mindquantum::spdlog>) + quafu_math + quafu::fmt + quafu::json + quafu_setup + $<$:quafu::spdlog>) # ============================================================================== diff --git a/ccsrc/include/CMakeLists.txt b/ccsrc/include/CMakeLists.txt index 0f805ed9e..2b880bc68 100644 --- a/ccsrc/include/CMakeLists.txt +++ b/ccsrc/include/CMakeLists.txt @@ -18,7 +18,7 @@ # lint_cmake: -whitespace/indent -set(MQ_BASE_HEADERS +set(QUAFU_BASE_HEADERS config/popcnt.h config/config.h config/libc_compat.h @@ -27,22 +27,22 @@ set(MQ_BASE_HEADERS core/sparse/csrhdmatrix.h core/sparse/paulimat.h core/sparse/sparse_utils.h - core/mq_base_types.h + core/quafu_base_types.h core/utils.h ops/basic_gate.h ops/gates.h ops/hamiltonian.h ops/projector.h) -target_sources(mq_base PRIVATE $) -target_include_directories(mq_base PUBLIC $ - $) +target_sources(quafu_base PRIVATE $) +target_include_directories(quafu_base PUBLIC $ + $) # ============================================================================== add_library(include_lib INTERFACE) target_include_directories(include_lib INTERFACE $ - $) -append_to_property(mq_install_targets GLOBAL include_lib) + $) +append_to_property(quafu_install_targets GLOBAL include_lib) # ------------------------------------------------------------------------------ @@ -55,7 +55,7 @@ install( ${CMAKE_CURRENT_LIST_DIR}/simulator ${CMAKE_CURRENT_LIST_DIR}/device ${CMAKE_CURRENT_LIST_DIR}/math - DESTINATION ${MQ_INSTALL_INCLUDEDIR}/ + DESTINATION ${QUAFU_INSTALL_INCLUDEDIR}/ PATTERN "CPPLINT.cfg" EXCLUDE) # ============================================================================= diff --git a/ccsrc/include/algorithm/qaia/csr_base.h b/ccsrc/include/algorithm/qaia/csr_base.h index c694701e2..c549add4c 100644 --- a/ccsrc/include/algorithm/qaia/csr_base.h +++ b/ccsrc/include/algorithm/qaia/csr_base.h @@ -17,9 +17,9 @@ #ifndef CSR_BASE_H #define CSR_BASE_H -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" -namespace mindquantum::sparse { +namespace quafu::sparse { template struct CsrBase { int dim_; @@ -35,6 +35,6 @@ struct CsrBase { : dim_(dim), nnz_(nnz), indptr_(indptr), indices_(indices), data_(data) { } }; -} // namespace mindquantum::sparse +} // namespace quafu::sparse #endif diff --git a/ccsrc/include/algorithm/qaia/detail/gpu_sb.cuh b/ccsrc/include/algorithm/qaia/detail/gpu_sb.cuh index 319136277..331ab1bb9 100644 --- a/ccsrc/include/algorithm/qaia/detail/gpu_sb.cuh +++ b/ccsrc/include/algorithm/qaia/detail/gpu_sb.cuh @@ -20,32 +20,32 @@ #include "algorithm/qaia/csr_base.h" #include "algorithm/qaia/detail/para.h" -namespace mindquantum::algorithm::qaia::detail { +namespace quafu::algorithm::qaia::detail { struct SBBase { - static void dSB_update_int8(mindquantum::sparse::CsrBase csr, double* x, Para paras); + static void dSB_update_int8(quafu::sparse::CsrBase csr, double* x, Para paras); - static void bSB_update_int8(mindquantum::sparse::CsrBase csr, double* x, Para paras); + static void bSB_update_int8(quafu::sparse::CsrBase csr, double* x, Para paras); - static void bSB_update_fp16(mindquantum::sparse::CsrBase csr, double* x, Para paras); + static void bSB_update_fp16(quafu::sparse::CsrBase csr, double* x, Para paras); - static void dSB_update_fp16(mindquantum::sparse::CsrBase csr, double* x, Para paras); + static void dSB_update_fp16(quafu::sparse::CsrBase csr, double* x, Para paras); - static void dSB_update_h_int8(mindquantum::sparse::CsrBase csr, double* x, Para paras, double* h, + static void dSB_update_h_int8(quafu::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size); - static void bSB_update_h_int8(mindquantum::sparse::CsrBase csr, double* x, Para paras, double* h, + static void bSB_update_h_int8(quafu::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size); - static void bSB_update_h_fp16(mindquantum::sparse::CsrBase csr, double* x, Para paras, double* h, + static void bSB_update_h_fp16(quafu::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size); - static void dSB_update_h_fp16(mindquantum::sparse::CsrBase csr, double* x, Para paras, double* h, + static void dSB_update_h_fp16(quafu::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size); static void cublas_warmup(int N, int B); }; -} // namespace mindquantum::algorithm::qaia::detail +} // namespace quafu::algorithm::qaia::detail #endif diff --git a/ccsrc/include/algorithm/qaia/detail/para.h b/ccsrc/include/algorithm/qaia/detail/para.h index 956473829..51d155e71 100644 --- a/ccsrc/include/algorithm/qaia/detail/para.h +++ b/ccsrc/include/algorithm/qaia/detail/para.h @@ -17,7 +17,7 @@ #ifndef PARA_H #define PARA_H -namespace mindquantum::algorithm::qaia::detail { +namespace quafu::algorithm::qaia::detail { struct Para { int B; @@ -34,6 +34,6 @@ struct Para { } }; -} // namespace mindquantum::algorithm::qaia::detail +} // namespace quafu::algorithm::qaia::detail #endif diff --git a/ccsrc/include/algorithm/qaia/detail/sb_helper.h b/ccsrc/include/algorithm/qaia/detail/sb_helper.h index 0ade2cbb4..d7efac02d 100644 --- a/ccsrc/include/algorithm/qaia/detail/sb_helper.h +++ b/ccsrc/include/algorithm/qaia/detail/sb_helper.h @@ -23,7 +23,7 @@ #include "algorithm/qaia/detail/gpu_sb.cuh" #include "algorithm/qaia/detail/para.h" -namespace mindquantum::algorithm::qaia::detail { +namespace quafu::algorithm::qaia::detail { // Helper structure, using template specialization to select different update functions template @@ -31,67 +31,67 @@ struct SBUpdater; template <> struct SBUpdater<0, half, true> { - static void update(const mindquantum::sparse::CsrBase& csr_matrix, double* raw_x, - const mindquantum::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { - mindquantum::algorithm::qaia::detail::SBBase::bSB_update_h_fp16(csr_matrix, raw_x, paras, raw_h, h_size); + static void update(const quafu::sparse::CsrBase& csr_matrix, double* raw_x, + const quafu::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { + quafu::algorithm::qaia::detail::SBBase::bSB_update_h_fp16(csr_matrix, raw_x, paras, raw_h, h_size); } }; template <> struct SBUpdater<0, int8_t, true> { - static void update(const mindquantum::sparse::CsrBase& csr_matrix, double* raw_x, - const mindquantum::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { - mindquantum::algorithm::qaia::detail::SBBase::bSB_update_h_int8(csr_matrix, raw_x, paras, raw_h, h_size); + static void update(const quafu::sparse::CsrBase& csr_matrix, double* raw_x, + const quafu::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { + quafu::algorithm::qaia::detail::SBBase::bSB_update_h_int8(csr_matrix, raw_x, paras, raw_h, h_size); } }; template <> struct SBUpdater<1, half, true> { - static void update(const mindquantum::sparse::CsrBase& csr_matrix, double* raw_x, - const mindquantum::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { - mindquantum::algorithm::qaia::detail::SBBase::dSB_update_h_fp16(csr_matrix, raw_x, paras, raw_h, h_size); + static void update(const quafu::sparse::CsrBase& csr_matrix, double* raw_x, + const quafu::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { + quafu::algorithm::qaia::detail::SBBase::dSB_update_h_fp16(csr_matrix, raw_x, paras, raw_h, h_size); } }; template <> struct SBUpdater<1, int8_t, true> { - static void update(const mindquantum::sparse::CsrBase& csr_matrix, double* raw_x, - const mindquantum::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { - mindquantum::algorithm::qaia::detail::SBBase::dSB_update_h_int8(csr_matrix, raw_x, paras, raw_h, h_size); + static void update(const quafu::sparse::CsrBase& csr_matrix, double* raw_x, + const quafu::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { + quafu::algorithm::qaia::detail::SBBase::dSB_update_h_int8(csr_matrix, raw_x, paras, raw_h, h_size); } }; template <> struct SBUpdater<0, half, false> { - static void update(const mindquantum::sparse::CsrBase& csr_matrix, double* raw_x, - const mindquantum::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { - mindquantum::algorithm::qaia::detail::SBBase::bSB_update_fp16(csr_matrix, raw_x, paras); + static void update(const quafu::sparse::CsrBase& csr_matrix, double* raw_x, + const quafu::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { + quafu::algorithm::qaia::detail::SBBase::bSB_update_fp16(csr_matrix, raw_x, paras); } }; template <> struct SBUpdater<0, int8_t, false> { - static void update(const mindquantum::sparse::CsrBase& csr_matrix, double* raw_x, - const mindquantum::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { - mindquantum::algorithm::qaia::detail::SBBase::bSB_update_int8(csr_matrix, raw_x, paras); + static void update(const quafu::sparse::CsrBase& csr_matrix, double* raw_x, + const quafu::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { + quafu::algorithm::qaia::detail::SBBase::bSB_update_int8(csr_matrix, raw_x, paras); } }; template <> struct SBUpdater<1, half, false> { - static void update(const mindquantum::sparse::CsrBase& csr_matrix, double* raw_x, - const mindquantum::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { - mindquantum::algorithm::qaia::detail::SBBase::dSB_update_fp16(csr_matrix, raw_x, paras); + static void update(const quafu::sparse::CsrBase& csr_matrix, double* raw_x, + const quafu::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { + quafu::algorithm::qaia::detail::SBBase::dSB_update_fp16(csr_matrix, raw_x, paras); } }; template <> struct SBUpdater<1, int8_t, false> { - static void update(const mindquantum::sparse::CsrBase& csr_matrix, double* raw_x, - const mindquantum::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { - mindquantum::algorithm::qaia::detail::SBBase::dSB_update_int8(csr_matrix, raw_x, paras); + static void update(const quafu::sparse::CsrBase& csr_matrix, double* raw_x, + const quafu::algorithm::qaia::detail::Para& paras, double* raw_h, int h_size) { + quafu::algorithm::qaia::detail::SBBase::dSB_update_int8(csr_matrix, raw_x, paras); } }; -} // namespace mindquantum::algorithm::qaia::detail +} // namespace quafu::algorithm::qaia::detail #endif diff --git a/ccsrc/include/algorithm/qaia/detail/tools.cuh b/ccsrc/include/algorithm/qaia/detail/tools.cuh index 3cd9b9bbf..2300f8bb2 100644 --- a/ccsrc/include/algorithm/qaia/detail/tools.cuh +++ b/ccsrc/include/algorithm/qaia/detail/tools.cuh @@ -25,9 +25,9 @@ #include #include "algorithm/qaia/csr_base.h" -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" -using mindquantum::Index; +using quafu::Index; template struct Bounds; diff --git a/ccsrc/include/config/common_type.h b/ccsrc/include/config/common_type.h index b80f9229c..bf6f8b81b 100644 --- a/ccsrc/include/config/common_type.h +++ b/ccsrc/include/config/common_type.h @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_COMMON_TYPE_HPP -#define MQ_CONFIG_COMMON_TYPE_HPP +#ifndef QUAFU_CONFIG_COMMON_TYPE_HPP +#define QUAFU_CONFIG_COMMON_TYPE_HPP // ============================================================================= -namespace mindquantum::traits { +namespace quafu::traits { template struct common_type; @@ -76,8 +76,8 @@ struct common_type : common_type_fold, common template using common_type_t = typename common_type::type; -} // namespace mindquantum::traits +} // namespace quafu::traits // ============================================================================= -#endif /* MQ_CONFIG_COMMON_TYPE_HPP */ +#endif /* QUAFU_CONFIG_COMMON_TYPE_HPP */ diff --git a/ccsrc/include/config/complex_cast.h b/ccsrc/include/config/complex_cast.h index 7ae097486..02119bd88 100644 --- a/ccsrc/include/config/complex_cast.h +++ b/ccsrc/include/config/complex_cast.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_COMPLEX_CAST_HPP -#define MQ_CONFIG_COMPLEX_CAST_HPP +#ifndef QUAFU_CONFIG_COMPLEX_CAST_HPP +#define QUAFU_CONFIG_COMPLEX_CAST_HPP #include #include @@ -23,7 +23,7 @@ #include "config/type_traits.h" -namespace mindquantum { +namespace quafu { template class ParameterResolver; @@ -51,6 +51,6 @@ template constexpr auto complex_cast(real_t&& number) { return details::complex_cast_impl>::apply(std::forward(number)); } -} // namespace mindquantum +} // namespace quafu -#endif /* MQ_CONFIG_COMPLEX_CAST_HPP */ +#endif /* QUAFU_CONFIG_COMPLEX_CAST_HPP */ diff --git a/ccsrc/include/config/concepts.h b/ccsrc/include/config/concepts.h index 59fe65525..1f89638ea 100644 --- a/ccsrc/include/config/concepts.h +++ b/ccsrc/include/config/concepts.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_CONCEPTS_HPP -#define MQ_CONFIG_CONCEPTS_HPP +#ifndef QUAFU_CONFIG_CONCEPTS_HPP +#define QUAFU_CONFIG_CONCEPTS_HPP #include #include @@ -23,7 +23,7 @@ #include "config/config.h" #include "config/type_traits.h" -namespace mindquantum::concepts { +namespace quafu::concepts { template concept same_decay_as = std::same_as, std::remove_cvref_t>; @@ -43,6 +43,6 @@ concept complex_number = std::same_as, T>; template concept number = real_number> || complex_number>; -} // namespace mindquantum::concepts +} // namespace quafu::concepts -#endif /* MQ_CONFIG_CONCEPTS_HPP */ +#endif /* QUAFU_CONFIG_CONCEPTS_HPP */ diff --git a/ccsrc/include/config/config.h b/ccsrc/include/config/config.h index e33f167eb..59b98bb08 100644 --- a/ccsrc/include/config/config.h +++ b/ccsrc/include/config/config.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_CONFIG_HPP -#define MQ_CONFIG_CONFIG_HPP +#ifndef QUAFU_CONFIG_CONFIG_HPP +#define QUAFU_CONFIG_CONFIG_HPP #include "config/cmake_config.h" #ifdef __CUDACC__ @@ -32,66 +32,66 @@ #ifdef __has_cpp_attribute # if __has_cpp_attribute(nodiscard) -# define MQ_NODISCARD [[nodiscard]] +# define QUAFU_NODISCARD [[nodiscard]] # endif // __has_cpp_attribute(nodiscard) #endif // __has_cpp_attribute -#ifndef MQ_NODISCARD -# define MQ_NODISCARD -#endif // MQ_NODISCARD +#ifndef QUAFU_NODISCARD +# define QUAFU_NODISCARD +#endif // QUAFU_NODISCARD /*! - * \def MQ_NODISCARD + * \def QUAFU_NODISCARD * Add the [[nodiscard]] attribute to a function if supported by the compiler */ // ------------------------------------- #ifndef _MSC_VER -# define MQ_ALIGN(x) __attribute__((aligned(x))) +# define QUAFU_ALIGN(x) __attribute__((aligned(x))) #else -# define MQ_ALIGN(x) +# define QUAFU_ALIGN(x) #endif // !_MSC_VER /*! - * \def MQ_ALIGN(x) + * \def QUAFU_ALIGN(x) * Align a C++ struct/class to a specific size. */ // ============================================================================= -#ifndef MQ_IS_CLANG_VERSION_LESS -# define MQ_IS_CLANG_VERSION_LESS(major, minor) \ - (defined __clang__) && (MQ_CLANG_MAJOR < (major)) && (MQ_CLANG_MINOR < (minor)) -# define MQ_IS_CLANG_VERSION_LESS_EQUAL(major, minor) \ - (defined __clang__) && (MQ_CLANG_MAJOR <= (major)) && (MQ_CLANG_MINOR <= (minor)) -#endif // MQ_IS_CLANG_VERSION_LESS +#ifndef QUAFU_IS_CLANG_VERSION_LESS +# define QUAFU_IS_CLANG_VERSION_LESS(major, minor) \ + (defined __clang__) && (QUAFU_CLANG_MAJOR < (major)) && (QUAFU_CLANG_MINOR < (minor)) +# define QUAFU_IS_CLANG_VERSION_LESS_EQUAL(major, minor) \ + (defined __clang__) && (QUAFU_CLANG_MAJOR <= (major)) && (QUAFU_CLANG_MINOR <= (minor)) +#endif // QUAFU_IS_CLANG_VERSION_LESS /*! - * \def MQ_IS_CLANG_VERSION_LESS(major, minor) + * \def QUAFU_IS_CLANG_VERSION_LESS(major, minor) * True if the compiler is Clang and if its version is strictly less than . */ /*! - * \def MQ_IS_CLANG_VERSION_LESS_EQUAL(major, minor) + * \def QUAFU_IS_CLANG_VERSION_LESS_EQUAL(major, minor) * True if the compiler is Clang and if its version is less than or equal to . */ // ------------------------------------- -#if !defined(MQ_CONFIG_NO_COUNTER) && !defined(MQ_CONFIG_COUNTER) -# define MQ_CONFIG_COUNTER -#endif // !MQ_CONFIG_NO_COUNTER && !MQ_CONFIG_COUNTER +#if !defined(QUAFU_CONFIG_NO_COUNTER) && !defined(QUAFU_CONFIG_COUNTER) +# define QUAFU_CONFIG_COUNTER +#endif // !QUAFU_CONFIG_NO_COUNTER && !QUAFU_CONFIG_COUNTER -#define MQ_UNIQUE_NAME_LINE2_(name, line) name##line -#define MQ_UNIQUE_NAME_LINE_(name, line) MQ_UNIQUE_NAME_LINE2_(name, line) -#ifdef MQ_CONFIG_COUNTER -# define MQ_UNIQUE_NAME(name) MQ_UNIQUE_NAME_LINE_(name, __COUNTER__) +#define QUAFU_UNIQUE_NAME_LINE2_(name, line) name##line +#define QUAFU_UNIQUE_NAME_LINE_(name, line) QUAFU_UNIQUE_NAME_LINE2_(name, line) +#ifdef QUAFU_CONFIG_COUNTER +# define QUAFU_UNIQUE_NAME(name) QUAFU_UNIQUE_NAME_LINE_(name, __COUNTER__) #else -# define MQ_UNIQUE_NAME(name) MQ_UNIQUE_NAME_LINE_(name, __LINE__) +# define QUAFU_UNIQUE_NAME(name) QUAFU_UNIQUE_NAME_LINE_(name, __LINE__) #endif /*! - * \def MQ_UNIQUE_NAME(name) + * \def QUAFU_UNIQUE_NAME(name) * Define a unique and valid C++ identifier. * * This is either based on \c __COUNTER__ if supported or in \c __LINE__ otherwise. @@ -99,4 +99,4 @@ // ============================================================================= -#endif /* MQ_CONFIG_CONFIG_HPP */ +#endif /* QUAFU_CONFIG_CONFIG_HPP */ diff --git a/ccsrc/include/config/constexpr_type_name.h b/ccsrc/include/config/constexpr_type_name.h index f017a4a7f..87ce83d59 100644 --- a/ccsrc/include/config/constexpr_type_name.h +++ b/ccsrc/include/config/constexpr_type_name.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_CONSTEXPR_TYPE_NAME -#define MQ_CONFIG_CONSTEXPR_TYPE_NAME +#ifndef QUAFU_CONFIG_CONSTEXPR_TYPE_NAME +#define QUAFU_CONFIG_CONSTEXPR_TYPE_NAME #include #include @@ -38,7 +38,7 @@ * be reported as 'class A' or 'struct B'. */ -namespace mindquantum { +namespace quafu { template constexpr std::string_view get_type_name(); @@ -94,8 +94,8 @@ constexpr std::string_view get_type_name() { constexpr auto type_name_length = wrapped_name.length() - real_prefix_length - suffix_length; return wrapped_name.substr(real_prefix_length, type_name_length); } -} // namespace mindquantum +} // namespace quafu // ============================================================================= -#endif /* MQ_CONFIG_CONSTEXPR_TYPE_NAME */ +#endif /* QUAFU_CONFIG_CONSTEXPR_TYPE_NAME */ diff --git a/ccsrc/include/config/conversion.h b/ccsrc/include/config/conversion.h index ef6063f13..5e2f535e0 100644 --- a/ccsrc/include/config/conversion.h +++ b/ccsrc/include/config/conversion.h @@ -14,10 +14,10 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_CONVERSION_HPP -#define MQ_CONFIG_CONVERSION_HPP +#ifndef QUAFU_CONFIG_CONVERSION_HPP +#define QUAFU_CONFIG_CONVERSION_HPP -namespace mindquantum::traits { +namespace quafu::traits { //! Helper class to convert some variable into some pre-defined type if required template struct conversion_helper { @@ -34,6 +34,6 @@ struct conversion_helper { return static_cast(value); } }; -} // namespace mindquantum::traits +} // namespace quafu::traits -#endif /* MQ_CONFIG_CONVERSION_HPP */ +#endif /* QUAFU_CONFIG_CONVERSION_HPP */ diff --git a/ccsrc/include/config/details/clang_version.h b/ccsrc/include/config/details/clang_version.h index bcc79517e..8347d78bc 100644 --- a/ccsrc/include/config/details/clang_version.h +++ b/ccsrc/include/config/details/clang_version.h @@ -14,39 +14,39 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_CLANG_VERSION_HPP -#define MQ_CONFIG_CLANG_VERSION_HPP +#ifndef QUAFU_CONFIG_CLANG_VERSION_HPP +#define QUAFU_CONFIG_CLANG_VERSION_HPP #ifdef __clang__ # ifdef __apple_build_version__ # if __apple_build_version__ > 14000000 -# define MQ_CLANG_MAJOR 14 +# define QUAFU_CLANG_MAJOR 14 # elif __apple_build_version__ > 13160000 -# define MQ_CLANG_MAJOR 13 +# define QUAFU_CLANG_MAJOR 13 # elif __apple_build_version__ > 13000000 -# define MQ_CLANG_MAJOR 12 +# define QUAFU_CLANG_MAJOR 12 # elif __apple_build_version__ > 12050000 -# define MQ_CLANG_MAJOR 11 +# define QUAFU_CLANG_MAJOR 11 # elif __apple_build_version__ > 12000000 -# define MQ_CLANG_MAJOR 10 +# define QUAFU_CLANG_MAJOR 10 # elif __apple_build_version__ > 11030000 -# define MQ_CLANG_MAJOR 9 +# define QUAFU_CLANG_MAJOR 9 # elif __apple_build_version__ > 11000000 -# define MQ_CLANG_MAJOR 8 +# define QUAFU_CLANG_MAJOR 8 # elif __apple_build_version__ > 10010000 -# define MQ_CLANG_MAJOR 7 +# define QUAFU_CLANG_MAJOR 7 # else # error Detected version of clang is too old! # endif # if (__apple_build_version__ / 10000) == 1205 -# define MQ_CLANG_MINOR 1 +# define QUAFU_CLANG_MINOR 1 # else -# define MQ_CLANG_MINOR 0 +# define QUAFU_CLANG_MINOR 0 # endif # else -# define MQ_CLANG_MAJOR __clang_major__ -# define MQ_CLANG_MINOR __clang_minor__ +# define QUAFU_CLANG_MAJOR __clang_major__ +# define QUAFU_CLANG_MINOR __clang_minor__ # endif // __apple_build_version__ #endif // __clang__ -#endif /* MQ_CONFIG_CLANG_VERSION_HPP */ +#endif /* QUAFU_CONFIG_CLANG_VERSION_HPP */ diff --git a/ccsrc/include/config/details/cxx20_compatibility.h b/ccsrc/include/config/details/cxx20_compatibility.h index cfc0d9dd6..ec90847ad 100644 --- a/ccsrc/include/config/details/cxx20_compatibility.h +++ b/ccsrc/include/config/details/cxx20_compatibility.h @@ -24,12 +24,12 @@ # endif #endif -#if MQ_HAS_CONCEPTS +#if QUAFU_HAS_CONCEPTS # include #endif namespace std { -#if MQ_HAS_CONCEPTS && !MQ_HAS_CONCEPT_LIBRARY && !(defined(_MSC_VER) && __cpp_lib_concepts == 201907L) +#if QUAFU_HAS_CONCEPTS && !QUAFU_HAS_CONCEPT_LIBRARY && !(defined(_MSC_VER) && __cpp_lib_concepts == 201907L) // clang-format off template concept integral = is_integral_v; @@ -45,10 +45,10 @@ template concept derived_from = is_base_of_v && is_convertible_v; -#if !MQ_HAS_CONCEPT_DESTRUCTIBLE +#if !QUAFU_HAS_CONCEPT_DESTRUCTIBLE template concept destructible = is_nothrow_destructible_v; -#endif /* !MQ_HAS_CONCEPT_DESTRUCTIBLE */ +#endif /* !QUAFU_HAS_CONCEPT_DESTRUCTIBLE */ template concept constructible_from = destructible&& is_constructible_v; @@ -75,9 +75,9 @@ concept copy_constructible = move_constructible&& constructible_from&& convertible_to; // clang-format on -#endif // MQ_HAS_CONCEPTS && !MQ_HAS_CONCEPT_LIBRARY +#endif // QUAFU_HAS_CONCEPTS && !QUAFU_HAS_CONCEPT_LIBRARY -#if !MQ_HAS_REMOVE_CVREF_T +#if !QUAFU_HAS_REMOVE_CVREF_T template struct remove_cvref { using type = remove_cv_t>; @@ -85,14 +85,14 @@ struct remove_cvref { template using remove_cvref_t = typename remove_cvref::type; -#endif // !MQ_HAS_REMOVE_CVREF_T +#endif // !QUAFU_HAS_REMOVE_CVREF_T -#if !MQ_HAS_STD_LAUNDER +#if !QUAFU_HAS_STD_LAUNDER template constexpr T* launder(T* t) noexcept { return t; } -#endif // !MQ_HAS_STD_LAUNDER +#endif // !QUAFU_HAS_STD_LAUNDER } // namespace std diff --git a/ccsrc/include/config/details/macros.h b/ccsrc/include/config/details/macros.h index 5bb4a597b..7ba13e939 100644 --- a/ccsrc/include/config/details/macros.h +++ b/ccsrc/include/config/details/macros.h @@ -20,12 +20,12 @@ // ============================================================================= // NB: _Pragma(...) is a C++11 addition and should be widely supported -#define MQ_DO_PRAGMA(x) _Pragma(#x) +#define QUAFU_DO_PRAGMA(x) _Pragma(#x) // ============================================================================= #ifdef __clang__ -# define CLANG_DIAG_PRAGMA(x) MQ_DO_PRAGMA(GCC diagnostic x) +# define CLANG_DIAG_PRAGMA(x) QUAFU_DO_PRAGMA(GCC diagnostic x) # define CLANG_DIAG_OFF(x) \ CLANG_DIAG_PRAGMA(push) \ CLANG_DIAG_PRAGMA(ignored x) @@ -38,7 +38,7 @@ // ============================================================================= #if (defined __GNUC__) && !(defined __clang__) -# define GCC_DIAG_PRAGMA(x) MQ_DO_PRAGMA(GCC diagnostic x) +# define GCC_DIAG_PRAGMA(x) QUAFU_DO_PRAGMA(GCC diagnostic x) # define GCC_DIAG_OFF(x) \ GCC_DIAG_PRAGMA(push) \ GCC_DIAG_PRAGMA(ignored x) @@ -51,8 +51,8 @@ // ============================================================================= #ifdef _MSC_VER -# define MSVC_DIAG_OFF(x) MQ_DO_PRAGMA(warning(push)) MQ_DO_PRAGMA(warning(disable : warningNumber)) -# define MSVC_DIAG_ON(x) MQ_DO_PRAGMA(warning(pop)) +# define MSVC_DIAG_OFF(x) QUAFU_DO_PRAGMA(warning(push)) QUAFU_DO_PRAGMA(warning(disable : warningNumber)) +# define MSVC_DIAG_ON(x) QUAFU_DO_PRAGMA(warning(pop)) #else # define MSVC_DIAG_OFF(x) # define MSVC_DIAG_ON(x) diff --git a/ccsrc/include/config/detected.h b/ccsrc/include/config/detected.h index 5d90a857f..55a132e4a 100644 --- a/ccsrc/include/config/detected.h +++ b/ccsrc/include/config/detected.h @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_DETECTED_HPP -#define MQ_CONFIG_DETECTED_HPP +#ifndef QUAFU_CONFIG_DETECTED_HPP +#define QUAFU_CONFIG_DETECTED_HPP #include "config/config.h" #ifdef HAS_STD_DETECTED_TS2 # include -namespace mindquantum { +namespace quafu { using std::experimental::detected_or; using std::experimental::detected_t; using std::experimental::is_detected; @@ -33,11 +33,11 @@ using std::experimental::is_detected_convertible_v; using std::experimental::is_detected_exact; using std::experimental::is_detected_exact_v; using std::experimental::is_detected_v; -} // namespace mindquantum +} // namespace quafu #else # include -namespace mindquantum { +namespace quafu { namespace detail { template using void_t = void; @@ -90,7 +90,7 @@ using is_detected_convertible = std::is_convertible> template class Op, class... Args> constexpr inline bool is_detected_convertible_v = is_detected_convertible::value; -} // namespace mindquantum +} // namespace quafu #endif // COMPILER_TYPE_TRAITS_TS2 -#endif /* MQ_CONFIG_DETECTED_HPP */ +#endif /* QUAFU_CONFIG_DETECTED_HPP */ diff --git a/ccsrc/include/config/format/std_complex.h b/ccsrc/include/config/format/std_complex.h index 587f9a574..486f708f4 100644 --- a/ccsrc/include/config/format/std_complex.h +++ b/ccsrc/include/config/format/std_complex.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_FORMAT_COMPLEX_HPP -#define MQ_FORMAT_COMPLEX_HPP +#ifndef QUAFU_FORMAT_COMPLEX_HPP +#define QUAFU_FORMAT_COMPLEX_HPP #include @@ -74,4 +74,4 @@ struct nlohmann::adl_serializer> { } }; -#endif /* MQ_FORMAT_COMPLEX_HPP */ +#endif /* QUAFU_FORMAT_COMPLEX_HPP */ diff --git a/ccsrc/include/config/libc_compat.h b/ccsrc/include/config/libc_compat.h index e5e430eb5..5aba549f5 100644 --- a/ccsrc/include/config/libc_compat.h +++ b/ccsrc/include/config/libc_compat.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MQ_CONFIG_LIBC_COMPAT_H_ -#define MQ_CONFIG_LIBC_COMPAT_H_ +#ifndef QUAFU_CONFIG_LIBC_COMPAT_H_ +#define QUAFU_CONFIG_LIBC_COMPAT_H_ #ifdef __linux__ extern "C" { double __exp_finite(double x); diff --git a/ccsrc/include/config/logging.h b/ccsrc/include/config/logging.h index 23cbf7e92..db1ad4ce4 100644 --- a/ccsrc/include/config/logging.h +++ b/ccsrc/include/config/logging.h @@ -14,52 +14,52 @@ * limitations under the License. */ -#ifndef MQ_LOGGING_HPP -#define MQ_LOGGING_HPP +#ifndef QUAFU_LOGGING_HPP +#define QUAFU_LOGGING_HPP #ifdef ENABLE_LOGGING # include // NB: setting this to WARN will disable at compile time any log calls lower than that -# if !(defined MQ_LOG_ACTIVE_LEVEL) && (defined SPDLOG_ACTIVE_LEVEL) -# define MQ_LOG_ACTIVE_LEVEL SPDLOG_ACTIVE_LEVEL -# endif // !MQ_LOG_ACTIVE_LEVEL && SPDLOG_ACTIVE_LEVEL -# if !(defined SPDLOG_ACTIVE_LEVEL) && (defined MQ_LOG_ACTIVE_LEVEL) -# define SPDLOG_ACTIVE_LEVEL MQ_LOG_ACTIVE_LEVEL -# endif // !SPDLOG_ACTIVE_LEVEL && MQ_LOG_ACTIVE_LEVEL +# if !(defined QUAFU_LOG_ACTIVE_LEVEL) && (defined SPDLOG_ACTIVE_LEVEL) +# define QUAFU_LOG_ACTIVE_LEVEL SPDLOG_ACTIVE_LEVEL +# endif // !QUAFU_LOG_ACTIVE_LEVEL && SPDLOG_ACTIVE_LEVEL +# if !(defined SPDLOG_ACTIVE_LEVEL) && (defined QUAFU_LOG_ACTIVE_LEVEL) +# define SPDLOG_ACTIVE_LEVEL QUAFU_LOG_ACTIVE_LEVEL +# endif // !SPDLOG_ACTIVE_LEVEL && QUAFU_LOG_ACTIVE_LEVEL -# if !(defined SPDLOG_ACTIVE_LEVEL) && !(defined MQ_LOG_ACTIVE_LEVEL) -# define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_WARN -# define MQ_LOG_ACTIVE_LEVEL SPDLOG_LEVEL_WARN -# endif // !SPDLOG_ACTIVE_LEVEL && !MQ_LOG_ACTIVE_LEVEL +# if !(defined SPDLOG_ACTIVE_LEVEL) && !(defined QUAFU_LOG_ACTIVE_LEVEL) +# define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_WARN +# define QUAFU_LOG_ACTIVE_LEVEL SPDLOG_LEVEL_WARN +# endif // !SPDLOG_ACTIVE_LEVEL && !QUAFU_LOG_ACTIVE_LEVEL # include -namespace mindquantum::logging { +namespace quafu::logging { void set_log_file(const std::string& filename); -} // namespace mindquantum::logging +} // namespace quafu::logging -# define MQ_TRACE(...) SPDLOG_TRACE(__VA_ARGS__) -# define MQ_LOGGER_TRACE(logger, ...) SPDLOG_LOGGER_TRACE(logger, __VA_ARGS__) -# define MQ_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__) -# define MQ_LOGGER_DEBUG(logger, ...) SPDLOG_LOGGER_DEBUG(logger, __VA_ARGS__) -# define MQ_ERROR(...) SPDLOG_ERROR(__VA_ARGS__) -# define MQ_LOGGER_ERROR(logger, ...) SPDLOG_LOGGER_ERROR(logger, __VA_ARGS__) -# define MQ_INFO(...) SPDLOG_INFO(__VA_ARGS__) -# define MQ_LOGGER_INFO(logger, ...) SPDLOG_LOGGER_INFO(logger, __VA_ARGS__) -# define MQ_WARN(...) SPDLOG_WARN(__VA_ARGS__) -# define MQ_LOGGER_WARN(logger, ...) SPDLOG_LOGGER_WARN(logger, __VA_ARGS__) +# define QUAFU_TRACE(...) SPDLOG_TRACE(__VA_ARGS__) +# define QUAFU_LOGGER_TRACE(logger, ...) SPDLOG_LOGGER_TRACE(logger, __VA_ARGS__) +# define QUAFU_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__) +# define QUAFU_LOGGER_DEBUG(logger, ...) SPDLOG_LOGGER_DEBUG(logger, __VA_ARGS__) +# define QUAFU_ERROR(...) SPDLOG_ERROR(__VA_ARGS__) +# define QUAFU_LOGGER_ERROR(logger, ...) SPDLOG_LOGGER_ERROR(logger, __VA_ARGS__) +# define QUAFU_INFO(...) SPDLOG_INFO(__VA_ARGS__) +# define QUAFU_LOGGER_INFO(logger, ...) SPDLOG_LOGGER_INFO(logger, __VA_ARGS__) +# define QUAFU_WARN(...) SPDLOG_WARN(__VA_ARGS__) +# define QUAFU_LOGGER_WARN(logger, ...) SPDLOG_LOGGER_WARN(logger, __VA_ARGS__) #else -# define MQ_TRACE(...) static_cast(0) -# define MQ_LOGGER_TRACE(logger, ...) static_cast(0) -# define MQ_DEBUG(...) static_cast(0) -# define MQ_LOGGER_DEBUG(logger, ...) static_cast(0) -# define MQ_ERROR(...) static_cast(0) -# define MQ_LOGGER_ERROR(logger, ...) static_cast(0) -# define MQ_INFO(...) static_cast(0) -# define MQ_LOGGER_INFO(logger, ...) static_cast(0) -# define MQ_WARN(...) static_cast(0) -# define MQ_LOGGER_WARN(logger, ...) static_cast(0) +# define QUAFU_TRACE(...) static_cast(0) +# define QUAFU_LOGGER_TRACE(logger, ...) static_cast(0) +# define QUAFU_DEBUG(...) static_cast(0) +# define QUAFU_LOGGER_DEBUG(logger, ...) static_cast(0) +# define QUAFU_ERROR(...) static_cast(0) +# define QUAFU_LOGGER_ERROR(logger, ...) static_cast(0) +# define QUAFU_INFO(...) static_cast(0) +# define QUAFU_LOGGER_INFO(logger, ...) static_cast(0) +# define QUAFU_WARN(...) static_cast(0) +# define QUAFU_LOGGER_WARN(logger, ...) static_cast(0) #endif // ENABLE_LOGGING -#endif /* MQ_LOGGING_HPP */ +#endif /* QUAFU_LOGGING_HPP */ diff --git a/ccsrc/include/config/openmp.h b/ccsrc/include/config/openmp.h index 03d02229d..4fe4968eb 100644 --- a/ccsrc/include/config/openmp.h +++ b/ccsrc/include/config/openmp.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_OPENMP_HPP -#define MQ_CONFIG_OPENMP_HPP +#ifndef QUAFU_CONFIG_OPENMP_HPP +#define QUAFU_CONFIG_OPENMP_HPP #include @@ -27,4 +27,4 @@ using idx_t = uint64_t; #endif // _MSC_VER } // namespace omp -#endif /* MQ_CONFIG_OPENMP_HPP */ +#endif /* QUAFU_CONFIG_OPENMP_HPP */ diff --git a/ccsrc/include/config/parser/boost_x3_error_handler.h b/ccsrc/include/config/parser/boost_x3_error_handler.h index 709eefb72..2d8a6aa2b 100644 --- a/ccsrc/include/config/parser/boost_x3_error_handler.h +++ b/ccsrc/include/config/parser/boost_x3_error_handler.h @@ -32,7 +32,7 @@ #include "config/logging.h" -namespace mindquantum::parser { +namespace quafu::parser { template class error_handler; @@ -104,9 +104,9 @@ class error_handler { template void error_handler::print_file_line(std::size_t line) const { if (!std::empty(file)) { - MQ_LOGGER_ERROR(logger, "In file {}, line: {}", file, line); + QUAFU_LOGGER_ERROR(logger, "In file {}, line: {}", file, line); } else { - MQ_LOGGER_ERROR(logger, "On line: {}", line); + QUAFU_LOGGER_ERROR(logger, "On line: {}", line); } } @@ -122,7 +122,7 @@ void error_handler::print_line(iterator_t start, iterator_t last) co } using char_type = typename std::iterator_traits::value_type; std::basic_string line{start, end}; - MQ_LOGGER_ERROR(logger, boost::spirit::x3::to_utf8(line)); + QUAFU_LOGGER_ERROR(logger, boost::spirit::x3::to_utf8(line)); } template @@ -142,13 +142,13 @@ void error_handler::print_indicator(iterator_t& start, iterator_t la } switch (ind) { case ' ': - MQ_LOGGER_ERROR(logger, "{: >{}}{}", "", length, indicator); + QUAFU_LOGGER_ERROR(logger, "{: >{}}{}", "", length, indicator); break; case '~': - MQ_LOGGER_ERROR(logger, "{:~>{}}{}", "", length, indicator); + QUAFU_LOGGER_ERROR(logger, "{:~>{}}{}", "", length, indicator); break; default: - MQ_LOGGER_ERROR(logger, "{:->{}}{}", "", length, indicator); + QUAFU_LOGGER_ERROR(logger, "{:->{}}{}", "", length, indicator); break; } } @@ -196,7 +196,7 @@ void error_handler::operator()(iterator_t err_pos, std::string const iterator_t last = pos_cache.last(); print_file_line(position(err_pos)); - MQ_LOGGER_ERROR(logger, error_message); + QUAFU_LOGGER_ERROR(logger, error_message); iterator_t start = get_line_start(first, err_pos); print_line(start, last); @@ -210,7 +210,7 @@ void error_handler::operator()(iterator_t err_first, iterator_t err_ iterator_t last = pos_cache.last(); print_file_line(position(err_first)); - MQ_LOGGER_ERROR(logger, error_message); + QUAFU_LOGGER_ERROR(logger, error_message); iterator_t start = get_line_start(first, err_first); print_line(start, last); @@ -218,6 +218,6 @@ void error_handler::operator()(iterator_t err_first, iterator_t err_ print_indicator(start, err_last, '~', " <<-- Here"); } #endif // ENABLE_LOGGING -} // namespace mindquantum::parser +} // namespace quafu::parser #endif /* BOOST_X3_ERROR_HANDLER_HPP */ diff --git a/ccsrc/include/config/popcnt.h b/ccsrc/include/config/popcnt.h index 609a5bbd7..56ed57f3a 100644 --- a/ccsrc/include/config/popcnt.h +++ b/ccsrc/include/config/popcnt.h @@ -16,7 +16,7 @@ #ifndef MINDQUANTUM_POPCNT_HPP_ #define MINDQUANTUM_POPCNT_HPP_ -namespace mindquantum { +namespace quafu { constexpr static char POPCNTTABLE[256] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, @@ -25,5 +25,5 @@ constexpr static char POPCNTTABLE[256] = { 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8}; -} // namespace mindquantum +} // namespace quafu #endif // MINDQUANTUM_POPCNT_HPP_ diff --git a/ccsrc/include/config/real_cast.h b/ccsrc/include/config/real_cast.h index d3c17f729..ab503b633 100644 --- a/ccsrc/include/config/real_cast.h +++ b/ccsrc/include/config/real_cast.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_REAL_CAST_HPP -#define MQ_CONFIG_REAL_CAST_HPP +#ifndef QUAFU_CONFIG_REAL_CAST_HPP +#define QUAFU_CONFIG_REAL_CAST_HPP #include #include @@ -27,7 +27,7 @@ #include "config/config.h" #include "config/type_traits.h" -namespace mindquantum { +namespace quafu { template struct ParameterResolver; @@ -123,6 +123,6 @@ template constexpr auto real_cast(complex_t&& number) { return details::real_cast_impl>::apply(std::forward(number)); } -} // namespace mindquantum +} // namespace quafu -#endif /* MQ_CONFIG_REAL_CAST_HPP */ +#endif /* QUAFU_CONFIG_REAL_CAST_HPP */ diff --git a/ccsrc/include/config/tsl_ordered_map.h b/ccsrc/include/config/tsl_ordered_map.h index 66eac5c92..11624c653 100644 --- a/ccsrc/include/config/tsl_ordered_map.h +++ b/ccsrc/include/config/tsl_ordered_map.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_TSL_ORDERED_MAP_HPP -#define MQ_CONFIG_TSL_ORDERED_MAP_HPP +#ifndef QUAFU_CONFIG_TSL_ORDERED_MAP_HPP +#define QUAFU_CONFIG_TSL_ORDERED_MAP_HPP #include #include @@ -29,7 +29,7 @@ namespace tsl { template -MQ_NODISCARD constexpr function_t for_each(iterator_t first, const iterator_t& last, function_t func) { +QUAFU_NODISCARD constexpr function_t for_each(iterator_t first, const iterator_t& last, function_t func) { if constexpr (std::is_const_v::pointer>>) { return std::for_each(first, last, std::move(func)); } else { @@ -41,7 +41,7 @@ MQ_NODISCARD constexpr function_t for_each(iterator_t first, const iterator_t& l } template -MQ_NODISCARD constexpr iterator_t remove_if(iterator_t first, iterator_t last, predicate_t pred) { +QUAFU_NODISCARD constexpr iterator_t remove_if(iterator_t first, iterator_t last, predicate_t pred) { first = std::find_if(first, last, pred); if (first != last) { auto it = first; @@ -90,4 +90,4 @@ struct adl_serializer> { }; } // namespace nlohmann -#endif /* MQ_CONFIG_TSL_ORDERED_MAP_HPP */ +#endif /* QUAFU_CONFIG_TSL_ORDERED_MAP_HPP */ diff --git a/ccsrc/include/config/type_promotion.h b/ccsrc/include/config/type_promotion.h index 21384abc0..43bfa7ac6 100644 --- a/ccsrc/include/config/type_promotion.h +++ b/ccsrc/include/config/type_promotion.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_CONFIG_TYPE_PROMOTION_HPP -#define MQ_CONFIG_TYPE_PROMOTION_HPP +#ifndef QUAFU_CONFIG_TYPE_PROMOTION_HPP +#define QUAFU_CONFIG_TYPE_PROMOTION_HPP #include #include @@ -24,7 +24,7 @@ #include "config/config.h" #include "config/type_traits.h" -namespace mindquantum { +namespace quafu { namespace traits { template struct type_promotion; @@ -47,22 +47,22 @@ struct type_promotion_encapsulated_fp { // ------------------------------------- // float -> double -> long double (if the latter is enabled) -#if MQ_HAS_LONG_DOUBLE +#if QUAFU_HAS_LONG_DOUBLE template <> struct type_promotion { using down_cast_t = double; using up_cast_t = long double; }; -#endif // MQ_HAS_LONG_DOUBLE +#endif // QUAFU_HAS_LONG_DOUBLE template <> struct type_promotion { using down_cast_t = float; -#if MQ_HAS_LONG_DOUBLE +#if QUAFU_HAS_LONG_DOUBLE using up_cast_t = long double; #else using up_cast_t = double; -#endif // MQ_HAS_LONG_DOUBLE +#endif // QUAFU_HAS_LONG_DOUBLE }; template <> @@ -138,6 +138,6 @@ struct ComplexCast #include @@ -24,7 +24,7 @@ #include "config/config.h" #include "details/cxx20_compatibility.h" -namespace mindquantum::traits { +namespace quafu::traits { template inline constexpr auto is_same_decay_v = std::is_same_v, std::remove_cvref_t>; @@ -129,8 +129,8 @@ template inline constexpr auto is_unique = std::true_type{}; template -inline constexpr auto is_unique = std::bool_constant< - std::conjunction_v>...> && is_unique>{}; +inline constexpr auto is_unique + = std::bool_constant>...> && is_unique>{}; // --------------------------------- @@ -142,6 +142,6 @@ template inline constexpr auto tuple_contains> = std::disjunction_v...>; // ============================================================================= -} // namespace mindquantum::traits +} // namespace quafu::traits -#endif /* MQ_CONFIG_TRAITS_HPP */ +#endif /* QUAFU_CONFIG_TRAITS_HPP */ diff --git a/ccsrc/include/core/numba_wrapper.h b/ccsrc/include/core/numba_wrapper.h index 38c219173..7b328e339 100644 --- a/ccsrc/include/core/numba_wrapper.h +++ b/ccsrc/include/core/numba_wrapper.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MQ_CORE_NUMBER_WRAPPER_HPP_ -#define MQ_CORE_NUMBER_WRAPPER_HPP_ +#ifndef QUAFU_CORE_NUMBER_WRAPPER_HPP_ +#define QUAFU_CORE_NUMBER_WRAPPER_HPP_ #include #include @@ -27,7 +27,7 @@ #include "math/tensor/ops_cpu/memory_operator.h" #include "math/tensor/tensor.h" #include "math/tensor/traits.h" -namespace mindquantum { +namespace quafu { struct NumbaMatFunWrapper { using mat_t = void (*)(double, std::complex*); NumbaMatFunWrapper() = default; @@ -72,5 +72,5 @@ struct NumbaTwoParamMatFunWrapper { int dim; tensor::TDtype dtype = tensor::TDtype::Complex128; }; -} // namespace mindquantum +} // namespace quafu #endif diff --git a/ccsrc/include/core/mq_base_types.h b/ccsrc/include/core/quafu_base_types.h similarity index 98% rename from ccsrc/include/core/mq_base_types.h rename to ccsrc/include/core/quafu_base_types.h index e40002be4..2f0945c36 100644 --- a/ccsrc/include/core/mq_base_types.h +++ b/ccsrc/include/core/quafu_base_types.h @@ -27,7 +27,7 @@ #include #include -namespace mindquantum { +namespace quafu { #define PRECISION 1e-8 #define COS1_2(theta) static_cast(cos((theta) / 2)) #define SIN1_2(theta) static_cast(sin((theta) / 2)) @@ -149,5 +149,5 @@ constexpr const char cPD[] = "PDC"; // phase damping channel * */ static constexpr Index nQubitTh = 13; -} // namespace mindquantum +} // namespace quafu #endif // MINDQUANTUM_BASE_TYPES_HPP_ diff --git a/ccsrc/include/core/sparse/algo.h b/ccsrc/include/core/sparse/algo.h index 3e220ac7e..970079809 100644 --- a/ccsrc/include/core/sparse/algo.h +++ b/ccsrc/include/core/sparse/algo.h @@ -25,7 +25,7 @@ #include "core/sparse/sparse_utils.h" #include "core/utils.h" -namespace mindquantum::sparse { +namespace quafu::sparse { template std::shared_ptr> TransposeCsrHdMatrix(std::shared_ptr> a) { auto &dim = a->dim_; @@ -72,11 +72,11 @@ std::shared_ptr> PauliMatToCsrHdMatrix(std::shared_ptrcoeff_; auto &p = a->p_; THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for schedule(static) reduction(+ : nnz)), dim, static_cast(1) << nQubitTh, + QUAFU_DO_PRAGMA(omp parallel for schedule(static) reduction(+ : nnz)), dim, static_cast(1) << nQubitTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { - if (i <= col[i]) { - nnz++; - } + if (i <= col[i]) { + nnz++; + } }) Index *indptr = reinterpret_cast(malloc(sizeof(Index) * (dim + 1))); Index *indices = reinterpret_cast(malloc(sizeof(Index) * nnz)); @@ -136,10 +136,10 @@ std::shared_ptr> SparseHamiltonian(const VT> &hams, while (tot > 1) { Index half = tot / 2 + tot % 2; THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for schedule(static) num_threads(half)), n_qubits, nQubitTh, + QUAFU_DO_PRAGMA(omp parallel for schedule(static) num_threads(half)), n_qubits, nQubitTh, for (omp::idx_t i = static_cast(half); i < tot; i++) { - sp_hams[i - half] = Csr_Plus_Csr(sp_hams[i - half], sp_hams[i]); - sp_hams[i]->Reset(); + sp_hams[i - half] = Csr_Plus_Csr(sp_hams[i - half], sp_hams[i]); + sp_hams[i]->Reset(); }) tot = half; } @@ -175,16 +175,16 @@ CT ExpectationOfCsr(std::shared_ptr> a, T2 *bra, T2 *ket) { auto indices = a->indices_; T2 res_real = 0, res_imag = 0; THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, static_cast(1) << nQubitTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { - CT sum = {0.0, 0.0}; - for (Index j = indptr[i]; j < indptr[i + 1]; j++) { - sum += data[j] * c_ket[indices[j]]; - } - auto tmp = std::conj(c_bra[i]) * sum; - res_real += std::real(tmp); - res_imag += std::imag(tmp); + CT sum = {0.0, 0.0}; + for (Index j = indptr[i]; j < indptr[i + 1]; j++) { + sum += data[j] * c_ket[indices[j]]; + } + auto tmp = std::conj(c_bra[i]) * sum; + res_real += std::real(tmp); + res_imag += std::imag(tmp); }) return {res_real, res_imag}; } @@ -230,7 +230,7 @@ CT ExpectationOfCsr(std::shared_ptr> a, std::shared_ptr(1) << nQubitTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { CT sum = {0.0, 0.0}; @@ -247,5 +247,5 @@ CT ExpectationOfCsr(std::shared_ptr> a, std::shared_ptr struct CsrHdMatrix { Index dim_; @@ -85,5 +85,5 @@ struct CsrHdMatrix { std::cout << "-->\n\n"; } }; -} // namespace mindquantum::sparse +} // namespace quafu::sparse #endif // MINDQUANTUM_SPARSE_CSR_HD_MATRIX_H_ diff --git a/ccsrc/include/core/sparse/paulimat.h b/ccsrc/include/core/sparse/paulimat.h index 9eede0d8a..b957a9bb6 100644 --- a/ccsrc/include/core/sparse/paulimat.h +++ b/ccsrc/include/core/sparse/paulimat.h @@ -18,7 +18,7 @@ #include "core/utils.h" -namespace mindquantum { +namespace quafu { namespace sparse { template struct PauliMat { @@ -84,5 +84,5 @@ struct PauliMat { } }; } // namespace sparse -} // namespace mindquantum +} // namespace quafu #endif // MINDQUANTUM_SPARSE_PAULI_MAT_H_ diff --git a/ccsrc/include/core/sparse/sparse_utils.h b/ccsrc/include/core/sparse/sparse_utils.h index 0ef70161e..4fc05307d 100644 --- a/ccsrc/include/core/sparse/sparse_utils.h +++ b/ccsrc/include/core/sparse/sparse_utils.h @@ -21,7 +21,7 @@ #include "core/utils.h" -namespace mindquantum { +namespace quafu { namespace sparse { template void csr_plus_csr(Index dim, const Index *a_indptr, const Index *aj, const T *ad, const Index *b_indptr, @@ -90,5 +90,5 @@ void csr_plus_csr(Index dim, const Index *a_indptr, const Index *aj, const T *ad } } } // namespace sparse -} // namespace mindquantum +} // namespace quafu #endif // MINDQUANTUM_SPARSE_SPARSE_UTILS_H_ diff --git a/ccsrc/include/core/utils.h b/ccsrc/include/core/utils.h index 46dafa97d..9d2f52d1b 100644 --- a/ccsrc/include/core/utils.h +++ b/ccsrc/include/core/utils.h @@ -32,12 +32,12 @@ #include "config/config.h" #include "config/openmp.h" #include "config/popcnt.h" -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" -namespace mindquantum { -#ifndef MQ_DO_PRAGMA -# define MQ_DO_PRAGMA(x) _Pragma(# x) -#endif // !MQ_DO_PRAGMA +namespace quafu { +#ifndef QUAFU_DO_PRAGMA +# define QUAFU_DO_PRAGMA(x) _Pragma(#x) +#endif // !QUAFU_DO_PRAGMA #define THRESHOLD_OMP(omp_pragma, n, n_th, ...) \ if ((n) < (n_th)) { \ @@ -46,7 +46,7 @@ namespace mindquantum { omp_pragma __VA_ARGS__ \ } #define THRESHOLD_OMP_FOR(n, n_th, ...) \ - THRESHOLD_OMP(MQ_DO_PRAGMA(omp parallel for schedule(static)), n, n_th, __VA_ARGS__) + THRESHOLD_OMP(QUAFU_DO_PRAGMA(omp parallel for schedule(static)), n, n_th, __VA_ARGS__) extern const VT> POLAR; template @@ -56,11 +56,11 @@ CT ComplexInnerProduct(const ST *v1, const ST *v2, Index len) { ST imag_part = 0; auto size = len / 2; THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+ : real_part, imag_part)), len, static_cast(2) << nQubitTh, - for (omp::idx_t i = 0; i < static_cast(size); i++) { - real_part += v1[2 * i] * v2[2 * i] + v1[2 * i + 1] * v2[2 * i + 1]; - imag_part += v1[2 * i] * v2[2 * i + 1] - v1[2 * i + 1] * v2[2 * i]; - }) + QUAFU_DO_PRAGMA(omp parallel for reduction(+ : real_part, imag_part)), len, static_cast(2) << nQubitTh, + for (omp::idx_t i = 0; i < static_cast(size); i++) { + real_part += v1[2 * i] * v2[2 * i] + v1[2 * i + 1] * v2[2 * i + 1]; + imag_part += v1[2 * i] * v2[2 * i + 1] - v1[2 * i + 1] * v2[2 * i]; + }) CT result = {static_cast(real_part), static_cast(imag_part)}; return result; } @@ -72,13 +72,13 @@ CT ComplexInnerProductWithControl(const ST *v1, const ST *v2, Index len, Inde ST imag_part = 0; auto size = len / 2; THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+ : real_part, imag_part)), len, static_cast(2) << nQubitTh, - for (omp::idx_t i = 0; i < static_cast(size); i++) { - if ((i & ctrl_mask) == ctrl_mask) { - real_part += v1[2 * i] * v2[2 * i] + v1[2 * i + 1] * v2[2 * i + 1]; - imag_part += v1[2 * i] * v2[2 * i + 1] - v1[2 * i + 1] * v2[2 * i]; - } - }) + QUAFU_DO_PRAGMA(omp parallel for reduction(+ : real_part, imag_part)), len, static_cast(2) << nQubitTh, + for (omp::idx_t i = 0; i < static_cast(size); i++) { + if ((i & ctrl_mask) == ctrl_mask) { + real_part += v1[2 * i] * v2[2 * i] + v1[2 * i + 1] * v2[2 * i + 1]; + imag_part += v1[2 * i] * v2[2 * i + 1] - v1[2 * i + 1] * v2[2 * i]; + } + }) CT result = {static_cast(real_part), static_cast(imag_part)}; return result; } @@ -176,5 +176,5 @@ void PrintVec(T *vec, size_t len) { } void safe_copy(void *dest, size_t dest_size, const void *src, size_t count); -} // namespace mindquantum +} // namespace quafu #endif // MINDQUANTUM_UTILS_HPP_ diff --git a/ccsrc/include/device/mapping.h b/ccsrc/include/device/mapping.h index 6ea56405f..8610c0b54 100644 --- a/ccsrc/include/device/mapping.h +++ b/ccsrc/include/device/mapping.h @@ -28,7 +28,7 @@ #include "device/topology.h" #include "ops/basic_gate.h" #include "ops/gate_id.h" -namespace mindquantum::mapping { +namespace quafu::mapping { struct Gate { std::string type; // gate's type, such as CNOT or X int q1, q2; // logical qubit number, if @@ -49,7 +49,7 @@ std::pair> GateToAbstractGate(const VT> GetCircuitDAG(int n, const VT& gates); -class MQ_SABRE { +class QUAFU_SABRE { private: int num_logical; int num_physical; @@ -173,15 +173,15 @@ class MQ_SABRE { VT> CNOT_gate_length; // The length of the cnot gates /** - * @brief Construct a new MQ_SABRE object + * @brief Construct a new QUAFU_SABRE object * * @param circ logical qubits circle * @param coupling_graph physical qubits topology * @param num_physical number of physical qubits * @param CnotErrrorRateAndGateLength The error rate and length of the cnot gate between two adjacent qubits */ - MQ_SABRE(const VT>& circ, const std::shared_ptr& coupling_graph, - const std::vector, VT>>& CnotErrrorRateAndGateLength); + QUAFU_SABRE(const VT>& circ, const std::shared_ptr& coupling_graph, + const std::vector, VT>>& CnotErrrorRateAndGateLength); /** * @brief solve qubit mapping problem @@ -340,5 +340,5 @@ class SABRE { inline void SetParameters(double W, double delta1, double delta2); }; -} // namespace mindquantum::mapping +} // namespace quafu::mapping #endif diff --git a/ccsrc/include/device/topology.h b/ccsrc/include/device/topology.h index 5f21b8e5a..2b18c1ce9 100644 --- a/ccsrc/include/device/topology.h +++ b/ccsrc/include/device/topology.h @@ -25,7 +25,7 @@ #include #include -namespace mindquantum::mapping { +namespace quafu::mapping { using qbit_t = int64_t; template using VT = std::vector; @@ -125,6 +125,6 @@ class GridQubits : public QubitsTopology { int n_row = 0; int n_col = 0; }; -} // namespace mindquantum::mapping +} // namespace quafu::mapping #endif diff --git a/ccsrc/include/math/longbits/longbits.h b/ccsrc/include/math/longbits/longbits.h index 1a9b23ea6..c43077641 100644 --- a/ccsrc/include/math/longbits/longbits.h +++ b/ccsrc/include/math/longbits/longbits.h @@ -24,7 +24,7 @@ #include #include -namespace mindquantum { +namespace quafu { class LongBits { using ele_t = uint64_t; @@ -62,17 +62,17 @@ class LongBits { size_t n_bits = 1; std::vector data = {0}; }; -} // namespace mindquantum +} // namespace quafu // ----------------------------------------------------------------------------- template <> -struct fmt::formatter { +struct fmt::formatter { constexpr auto parse(format_parse_context& ctx) { // NOLINT(runtime/references) return ctx.begin(); } template - auto format(const mindquantum::LongBits& obj, FormatContext& ctx) { // NOLINT(runtime/references) + auto format(const quafu::LongBits& obj, FormatContext& ctx) { // NOLINT(runtime/references) return format_to(ctx.out(), obj.ToString()); } }; diff --git a/ccsrc/include/math/tensor/ops_cpu/basic_math.h b/ccsrc/include/math/tensor/ops_cpu/basic_math.h index 1b3aabca1..70b378816 100644 --- a/ccsrc/include/math/tensor/ops_cpu/basic_math.h +++ b/ccsrc/include/math/tensor/ops_cpu/basic_math.h @@ -22,7 +22,7 @@ #include #include "config/openmp.h" -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "core/utils.h" #include "math/tensor/csr_matrix.h" #include "math/tensor/matrix.h" @@ -592,7 +592,7 @@ Tensor MatMul(void* m1, size_t* indptr, size_t* indices, size_t n_row, size_t n_ auto c_out = reinterpret_cast(out.data); THRESHOLD_OMP_FOR( - len, static_cast(1) << mindquantum::nQubitTh, + len, static_cast(1) << quafu::nQubitTh, for (omp::idx_t i = 0; i < static_cast(n_row); i++) { upper_t sum = 0.0; for (omp::idx_t j = indptr[i]; j < static_cast(indptr[i + 1]); j++) { diff --git a/ccsrc/include/math/tensor/ops_cpu/memory_operator.h b/ccsrc/include/math/tensor/ops_cpu/memory_operator.h index cbad5cc3f..893dabdc8 100644 --- a/ccsrc/include/math/tensor/ops_cpu/memory_operator.h +++ b/ccsrc/include/math/tensor/ops_cpu/memory_operator.h @@ -111,7 +111,7 @@ template Tensor init_with_vector(const std::vector& a) { constexpr auto dtype = to_dtype_v; auto out = cpu::init(a.size()); - mindquantum::safe_copy(out.data, sizeof(T) * a.size(), a.data(), sizeof(T) * a.size()); + quafu::safe_copy(out.data, sizeof(T) * a.size(), a.data(), sizeof(T) * a.size()); return out; } @@ -121,7 +121,7 @@ template Tensor copy(const void* data, size_t len) { using calc_t = to_device_t; auto out = init(len); - mindquantum::safe_copy(out.data, sizeof(calc_t) * len, data, sizeof(calc_t) * len); + quafu::safe_copy(out.data, sizeof(calc_t) * len, data, sizeof(calc_t) * len); return out; } @@ -134,7 +134,7 @@ void* copy_mem(const void* data, size_t len) { if (res == nullptr) { throw std::runtime_error("malloc memory error."); } - mindquantum::safe_copy(res, sizeof(calc_t) * len, data, sizeof(calc_t) * len); + quafu::safe_copy(res, sizeof(calc_t) * len, data, sizeof(calc_t) * len); return res; } void* copy_mem(const void* data, TDtype dtype, size_t len); diff --git a/ccsrc/include/ops/basic_gate.h b/ccsrc/include/ops/basic_gate.h index 2709f6779..d8501726b 100644 --- a/ccsrc/include/ops/basic_gate.h +++ b/ccsrc/include/ops/basic_gate.h @@ -27,8 +27,8 @@ #include #include -#include "core/mq_base_types.h" #include "core/numba_wrapper.h" +#include "core/quafu_base_types.h" #include "core/utils.h" #include "math/pr/parameter_resolver.h" #include "math/tensor/matrix.h" @@ -36,7 +36,7 @@ #include "ops/gate_id.h" #include "ops/hamiltonian.h" -namespace mindquantum { +namespace quafu { class BasicGate { public: BasicGate() = default; @@ -108,7 +108,7 @@ class PauliString : public BasicGate { term.push_back(PauliWord(obj_qubits.at(i), pauli)); ++i; } - pauli_mask = mindquantum::GetPauliMask(term); + pauli_mask = quafu::GetPauliMask(term); ctrl_mask = GetControlMask(ctrl_qubits); } PauliMask GetPauliMask() const { @@ -510,9 +510,8 @@ class CustomTwoParamGate : public Parameterizable { , numba_param_diff_matrix2_(dm_addr2, dim) { if (!this->Parameterized()) { auto coeffs = this->GetCoeffs(); - base_matrix_ = this->numba_param_matrix_( - tensor::ops::cpu::to_vector(coeffs[0].const_value)[0], - tensor::ops::cpu::to_vector(coeffs[1].const_value)[0]); + base_matrix_ = this->numba_param_matrix_(tensor::ops::cpu::to_vector(coeffs[0].const_value)[0], + tensor::ops::cpu::to_vector(coeffs[1].const_value)[0]); } } @@ -539,5 +538,5 @@ class CustomTwoParamGate : public Parameterizable { NumbaTwoParamMatFunWrapper numba_param_diff_matrix1_; NumbaTwoParamMatFunWrapper numba_param_diff_matrix2_; }; -} // namespace mindquantum +} // namespace quafu #endif // MINDQUANTUM_GATE_basic_gate_H_ diff --git a/ccsrc/include/ops/gate_id.h b/ccsrc/include/ops/gate_id.h index dfb4d7655..12a75680a 100644 --- a/ccsrc/include/ops/gate_id.h +++ b/ccsrc/include/ops/gate_id.h @@ -14,60 +14,60 @@ * limitations under the License. */ -#ifndef MQ_GATE_ID -#define MQ_GATE_ID +#ifndef QUAFU_GATE_ID +#define QUAFU_GATE_ID #include #include #include -namespace mindquantum { +namespace quafu { enum class GateID : uint8_t { null, - I, // - X, // - Y, // - Z, // - RX, // - RY, // - RZ, // - Rxx, // - Ryy, // - Rzz, // - Rxy, // - Rxz, // - Ryz, // - Givens, // - Rn, // - H, // - SWAP, // - ISWAP, // - SWAPalpha, // - T, // - S, // - SX, // - SXdag, // - Tdag, // - Sdag, // - CNOT, // - CZ, // - GP, // - PauliString, // - RPS, // Rot-PauliString - PS, // - U3, // - FSim, // - M, // - PL, // Pauli channel - GPL, // Groupued Pauli channel - DEP, // depolarizing channel - AD, // amplitude damping channel - PD, // phase damping channel - KRAUS, // Kraus channel - TR, // thermal relaxation channel - CUSTOM, // - CUSTOM_TWO_PARAM,// - HOLDER, // for extended gate id. + I, // + X, // + Y, // + Z, // + RX, // + RY, // + RZ, // + Rxx, // + Ryy, // + Rzz, // + Rxy, // + Rxz, // + Ryz, // + Givens, // + Rn, // + H, // + SWAP, // + ISWAP, // + SWAPalpha, // + T, // + S, // + SX, // + SXdag, // + Tdag, // + Sdag, // + CNOT, // + CZ, // + GP, // + PauliString, // + RPS, // Rot-PauliString + PS, // + U3, // + FSim, // + M, // + PL, // Pauli channel + GPL, // Groupued Pauli channel + DEP, // depolarizing channel + AD, // amplitude damping channel + PD, // phase damping channel + KRAUS, // Kraus channel + TR, // thermal relaxation channel + CUSTOM, // + CUSTOM_TWO_PARAM, // + HOLDER, // for extended gate id. }; // NOLINTNEXTLINE(*avoid-c-arrays,readability-identifier-length) @@ -114,125 +114,125 @@ NLOHMANN_JSON_SERIALIZE_ENUM(GateID, {{GateID::I, "I"}, {GateID::CUSTOM_TWO_PARAM, "CUSTOM_TWO_PARAM"}, // 添加对应的序列化支持 {GateID::PauliString, "PauliString"}, {GateID::RPS, "RotPauliString"}}); -} // namespace mindquantum +} // namespace quafu template -struct fmt::formatter { +struct fmt::formatter { FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { // NOLINT(runtime/references) return ctx.begin(); } template - auto format_one(const mindquantum::GateID& value, format_context_t& ctx) const // NOLINT(runtime/references) + auto format_one(const quafu::GateID& value, format_context_t& ctx) const // NOLINT(runtime/references) -> decltype(ctx.out()) { switch (value) { - case mindquantum::GateID::Givens: + case quafu::GateID::Givens: return fmt::format_to(ctx.out(), "Givens"); - case mindquantum::GateID::GP: + case quafu::GateID::GP: return fmt::format_to(ctx.out(), "GP"); - case mindquantum::GateID::PS: + case quafu::GateID::PS: return fmt::format_to(ctx.out(), "PS"); - case mindquantum::GateID::U3: + case quafu::GateID::U3: return fmt::format_to(ctx.out(), "U3"); - case mindquantum::GateID::FSim: + case quafu::GateID::FSim: return fmt::format_to(ctx.out(), "FSim"); - case mindquantum::GateID::M: + case quafu::GateID::M: return fmt::format_to(ctx.out(), "M"); - case mindquantum::GateID::CUSTOM: + case quafu::GateID::CUSTOM: return fmt::format_to(ctx.out(), "CUSTOM"); - case mindquantum::GateID::CUSTOM_TWO_PARAM: + case quafu::GateID::CUSTOM_TWO_PARAM: return fmt::format_to(ctx.out(), "CUSTOM_TWO_PARAM"); - case mindquantum::GateID::SWAPalpha: + case quafu::GateID::SWAPalpha: return fmt::format_to(ctx.out(), "SWAPalpha"); - case mindquantum::GateID::PauliString: + case quafu::GateID::PauliString: return fmt::format_to(ctx.out(), "PauliString"); - case mindquantum::GateID::RPS: + case quafu::GateID::RPS: return fmt::format_to(ctx.out(), "RotPauliString"); default: - return fmt::format_to(ctx.out(), "Invalid "); + return fmt::format_to(ctx.out(), "Invalid "); } } template - auto format_two(const mindquantum::GateID& value, format_context_t& ctx) const // NOLINT(runtime/references) + auto format_two(const quafu::GateID& value, format_context_t& ctx) const // NOLINT(runtime/references) -> decltype(ctx.out()) { switch (value) { - case mindquantum::GateID::PL: + case quafu::GateID::PL: return fmt::format_to(ctx.out(), "PL"); - case mindquantum::GateID::GPL: + case quafu::GateID::GPL: return fmt::format_to(ctx.out(), "GPL"); - case mindquantum::GateID::DEP: + case quafu::GateID::DEP: return fmt::format_to(ctx.out(), "DEP"); - case mindquantum::GateID::AD: + case quafu::GateID::AD: return fmt::format_to(ctx.out(), "AD"); - case mindquantum::GateID::PD: + case quafu::GateID::PD: return fmt::format_to(ctx.out(), "PD"); - case mindquantum::GateID::KRAUS: + case quafu::GateID::KRAUS: return fmt::format_to(ctx.out(), "KRAUS"); - case mindquantum::GateID::TR: + case quafu::GateID::TR: return fmt::format_to(ctx.out(), "TR"); default: return format_one(value, ctx); } } template - auto format_three(const mindquantum::GateID& value, format_context_t& ctx) const // NOLINT(runtime/references) + auto format_three(const quafu::GateID& value, format_context_t& ctx) const // NOLINT(runtime/references) -> decltype(ctx.out()) { switch (value) { - case mindquantum::GateID::RX: + case quafu::GateID::RX: return fmt::format_to(ctx.out(), "RX"); - case mindquantum::GateID::RY: + case quafu::GateID::RY: return fmt::format_to(ctx.out(), "RY"); - case mindquantum::GateID::RZ: + case quafu::GateID::RZ: return fmt::format_to(ctx.out(), "RZ"); - case mindquantum::GateID::Rxx: + case quafu::GateID::Rxx: return fmt::format_to(ctx.out(), "Rxx"); - case mindquantum::GateID::Ryy: + case quafu::GateID::Ryy: return fmt::format_to(ctx.out(), "Ryy"); - case mindquantum::GateID::Rzz: + case quafu::GateID::Rzz: return fmt::format_to(ctx.out(), "Rzz"); - case mindquantum::GateID::Rxy: + case quafu::GateID::Rxy: return fmt::format_to(ctx.out(), "Rxy"); - case mindquantum::GateID::Rxz: + case quafu::GateID::Rxz: return fmt::format_to(ctx.out(), "Rxz"); - case mindquantum::GateID::Ryz: + case quafu::GateID::Ryz: return fmt::format_to(ctx.out(), "Ryz"); - case mindquantum::GateID::Rn: + case quafu::GateID::Rn: return fmt::format_to(ctx.out(), "Rn"); default: return format_two(value, ctx); } } template - auto format(const mindquantum::GateID& value, format_context_t& ctx) const // NOLINT(runtime/references) + auto format(const quafu::GateID& value, format_context_t& ctx) const // NOLINT(runtime/references) -> decltype(ctx.out()) { switch (value) { - case mindquantum::GateID::I: + case quafu::GateID::I: return fmt::format_to(ctx.out(), "I"); - case mindquantum::GateID::X: + case quafu::GateID::X: return fmt::format_to(ctx.out(), "X"); - case mindquantum::GateID::Y: + case quafu::GateID::Y: return fmt::format_to(ctx.out(), "Y"); - case mindquantum::GateID::Z: + case quafu::GateID::Z: return fmt::format_to(ctx.out(), "Z"); - case mindquantum::GateID::H: + case quafu::GateID::H: return fmt::format_to(ctx.out(), "H"); - case mindquantum::GateID::SWAP: + case quafu::GateID::SWAP: return fmt::format_to(ctx.out(), "SWAP"); - case mindquantum::GateID::ISWAP: + case quafu::GateID::ISWAP: return fmt::format_to(ctx.out(), "ISWAP"); - case mindquantum::GateID::T: + case quafu::GateID::T: return fmt::format_to(ctx.out(), "T"); - case mindquantum::GateID::S: + case quafu::GateID::S: return fmt::format_to(ctx.out(), "S"); - case mindquantum::GateID::SX: + case quafu::GateID::SX: return fmt::format_to(ctx.out(), "SX"); - case mindquantum::GateID::Tdag: + case quafu::GateID::Tdag: return fmt::format_to(ctx.out(), "Tdag"); - case mindquantum::GateID::SXdag: + case quafu::GateID::SXdag: return fmt::format_to(ctx.out(), "SXdag"); - case mindquantum::GateID::Sdag: + case quafu::GateID::Sdag: return fmt::format_to(ctx.out(), "Sdag"); - case mindquantum::GateID::CNOT: + case quafu::GateID::CNOT: return fmt::format_to(ctx.out(), "CNOT"); - case mindquantum::GateID::CZ: + case quafu::GateID::CZ: return fmt::format_to(ctx.out(), "CZ"); default: return format_three(value, ctx); diff --git a/ccsrc/include/ops/gates.h b/ccsrc/include/ops/gates.h index bff21a6af..5c8833823 100644 --- a/ccsrc/include/ops/gates.h +++ b/ccsrc/include/ops/gates.h @@ -23,7 +23,7 @@ #include #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "core/utils.h" #include "math/pr/parameter_resolver.h" #include "math/tensor/matrix.h" @@ -47,7 +47,7 @@ # define M_PI_2 1.57079632679489661923132169163975144 #endif // !M_PI_2 -namespace mindquantum { +namespace quafu { tensor::Matrix U3Matrix(tensor::Tensor theta, tensor::Tensor phi, tensor::Tensor lambda); tensor::Matrix FSimMatrix(tensor::Tensor theta, tensor::Tensor phi); @@ -137,5 +137,5 @@ class Rn : public Parameterizable { parameter::ParameterResolver gamma; tensor::Matrix base_matrix_; }; -} // namespace mindquantum +} // namespace quafu #endif // MINDQUANTUM_GATE_GATES_HPP_ diff --git a/ccsrc/include/ops/gates/traits.h b/ccsrc/include/ops/gates/traits.h index 85a5f936e..effcae901 100644 --- a/ccsrc/include/ops/gates/traits.h +++ b/ccsrc/include/ops/gates/traits.h @@ -22,7 +22,7 @@ #include "config/type_traits.h" -namespace mindquantum::traits { +namespace quafu::traits { template struct is_compatible_scalar : std::false_type {}; @@ -51,6 +51,6 @@ static_assert(is_compatible_scalar_v); static_assert(is_compatible_scalar_v); static_assert(is_compatible_scalar_v, false>); static_assert(is_compatible_scalar_v, false>); -} // namespace mindquantum::traits +} // namespace quafu::traits #endif /* OPS_GATES_TRAITS_HPP */ diff --git a/ccsrc/include/ops/hamiltonian.h b/ccsrc/include/ops/hamiltonian.h index cb63a63ec..31afed882 100644 --- a/ccsrc/include/ops/hamiltonian.h +++ b/ccsrc/include/ops/hamiltonian.h @@ -21,10 +21,10 @@ #include "core/sparse/algo.h" #include "core/utils.h" -namespace mindquantum { -using mindquantum::sparse::CsrHdMatrix; -using mindquantum::sparse::SparseHamiltonian; -using mindquantum::sparse::TransposeCsrHdMatrix; +namespace quafu { +using quafu::sparse::CsrHdMatrix; +using quafu::sparse::SparseHamiltonian; +using quafu::sparse::TransposeCsrHdMatrix; template struct Hamiltonian { @@ -54,5 +54,5 @@ struct Hamiltonian { : n_qubits_(n_qubits), how_to_(FRONTEND), ham_sparse_main_(csr_mat) { } }; -} // namespace mindquantum +} // namespace quafu #endif // MINDQUANTUM_HAMILTONIAN_HAMILTONIAN_H_ diff --git a/ccsrc/include/ops/projector.h b/ccsrc/include/ops/projector.h index fc5ec85da..fa2e5ecdd 100644 --- a/ccsrc/include/ops/projector.h +++ b/ccsrc/include/ops/projector.h @@ -20,7 +20,7 @@ #include "core/utils.h" -namespace mindquantum { +namespace quafu { struct Projector { std::string proj_str_; Index n_qubits_; @@ -45,5 +45,5 @@ struct Projector { } } }; -} // namespace mindquantum +} // namespace quafu #endif // MINDQUANTUM_PROJECTOR_PROJECTOR_H_ diff --git a/ccsrc/include/simulator/densitymatrix/densitymatrix_state.h b/ccsrc/include/simulator/densitymatrix/densitymatrix_state.h index 12db0b2c2..126a8987d 100644 --- a/ccsrc/include/simulator/densitymatrix/densitymatrix_state.h +++ b/ccsrc/include/simulator/densitymatrix/densitymatrix_state.h @@ -34,7 +34,7 @@ #include #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "math/pr/parameter_resolver.h" #include "ops/basic_gate.h" #include "ops/gates.h" @@ -42,7 +42,7 @@ #include "simulator/timer.h" #include "simulator/utils.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { template struct BLAS; @@ -198,7 +198,7 @@ class DensityMatrixState { RndEngine rnd_eng_; std::function rng_; }; -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail #include "simulator/densitymatrix/densitymatrix_state.tpp" // NOLINT diff --git a/ccsrc/include/simulator/densitymatrix/densitymatrix_state.tpp b/ccsrc/include/simulator/densitymatrix/densitymatrix_state.tpp index a2f315a6d..41a58c5d3 100644 --- a/ccsrc/include/simulator/densitymatrix/densitymatrix_state.tpp +++ b/ccsrc/include/simulator/densitymatrix/densitymatrix_state.tpp @@ -36,7 +36,7 @@ #include #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "math/pr/parameter_resolver.h" #include "math/tensor/matrix.h" #include "math/tensor/ops/basic_math.h" @@ -46,7 +46,7 @@ #include "ops/hamiltonian.h" #include "simulator/densitymatrix/densitymatrix_state.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { template DensityMatrixState::DensityMatrixState(qbit_t n_qubits, unsigned seed) @@ -1153,6 +1153,6 @@ VT DensityMatrixState::SamplingMeasurementEndingWithoutN } return sim.Sampling(mea_circ, pr, shots, key_map, static_cast(rng())); } -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail #endif diff --git a/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_arm_double_policy.h b/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_arm_double_policy.h index 6948099ef..221ca28e9 100644 --- a/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_arm_double_policy.h +++ b/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_arm_double_policy.h @@ -17,7 +17,7 @@ #define INCLUDE_DENSITYMATRIX_DETAIL_CPU_DENSITYMATRIX_ARM_DOUBLE_POLICY_HPP #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { struct CPUDensityMatrixPolicyArmDouble : public CPUDensityMatrixPolicyBase {}; -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail #endif diff --git a/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_arm_float_policy.h b/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_arm_float_policy.h index 768bdd4b7..937eb378e 100644 --- a/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_arm_float_policy.h +++ b/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_arm_float_policy.h @@ -17,7 +17,7 @@ #define INCLUDE_DENSITYMATRIX_DETAIL_CPU_DENSITYMATRIX_ARM_FLOAT_POLICY_HPP #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { struct CPUDensityMatrixPolicyArmFloat : public CPUDensityMatrixPolicyBase {}; -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail #endif diff --git a/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_avx_double_policy.h b/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_avx_double_policy.h index 69c26bc17..485c46cd7 100644 --- a/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_avx_double_policy.h +++ b/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_avx_double_policy.h @@ -17,7 +17,7 @@ #define INCLUDE_DENSITYMATRIX_DETAIL_CPU_DENSITYMATRIX_AVX_DOUBLE_POLICY_HPP #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { struct CPUDensityMatrixPolicyAvxDouble : public CPUDensityMatrixPolicyBase {}; -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail #endif diff --git a/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_avx_float_policy.h b/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_avx_float_policy.h index f096bcb76..8b1e7a6ff 100644 --- a/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_avx_float_policy.h +++ b/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_avx_float_policy.h @@ -17,7 +17,7 @@ #define INCLUDE_DENSITYMATRIX_DETAIL_CPU_DENSITYMATRIX_AVX_FLOAT_POLICY_HPP #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { struct CPUDensityMatrixPolicyAvxFloat : public CPUDensityMatrixPolicyBase {}; -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail #endif diff --git a/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_policy.h b/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_policy.h index 6f5b41e26..3796acd1b 100644 --- a/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_policy.h +++ b/ccsrc/include/simulator/densitymatrix/detail/cpu_densitymatrix_policy.h @@ -25,7 +25,7 @@ #include "config/openmp.h" #include "config/type_promotion.h" -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "core/utils.h" #include "math/tensor/ops_cpu/utils.h" #include "ops/hamiltonian.h" @@ -38,7 +38,7 @@ #define SelfMultiply(qs, x, y, data) \ (((x) >= (y)) ? ((qs)[IdxMap((x), (y))] *= (data)) : ((qs)[IdxMap((y), (x))] *= std::conj((data)))) -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { struct CPUDensityMatrixPolicyAvxFloat; struct CPUDensityMatrixPolicyAvxDouble; @@ -290,6 +290,6 @@ struct CastTo { return des; } }; -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail #endif diff --git a/ccsrc/include/simulator/stabilizer/query_element.h b/ccsrc/include/simulator/stabilizer/query_element.h index e7639e7c3..7c866e814 100644 --- a/ccsrc/include/simulator/stabilizer/query_element.h +++ b/ccsrc/include/simulator/stabilizer/query_element.h @@ -19,7 +19,7 @@ #include "simulator/stabilizer/stabilizer.h" -namespace mindquantum::stabilizer { +namespace quafu::stabilizer { std::pair DetermineClass(size_t i); void EvoClass1(StabilizerTableau* stab, size_t idx); void EvoClass2(StabilizerTableau* stab, size_t idx); @@ -28,5 +28,5 @@ void EvoClass4(StabilizerTableau* stab, size_t idx); StabilizerTableau QueryDoubleQubitsCliffordElem(size_t idx); StabilizerTableau QuerySingleQubitCliffordElem(size_t idx); void Verification(); -} // namespace mindquantum::stabilizer +} // namespace quafu::stabilizer #endif diff --git a/ccsrc/include/simulator/stabilizer/random_benchmarking.h b/ccsrc/include/simulator/stabilizer/random_benchmarking.h index 97fc9284f..5b753d561 100644 --- a/ccsrc/include/simulator/stabilizer/random_benchmarking.h +++ b/ccsrc/include/simulator/stabilizer/random_benchmarking.h @@ -17,8 +17,8 @@ #define SIMULATOR_STABILIZER_RANDOM_BENCHMARKING_H_ #include "simulator/stabilizer/query_element.h" #include "simulator/stabilizer/stabilizer.h" -namespace mindquantum::stabilizer { +namespace quafu::stabilizer { VT SingleQubitRBCircuit(size_t len, int seed); VT DoubleQubitsRBCircuit(size_t len, int seed); -} // namespace mindquantum::stabilizer +} // namespace quafu::stabilizer #endif diff --git a/ccsrc/include/simulator/stabilizer/stabilizer.h b/ccsrc/include/simulator/stabilizer/stabilizer.h index e0728688a..147cf7763 100644 --- a/ccsrc/include/simulator/stabilizer/stabilizer.h +++ b/ccsrc/include/simulator/stabilizer/stabilizer.h @@ -25,7 +25,7 @@ #include "math/longbits/longbits.h" #include "ops/basic_gate.h" #include "ops/gate_id.h" -namespace mindquantum::stabilizer { +namespace quafu::stabilizer { using stab_circ_t = VT>; class StabilizerTableau { @@ -80,5 +80,5 @@ class StabilizerTableau { }; stab_circ_t CliffordCircDagger(const stab_circ_t& circ); -} // namespace mindquantum::stabilizer +} // namespace quafu::stabilizer #endif diff --git a/ccsrc/include/simulator/timer.h b/ccsrc/include/simulator/timer.h index 307215674..f1b7e8c60 100644 --- a/ccsrc/include/simulator/timer.h +++ b/ccsrc/include/simulator/timer.h @@ -26,7 +26,7 @@ #include #include -namespace mindquantum::timer { +namespace quafu::timer { using TimePoint = typename std::chrono::steady_clock::time_point; TimePoint NOW(); @@ -93,6 +93,6 @@ class Timer { private: std::map> data_{}; }; -} // namespace mindquantum::timer +} // namespace quafu::timer #endif diff --git a/ccsrc/include/simulator/utils.h b/ccsrc/include/simulator/utils.h index eeab7ab24..a70fddfe7 100644 --- a/ccsrc/include/simulator/utils.h +++ b/ccsrc/include/simulator/utils.h @@ -20,9 +20,9 @@ #include #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" -namespace mindquantum::sim { +namespace quafu::sim { index_t QIndexToMask(qbits_t objs); PauliMask GenPauliMask(const std::vector& pws); struct SingleQubitGateMask { @@ -56,6 +56,6 @@ struct DoubleQubitGateMask { (des) = (((ori) & (obj_rev_low_mask)) << 1) + ((ori) & (obj_low_mask)); \ (des) = (((des) & (obj_rev_high_mask)) << 1) + ((des) & (obj_high_mask)); \ } while (0) -} // namespace mindquantum::sim +} // namespace quafu::sim #endif diff --git a/ccsrc/include/simulator/vector/blas.h b/ccsrc/include/simulator/vector/blas.h index 54b5bc71f..d7e4d3dcd 100644 --- a/ccsrc/include/simulator/vector/blas.h +++ b/ccsrc/include/simulator/vector/blas.h @@ -19,7 +19,7 @@ #include #include "simulator/vector/vector_state.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template struct BLAS { using qs_policy_t = qs_policy_t_; @@ -30,5 +30,5 @@ struct BLAS { return qs_policy_t::Vdot(bra.qs, ket.qs, bra.dim); } }; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail #endif diff --git a/ccsrc/include/simulator/vector/detail/cpu_vector_arm_double_policy.h b/ccsrc/include/simulator/vector/detail/cpu_vector_arm_double_policy.h index 98206e173..3256b9b61 100644 --- a/ccsrc/include/simulator/vector/detail/cpu_vector_arm_double_policy.h +++ b/ccsrc/include/simulator/vector/detail/cpu_vector_arm_double_policy.h @@ -18,7 +18,7 @@ #include #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { struct CPUVectorPolicyArmDouble : public CPUVectorPolicyBase {}; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail #endif diff --git a/ccsrc/include/simulator/vector/detail/cpu_vector_arm_float_policy.h b/ccsrc/include/simulator/vector/detail/cpu_vector_arm_float_policy.h index f5539b4be..3658ed544 100644 --- a/ccsrc/include/simulator/vector/detail/cpu_vector_arm_float_policy.h +++ b/ccsrc/include/simulator/vector/detail/cpu_vector_arm_float_policy.h @@ -17,7 +17,7 @@ #define INCLUDE_VECTOR_DETAIL_CPU_VECTOR_ARM_FLOAT_POLICY_HPP #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { struct CPUVectorPolicyArmFloat : public CPUVectorPolicyBase {}; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail #endif diff --git a/ccsrc/include/simulator/vector/detail/cpu_vector_avx_double_policy.h b/ccsrc/include/simulator/vector/detail/cpu_vector_avx_double_policy.h index aa67e775f..0830b0cd4 100644 --- a/ccsrc/include/simulator/vector/detail/cpu_vector_avx_double_policy.h +++ b/ccsrc/include/simulator/vector/detail/cpu_vector_avx_double_policy.h @@ -53,7 +53,7 @@ } \ } while (0) -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { struct CPUVectorPolicyAvxDouble : public CPUVectorPolicyBase { using gate_matrix_t = std::vector>; static void ApplySingleQubitMatrix(const qs_data_p_t& src, qs_data_p_t* des_p, qbit_t obj_qubit, @@ -62,5 +62,5 @@ struct CPUVectorPolicyAvxDouble : public CPUVectorPolicyBase& m, index_t dim); }; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail #endif diff --git a/ccsrc/include/simulator/vector/detail/cpu_vector_avx_float_policy.h b/ccsrc/include/simulator/vector/detail/cpu_vector_avx_float_policy.h index 6beab4628..f2a7a55e1 100644 --- a/ccsrc/include/simulator/vector/detail/cpu_vector_avx_float_policy.h +++ b/ccsrc/include/simulator/vector/detail/cpu_vector_avx_float_policy.h @@ -17,7 +17,7 @@ #define INCLUDE_VECTOR_DETAIL_CPU_VECTOR_AVX_FLOAT_POLICY_HPP #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { struct CPUVectorPolicyAvxFloat : public CPUVectorPolicyBase {}; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail #endif diff --git a/ccsrc/include/simulator/vector/detail/cpu_vector_policy.h b/ccsrc/include/simulator/vector/detail/cpu_vector_policy.h index a824a605f..4b04bdf58 100644 --- a/ccsrc/include/simulator/vector/detail/cpu_vector_policy.h +++ b/ccsrc/include/simulator/vector/detail/cpu_vector_policy.h @@ -26,13 +26,13 @@ #include #include "config/openmp.h" -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "core/sparse/csrhdmatrix.h" #include "core/utils.h" #include "math/tensor/ops_cpu/utils.h" #include "math/tensor/traits.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { struct CPUVectorPolicyAvxFloat; struct CPUVectorPolicyAvxDouble; @@ -227,5 +227,5 @@ struct CastTo { } } }; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail #endif diff --git a/ccsrc/include/simulator/vector/detail/gpu_vector_double_policy.cuh b/ccsrc/include/simulator/vector/detail/gpu_vector_double_policy.cuh index 48721d620..9edbed116 100644 --- a/ccsrc/include/simulator/vector/detail/gpu_vector_double_policy.cuh +++ b/ccsrc/include/simulator/vector/detail/gpu_vector_double_policy.cuh @@ -17,7 +17,7 @@ #define INCLUDE_VECTOR_DETAIL_GPU_VECTOR_DOUBLE_POLICY_HPP #include "simulator/vector/detail/gpu_vector_policy.cuh" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { struct GPUVectorPolicyDouble : public GPUVectorPolicyBase {}; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail #endif diff --git a/ccsrc/include/simulator/vector/detail/gpu_vector_float_policy.cuh b/ccsrc/include/simulator/vector/detail/gpu_vector_float_policy.cuh index d53fad648..d03b7fe45 100644 --- a/ccsrc/include/simulator/vector/detail/gpu_vector_float_policy.cuh +++ b/ccsrc/include/simulator/vector/detail/gpu_vector_float_policy.cuh @@ -17,7 +17,7 @@ #define INCLUDE_VECTOR_DETAIL_GPU_VECTOR_FLOAT_POLICY_HPP #include "simulator/vector/detail/gpu_vector_policy.cuh" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { struct GPUVectorPolicyFloat : public GPUVectorPolicyBase {}; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail #endif diff --git a/ccsrc/include/simulator/vector/detail/gpu_vector_policy.cuh b/ccsrc/include/simulator/vector/detail/gpu_vector_policy.cuh index f75bfbfa7..5bf58ac01 100644 --- a/ccsrc/include/simulator/vector/detail/gpu_vector_policy.cuh +++ b/ccsrc/include/simulator/vector/detail/gpu_vector_policy.cuh @@ -25,13 +25,13 @@ #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "core/sparse/csrhdmatrix.h" #include "math/tensor/traits.h" #include "thrust/complex.h" #include "thrust/functional.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { struct GPUVectorPolicyFloat; struct GPUVectorPolicyDouble; @@ -153,7 +153,7 @@ struct GPUVectorPolicyBase { static void ApplyRyz(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, calc_type val, index_t dim, bool diff = false); static void ApplyGivens(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, calc_type val, index_t dim, - bool diff = false); + bool diff = false); // gate_expec // ======================================================================================================== static qs_data_t ExpectDiffRPS(const qs_data_p_t& bra, const qs_data_p_t& ket, const PauliMask& pauli_mask, @@ -186,7 +186,7 @@ struct GPUVectorPolicyBase { static qs_data_t ExpectDiffRyz(const qs_data_p_t& bra, const qs_data_p_t& ket, const qbits_t& objs, const qbits_t& ctrls, calc_type val, index_t dim); static qs_data_t ExpectDiffGivens(const qs_data_p_t& bra, const qs_data_p_t& ket, const qbits_t& objs, - const qbits_t& ctrls, calc_type val, index_t dim); + const qbits_t& ctrls, calc_type val, index_t dim); static qs_data_t ExpectDiffSWAPalpha(const qs_data_p_t& bra, const qs_data_p_t& ket, const qbits_t& objs, const qbits_t& ctrls, calc_type val, index_t dim); static qs_data_t ExpectDiffPS(const qs_data_p_t& bra, const qs_data_p_t& ket, const qbits_t& objs, @@ -247,6 +247,6 @@ struct CastTo { return des; } }; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail #endif diff --git a/ccsrc/include/simulator/vector/gradient.h b/ccsrc/include/simulator/vector/gradient.h index 9c60b01ee..66778c187 100644 --- a/ccsrc/include/simulator/vector/gradient.h +++ b/ccsrc/include/simulator/vector/gradient.h @@ -23,11 +23,11 @@ #include #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "math/pr/parameter_resolver.h" #include "math/tensor/matrix.h" -namespace mindquantum { +namespace quafu { /* * ! A example policy. * @@ -298,5 +298,5 @@ class GradientHelper { } } }; -} // namespace mindquantum +} // namespace quafu #endif diff --git a/ccsrc/include/simulator/vector/runtime/cmd.h b/ccsrc/include/simulator/vector/runtime/cmd.h index adcf294f9..57332478e 100644 --- a/ccsrc/include/simulator/vector/runtime/cmd.h +++ b/ccsrc/include/simulator/vector/runtime/cmd.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MQ_SIM_VECTOR_CMD -#define MQ_SIM_VECTOR_CMD +#ifndef QUAFU_SIM_VECTOR_CMD +#define QUAFU_SIM_VECTOR_CMD #include #include #include @@ -29,8 +29,8 @@ #include "simulator/vector/runtime/rt_gate.h" #include "simulator/vector/runtime/utils.h" -namespace mindquantum::sim::rt { +namespace quafu::sim::rt { int cmd(const std::vector& args); int cmd_file(const char* filename); -} // namespace mindquantum::sim::rt +} // namespace quafu::sim::rt #endif diff --git a/ccsrc/include/simulator/vector/runtime/rt_gate.h b/ccsrc/include/simulator/vector/runtime/rt_gate.h index 19012e0a7..b285f86f1 100644 --- a/ccsrc/include/simulator/vector/runtime/rt_gate.h +++ b/ccsrc/include/simulator/vector/runtime/rt_gate.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MQ_SIM_VECTOR_RT_GATE -#define MQ_SIM_VECTOR_RT_GATE +#ifndef QUAFU_SIM_VECTOR_RT_GATE +#define QUAFU_SIM_VECTOR_RT_GATE #include #include #include @@ -24,7 +24,7 @@ #include "ops/basic_gate.h" #include "ops/gate_id.h" -namespace mindquantum::sim::rt { +namespace quafu::sim::rt { struct Gate { GateID gate = GateID::null; qbits_t objs; @@ -129,5 +129,5 @@ struct Gate { } } }; -} // namespace mindquantum::sim::rt +} // namespace quafu::sim::rt #endif diff --git a/ccsrc/include/simulator/vector/runtime/utils.h b/ccsrc/include/simulator/vector/runtime/utils.h index e3637a48b..385789cad 100644 --- a/ccsrc/include/simulator/vector/runtime/utils.h +++ b/ccsrc/include/simulator/vector/runtime/utils.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MQ_SIM_VECTOR_RT -#define MQ_SIM_VECTOR_RT +#ifndef QUAFU_SIM_VECTOR_RT +#define QUAFU_SIM_VECTOR_RT #include #include @@ -22,7 +22,7 @@ #define MAX_QUBIT 64 #define MAX_SEED 65536 -namespace mindquantum::sim::rt { +namespace quafu::sim::rt { enum class State { null, W_GATE, @@ -36,5 +36,5 @@ enum class State { std::tuple convert_int(const std::string &s, int64_t limit, bool raise_error = true); std::tuple convert_double(const std::string &s, bool raise_error = true); -} // namespace mindquantum::sim::rt +} // namespace quafu::sim::rt #endif diff --git a/ccsrc/include/simulator/vector/vector_state.h b/ccsrc/include/simulator/vector/vector_state.h index 4be9dbad0..264190130 100644 --- a/ccsrc/include/simulator/vector/vector_state.h +++ b/ccsrc/include/simulator/vector/vector_state.h @@ -36,7 +36,7 @@ #include #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "math/pr/parameter_resolver.h" #include "math/tensor/traits.h" #include "ops/basic_gate.h" @@ -45,7 +45,7 @@ #include "simulator/timer.h" #include "simulator/utils.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template struct BLAS; template @@ -271,7 +271,7 @@ struct VectorStateAdjoint { return psi_l->ExpectDiffGate(psi_l->qs, psi_r->qs, g, pr, psi_l->dim); } }; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail #include "simulator/vector/vector_state.tpp" // NOLINT diff --git a/ccsrc/include/simulator/vector/vector_state.tpp b/ccsrc/include/simulator/vector/vector_state.tpp index 563d16dd8..5a3458f7d 100644 --- a/ccsrc/include/simulator/vector/vector_state.tpp +++ b/ccsrc/include/simulator/vector/vector_state.tpp @@ -37,7 +37,7 @@ #include #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "core/utils.h" #include "math/pr/parameter_resolver.h" #include "math/tensor/matrix.h" @@ -51,7 +51,7 @@ #include "simulator/vector/gradient.h" #include "simulator/vector/vector_state.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void VectorState::SetSeed(unsigned new_seed) { this->seed = new_seed; @@ -1384,18 +1384,18 @@ auto VectorState::ExpectDiffCustomTwoParam(const qs_data_p_t& bra, if (param1.data_.size() != param1.no_grad_parameters_.size()) { m = custom_gate->GetDiffMatrix1Wrapper()(param1_const, param2_const); grad[0] = qs_policy_t::ExpectDiffMatrixGate(bra, ket, custom_gate->GetObjQubits(), - custom_gate->GetCtrlQubits(), - tensor::ops::cpu::to_vector(m), dim); + custom_gate->GetCtrlQubits(), + tensor::ops::cpu::to_vector(m), dim); } if (param2.data_.size() != param2.no_grad_parameters_.size()) { m = custom_gate->GetDiffMatrix2Wrapper()(param1_const, param2_const); grad[1] = qs_policy_t::ExpectDiffMatrixGate(bra, ket, custom_gate->GetObjQubits(), - custom_gate->GetCtrlQubits(), - tensor::ops::cpu::to_vector(m), dim); + custom_gate->GetCtrlQubits(), + tensor::ops::cpu::to_vector(m), dim); } } return tensor::Matrix(VVT{grad}); } -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail #endif diff --git a/ccsrc/lib/CMakeLists.txt b/ccsrc/lib/CMakeLists.txt index bbbdf89bd..ef47da0d9 100644 --- a/ccsrc/lib/CMakeLists.txt +++ b/ccsrc/lib/CMakeLists.txt @@ -17,7 +17,7 @@ # ============================================================================== add_subdirectory(algorithm) -add_subdirectory(mq_base) +add_subdirectory(quafu_base) add_subdirectory(simulator) add_subdirectory(device) add_subdirectory(math) diff --git a/ccsrc/lib/algorithm/CMakeLists.txt b/ccsrc/lib/algorithm/CMakeLists.txt index 3353242ce..843e7c791 100644 --- a/ccsrc/lib/algorithm/CMakeLists.txt +++ b/ccsrc/lib/algorithm/CMakeLists.txt @@ -18,9 +18,9 @@ if(ENABLE_CUDA) add_library(qaia_sb_gpu STATIC) - target_link_libraries(qaia_sb_gpu PUBLIC CUDA_mindquantum mq_math cublas) + target_link_libraries(qaia_sb_gpu PUBLIC CUDA_quafu quafu_math cublas) set_target_properties(qaia_sb_gpu PROPERTIES CUDA_RUNTIME_LIBRARY $,Static,Shared>) force_at_least_cxx17_workaround(qaia_sb_gpu) - append_to_property(mq_install_targets GLOBAL qaia_sb_gpu) + append_to_property(quafu_install_targets GLOBAL qaia_sb_gpu) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/qaia/detail) endif() diff --git a/ccsrc/lib/algorithm/qaia/detail/gpu_sb_update.cu b/ccsrc/lib/algorithm/qaia/detail/gpu_sb_update.cu index 11a746715..39f803408 100644 --- a/ccsrc/lib/algorithm/qaia/detail/gpu_sb_update.cu +++ b/ccsrc/lib/algorithm/qaia/detail/gpu_sb_update.cu @@ -31,11 +31,11 @@ #include "algorithm/qaia/detail/para.h" #include "algorithm/qaia/detail/tools.cuh" -using mindquantum::Index; +using quafu::Index; -namespace mindquantum::algorithm::qaia::detail { +namespace quafu::algorithm::qaia::detail { -void SBBase::dSB_update_int8(mindquantum::sparse::CsrBase csr, double* x, Para paras) { +void SBBase::dSB_update_int8(quafu::sparse::CsrBase csr, double* x, Para paras) { Index* indptr = csr.indptr_; Index* indices = csr.indices_; double* data = csr.data_; @@ -100,7 +100,7 @@ void SBBase::dSB_update_int8(mindquantum::sparse::CsrBase csr, double* x HANDLE_ERROR(cudaFree(signx)); } -void SBBase::bSB_update_int8(mindquantum::sparse::CsrBase csr, double* x, Para paras) { +void SBBase::bSB_update_int8(quafu::sparse::CsrBase csr, double* x, Para paras) { Index* indptr = csr.indptr_; Index* indices = csr.indices_; double* data = csr.data_; @@ -160,7 +160,7 @@ void SBBase::bSB_update_int8(mindquantum::sparse::CsrBase csr, double* x HANDLE_ERROR(cudaFree(tmp)); } -void SBBase::bSB_update_fp16(mindquantum::sparse::CsrBase csr, double* x, Para paras) { +void SBBase::bSB_update_fp16(quafu::sparse::CsrBase csr, double* x, Para paras) { Index* indptr = csr.indptr_; Index* indices = csr.indices_; double* data = csr.data_; @@ -223,7 +223,7 @@ void SBBase::bSB_update_fp16(mindquantum::sparse::CsrBase csr, double* x HANDLE_ERROR(cudaFree(tmp)); } -void SBBase::dSB_update_fp16(mindquantum::sparse::CsrBase csr, double* x, Para paras) { +void SBBase::dSB_update_fp16(quafu::sparse::CsrBase csr, double* x, Para paras) { Index* indptr = csr.indptr_; Index* indices = csr.indices_; double* data = csr.data_; @@ -288,7 +288,7 @@ void SBBase::dSB_update_fp16(mindquantum::sparse::CsrBase csr, double* x HANDLE_ERROR(cudaFree(signx)); } -void SBBase::dSB_update_h_int8(mindquantum::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size) { +void SBBase::dSB_update_h_int8(quafu::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size) { Index* indptr = csr.indptr_; Index* indices = csr.indices_; double* data = csr.data_; @@ -366,7 +366,7 @@ void SBBase::dSB_update_h_int8(mindquantum::sparse::CsrBase csr, double* HANDLE_ERROR(cudaFree(signx)); } -void SBBase::bSB_update_h_int8(mindquantum::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size) { +void SBBase::bSB_update_h_int8(quafu::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size) { Index* indptr = csr.indptr_; Index* indices = csr.indices_; double* data = csr.data_; @@ -441,7 +441,7 @@ void SBBase::bSB_update_h_int8(mindquantum::sparse::CsrBase csr, double* HANDLE_ERROR(cudaFree(tmp)); } -void SBBase::bSB_update_h_fp16(mindquantum::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size) { +void SBBase::bSB_update_h_fp16(quafu::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size) { Index* indptr = csr.indptr_; Index* indices = csr.indices_; double* data = csr.data_; @@ -518,7 +518,7 @@ void SBBase::bSB_update_h_fp16(mindquantum::sparse::CsrBase csr, double* HANDLE_ERROR(cudaFree(tmp)); } -void SBBase::dSB_update_h_fp16(mindquantum::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size) { +void SBBase::dSB_update_h_fp16(quafu::sparse::CsrBase csr, double* x, Para paras, double* h, int h_size) { Index* indptr = csr.indptr_; Index* indices = csr.indices_; double* data = csr.data_; @@ -617,4 +617,4 @@ void SBBase::cublas_warmup(int N, int B) { HANDLE_ERROR(cudaFree(tmp)); } -} // namespace mindquantum::algorithm::qaia::detail +} // namespace quafu::algorithm::qaia::detail diff --git a/ccsrc/lib/device/CMakeLists.txt b/ccsrc/lib/device/CMakeLists.txt index 39d3317f5..00995f810 100644 --- a/ccsrc/lib/device/CMakeLists.txt +++ b/ccsrc/lib/device/CMakeLists.txt @@ -18,6 +18,6 @@ # lint_cmake: -whitespace/indent -target_sources(mq_base PRIVATE ${CMAKE_CURRENT_LIST_DIR}/topology.cpp ${CMAKE_CURRENT_LIST_DIR}/mapping.cpp) +target_sources(quafu_base PRIVATE ${CMAKE_CURRENT_LIST_DIR}/topology.cpp ${CMAKE_CURRENT_LIST_DIR}/mapping.cpp) # ============================================================================== diff --git a/ccsrc/lib/device/mapping.cpp b/ccsrc/lib/device/mapping.cpp index a389923ce..1e27aed66 100644 --- a/ccsrc/lib/device/mapping.cpp +++ b/ccsrc/lib/device/mapping.cpp @@ -25,12 +25,12 @@ #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "device/topology.h" #include "ops/basic_gate.h" #include "ops/gate_id.h" -namespace mindquantum::mapping { +namespace quafu::mapping { // ----------------------------------------------------------------------------- VT> GetCircuitDAG(int n, const VT& gates) { int m = gates.size(); @@ -88,7 +88,7 @@ std::pair> GateToAbstractGate(const VT>& graph) { +int QUAFU_SABRE::CalGraphCenter(const VT>& graph) { int n = graph.size(); int center_qubit = 0; int tempmin = INT16_MAX; @@ -105,7 +105,7 @@ int MQ_SABRE::CalGraphCenter(const VT>& graph) { return center_qubit; } -VT MQ_SABRE::InitialMapping(const std::shared_ptr& coupling_graph) { +VT QUAFU_SABRE::InitialMapping(const std::shared_ptr& coupling_graph) { VT layout(this->num_physical, -1); VT Rlayout(this->num_physical, -1); int Qc = CalGraphCenter(this->D); @@ -217,7 +217,7 @@ VT MQ_SABRE::InitialMapping(const std::shared_ptr& coupling return layout; } -std::list MQ_SABRE::GetNextLayer(const std::list& F, const VT>& DAG, VT& indeg) { +std::list QUAFU_SABRE::GetNextLayer(const std::list& F, const VT>& DAG, VT& indeg) { std::list ret; for (int x : F) { for (int y : DAG[x]) { @@ -236,7 +236,7 @@ std::list MQ_SABRE::GetNextLayer(const std::list& F, const VT> } return ret; } -std::list MQ_SABRE::GetFLayer(std::list>& E) { +std::list QUAFU_SABRE::GetFLayer(std::list>& E) { std::list res; if (E.size() > 0) { int flag = E.front().second; @@ -248,7 +248,7 @@ std::list MQ_SABRE::GetFLayer(std::list>& E) { return res; } -bool MQ_SABRE::IsExecutable(const VT& pi, int g) const { +bool QUAFU_SABRE::IsExecutable(const VT& pi, int g) const { if (gates[g].type == "CNOT") { int p = pi[gates[g].q1], q = pi[gates[g].q2]; return std::any_of(G[p].begin(), G[p].end(), [&](int a) { return a == q; }); @@ -257,7 +257,7 @@ bool MQ_SABRE::IsExecutable(const VT& pi, int g) const { } } -std::set> MQ_SABRE::ObtainSWAPs(const std::list& F, const VT& pi) const { +std::set> QUAFU_SABRE::ObtainSWAPs(const std::list& F, const VT& pi) const { std::set> ret; for (int g : F) { int x = pi[gates[g].q1]; @@ -272,7 +272,7 @@ std::set> MQ_SABRE::ObtainSWAPs(const std::list& F, con return ret; } -double MQ_SABRE::HBasic(const std::list& F, const VT& pi) const { +double QUAFU_SABRE::HBasic(const std::list& F, const VT& pi) const { double sum = 0; for (int g : F) { int q1 = gates[g].q1; @@ -282,8 +282,8 @@ double MQ_SABRE::HBasic(const std::list& F, const VT& pi) const { return sum; } -std::pair MQ_SABRE::HExtended(const std::list>& E, const VT& tmppi, - const VT& pi) const { +std::pair QUAFU_SABRE::HExtended(const std::list>& E, const VT& tmppi, + const VT& pi) const { double sum = 0; double effectcost = 0; for (auto g : E) { @@ -295,7 +295,7 @@ std::pair MQ_SABRE::HExtended(const std::list({sum, effectcost}); } -VT MQ_SABRE::GetReversePi(const VT& pi) const { +VT QUAFU_SABRE::GetReversePi(const VT& pi) const { VT rpi(pi.size(), -1); for (int i = 0; i < static_cast(pi.size()); ++i) { if (pi[i] != -1) @@ -304,7 +304,7 @@ VT MQ_SABRE::GetReversePi(const VT& pi) const { return rpi; } -VT MQ_SABRE::HeuristicSearch(VT& pi, const VT>& DAG) { +VT QUAFU_SABRE::HeuristicSearch(VT& pi, const VT>& DAG) { VT ans; int tot = 0; auto rpi = GetReversePi(pi); // mapping from physical to logical @@ -442,8 +442,9 @@ VT MQ_SABRE::HeuristicSearch(VT& pi, const VT>& DAG) { return ans; } -MQ_SABRE::MQ_SABRE(const VT>& circ, const std::shared_ptr& coupling_graph, - const std::vector, VT>>& CnotErrrorRateAndGateLength) { +QUAFU_SABRE::QUAFU_SABRE(const VT>& circ, + const std::shared_ptr& coupling_graph, + const std::vector, VT>>& CnotErrrorRateAndGateLength) { auto tmp = GateToAbstractGate(circ); this->num_logical = tmp.first; this->gates = tmp.second; @@ -560,8 +561,8 @@ MQ_SABRE::MQ_SABRE(const VT>& circ, const std::shared // return; } -std::pair>, std::pair, VT>> MQ_SABRE::Solve(double W, double alpha1, double alpha2, - double alpha3) { +std::pair>, std::pair, VT>> QUAFU_SABRE::Solve(double W, double alpha1, double alpha2, + double alpha3) { this->SetParameters(W, alpha1, alpha2, alpha3); // set parameters this->DM = VT>(num_physical, VT(num_physical, 0.0)); for (int i = 0; i < num_physical; i++) { @@ -584,7 +585,7 @@ std::pair>, std::pair, VT>> MQ_SABRE::Solve(double W, do return {gate_info, {initial_mapping, this->layout}}; } -inline void MQ_SABRE::SetParameters(double W, double alpha1, double alpha2, double alpha3) { +inline void QUAFU_SABRE::SetParameters(double W, double alpha1, double alpha2, double alpha3) { this->W = W; this->alpha1 = alpha1; this->alpha2 = alpha2; @@ -831,4 +832,4 @@ inline void SABRE::SetParameters(double W, double delta1, double delta2) { this->delta1 = delta1; this->delta2 = delta2; } -} // namespace mindquantum::mapping +} // namespace quafu::mapping diff --git a/ccsrc/lib/device/topology.cpp b/ccsrc/lib/device/topology.cpp index de69946c4..d5b60c23f 100644 --- a/ccsrc/lib/device/topology.cpp +++ b/ccsrc/lib/device/topology.cpp @@ -20,7 +20,7 @@ #include #include -namespace mindquantum::mapping { +namespace quafu::mapping { // ============================================================================= QubitNode::QubitNode(qbit_t id, std::string color, double poi_x, double poi_y, const std::set& neighbour) @@ -260,4 +260,4 @@ int GridQubits::NRow() { int GridQubits::NCol() { return this->n_col; } -} // namespace mindquantum::mapping +} // namespace quafu::mapping diff --git a/ccsrc/lib/math/CMakeLists.txt b/ccsrc/lib/math/CMakeLists.txt index 0eb1c0520..0ef1dd273 100644 --- a/ccsrc/lib/math/CMakeLists.txt +++ b/ccsrc/lib/math/CMakeLists.txt @@ -16,10 +16,10 @@ # # ============================================================================== -add_library(mq_math) -force_at_least_cxx17_workaround(mq_math) -append_to_property(mq_install_targets GLOBAL mq_math) -target_link_libraries(mq_math PUBLIC ${MQ_OPENMP_TARGET} include_lib cmake_config cxx20_compat mq_base) +add_library(quafu_math) +force_at_least_cxx17_workaround(quafu_math) +append_to_property(quafu_install_targets GLOBAL quafu_math) +target_link_libraries(quafu_math PUBLIC ${QUAFU_OPENMP_TARGET} include_lib cmake_config cxx20_compat quafu_base) # ============================================================================== diff --git a/ccsrc/lib/math/longbits/CMakeLists.txt b/ccsrc/lib/math/longbits/CMakeLists.txt index f9cd08f3f..da8a61041 100644 --- a/ccsrc/lib/math/longbits/CMakeLists.txt +++ b/ccsrc/lib/math/longbits/CMakeLists.txt @@ -17,4 +17,4 @@ # ============================================================================== # lint_cmake: -whitespace/indent -target_sources(mq_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/longbits.cpp) +target_sources(quafu_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/longbits.cpp) diff --git a/ccsrc/lib/math/longbits/longbits.cpp b/ccsrc/lib/math/longbits/longbits.cpp index 0fc829f6c..7656d09ae 100644 --- a/ccsrc/lib/math/longbits/longbits.cpp +++ b/ccsrc/lib/math/longbits/longbits.cpp @@ -21,7 +21,7 @@ #include -namespace mindquantum { +namespace quafu { #define REG_OPERATOR(op_eq, op) \ void LongBits::operator op_eq(const LongBits& other) { \ if (other.n_bits != this->n_bits) { \ @@ -120,4 +120,4 @@ bool LongBits::Any(size_t start) { return Any(start, n_bits); } #undef REG_OPERATOR -} // namespace mindquantum +} // namespace quafu diff --git a/ccsrc/lib/math/operators/CMakeLists.txt b/ccsrc/lib/math/operators/CMakeLists.txt index 373401cc5..f8de69b09 100644 --- a/ccsrc/lib/math/operators/CMakeLists.txt +++ b/ccsrc/lib/math/operators/CMakeLists.txt @@ -18,7 +18,7 @@ # lint_cmake: -whitespace/indent target_sources( - mq_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qubit_operator_view.cpp ${CMAKE_CURRENT_LIST_DIR}/fermion_operator_view.cpp + quafu_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qubit_operator_view.cpp ${CMAKE_CURRENT_LIST_DIR}/fermion_operator_view.cpp ${CMAKE_CURRENT_LIST_DIR}/utils.cpp ${CMAKE_CURRENT_LIST_DIR}/sparsing.cpp) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/transform) diff --git a/ccsrc/lib/math/operators/fermion_operator_view.cpp b/ccsrc/lib/math/operators/fermion_operator_view.cpp index 99d787311..4b9ebf7b5 100644 --- a/ccsrc/lib/math/operators/fermion_operator_view.cpp +++ b/ccsrc/lib/math/operators/fermion_operator_view.cpp @@ -116,7 +116,7 @@ auto SingleFermionStr::init(const terms_t& terms, const parameter::ParameterReso std::vector SingleFermionStr::NumOneMask(const compress_term_t& fermion) { std::vector out(fermion.first.size()); std::transform(fermion.first.begin(), fermion.first.end(), out.begin(), - [&](auto& i) { return mindquantum::CountOne(i) & 1; }); + [&](auto& i) { return quafu::CountOne(i) & 1; }); return out; } @@ -124,7 +124,7 @@ uint64_t SingleFermionStr::PrevOneMask(const std::vector& one_mask, si uint64_t out = 0; for (size_t i = 0; i < idx; i++) { if (i < one_mask.size()) { - out += mindquantum::CountOne(one_mask[i]); + out += quafu::CountOne(one_mask[i]); } } return out & 1; @@ -176,7 +176,7 @@ bool SingleFermionStr::InplaceMulCompressTerm(const term_t& term, compress_term_ size_t local_mask = (static_cast(1) << local_id) | (static_cast(1) << (local_id + 1)) | (static_cast(1) << (local_id + 2)); auto one_mask_vec = NumOneMask(fermion); - auto one_mask_of_word = mindquantum::CountOne(static_cast(word)); + auto one_mask_of_word = quafu::CountOne(static_cast(word)); auto one_mask = PrevOneMask(one_mask_vec, group_id) & one_mask_of_word; if (ori_term.size() < group_id + 1) { for (size_t i = ori_term.size(); i < group_id + 1; i++) { @@ -194,8 +194,8 @@ bool SingleFermionStr::InplaceMulCompressTerm(const term_t& term, compress_term_ } ori_term[group_id] = (ori_term[group_id] & (~local_mask)) | (static_cast(res)) << local_id; one_mask = (one_mask - + (mindquantum::CountOne(static_cast(word)) - & mindquantum::CountOne(ori_term[group_id] & low_mask))) + + (quafu::CountOne(static_cast(word)) + & quafu::CountOne(ori_term[group_id] & low_mask))) & 1; } if (one_mask & 1) { @@ -293,13 +293,13 @@ auto SingleFermionStr::Mul(const compress_term_t& lhs, const compress_term_t& rh int total_one = 0; for (std::size_t i = 0; i < max_size; i++) { if (i < min_size) { - total_one += one_in_low & mindquantum::CountOne(r_k[i]); - one_in_low += mindquantum::CountOne(l_k[i]); + total_one += one_in_low & quafu::CountOne(r_k[i]); + one_in_low += quafu::CountOne(l_k[i]); auto [t, s] = MulSingleCompressTerm(l_k[i], r_k[i]); coeff = coeff * t; fermion_string.push_back(s); } else if (i >= l_k.size()) { - total_one += one_in_low & mindquantum::CountOne(r_k[i]); + total_one += one_in_low & quafu::CountOne(r_k[i]); fermion_string.push_back(r_k[i]); } else { fermion_string.push_back(l_k[i]); @@ -324,9 +324,9 @@ std::tuple SingleFermionStr::MulSingleCompressTerm(uint64_ auto lhs = static_cast(a & 7); auto rhs = static_cast(b & 7); if (rhs != TermValue::I) { - total_one += one_in_low & mindquantum::CountOne(b & 7); + total_one += one_in_low & quafu::CountOne(b & 7); } - one_in_low += mindquantum::CountOne(a & 7); + one_in_low += quafu::CountOne(a & 7); auto res = fermion_product_map.at(lhs).at(rhs); if (res == TermValue::nll) { return {tn::ops::ones(1), static_cast(TermValue::nll)}; @@ -669,7 +669,7 @@ size_t FermionOperator::count_qubits() const { for (auto word = k.rbegin(); word != k.rend(); ++word) { if ((*word) != 0) { n_qubits = std::max(n_qubits, - static_cast((63 - mindquantum::CountLeadingZero(*word)) / 3 + group_id * 21)); + static_cast((63 - quafu::CountLeadingZero(*word)) / 3 + group_id * 21)); break; } group_id -= 1; diff --git a/ccsrc/lib/math/operators/qubit_operator_view.cpp b/ccsrc/lib/math/operators/qubit_operator_view.cpp index 14c256b3b..5d4976e67 100644 --- a/ccsrc/lib/math/operators/qubit_operator_view.cpp +++ b/ccsrc/lib/math/operators/qubit_operator_view.cpp @@ -201,9 +201,9 @@ std::tuple SinglePauliStr::MulSingleCompressTerm(uint64_t auto idx_1 = (~(a >> 1) & a & (b >> 1) & b) | ((a >> 1) & ~a & ~(b >> 1) & b) | ((a >> 1) & a & (b >> 1) & ~b); idx_0 = idx_0 & M_B; idx_1 = idx_1 & M_B; - auto num_I = mindquantum::CountOne(~idx_1 & idx_0); - auto num_M_ONE = mindquantum::CountOne(idx_1 & ~idx_0); - auto num_M_I = mindquantum::CountOne(idx_1 & idx_0); + auto num_I = quafu::CountOne(~idx_1 & idx_0); + auto num_M_ONE = quafu::CountOne(idx_1 & ~idx_0); + auto num_M_I = quafu::CountOne(idx_1 & idx_0); auto out = (num_I + 2 * num_M_ONE + 3 * num_M_I) & 3; switch (out) { case (0): @@ -338,7 +338,7 @@ size_t QubitOperator::count_qubits() const { for (auto word = k.rbegin(); word != k.rend(); ++word) { if ((*word) != 0) { n_qubits = std::max(n_qubits, - static_cast((63 - mindquantum::CountLeadingZero(*word)) / 2 + group_id * 32)); + static_cast((63 - quafu::CountLeadingZero(*word)) / 2 + group_id * 32)); break; } group_id -= 1; diff --git a/ccsrc/lib/math/operators/sparsing.cpp b/ccsrc/lib/math/operators/sparsing.cpp index f551688ea..b070fabbe 100644 --- a/ccsrc/lib/math/operators/sparsing.cpp +++ b/ccsrc/lib/math/operators/sparsing.cpp @@ -20,7 +20,7 @@ #include #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "fmt/format.h" #include "math/operators/qubit_operator_view.h" #include "math/tensor/csr_matrix.h" @@ -29,10 +29,10 @@ #include "math/tensor/traits.h" namespace operators { -namespace mq = mindquantum; +namespace quafu = quafu; template struct EleComp { - using ele_t = std::pair; + using ele_t = std::pair; bool operator()(const ele_t& lhs, const ele_t& rhs) const { return lhs.first < rhs.first; } @@ -47,7 +47,7 @@ tn::CsrMatrix GetMatrixImp(const qubit::QubitOperator& ops, int n_qubits) { throw std::invalid_argument(fmt::format("Data type mismatch for sparsing operator.")); } using calc_type = tn::to_device_t; - mq::VT polar = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}}; + quafu::VT polar = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}}; auto n_local_qubits = ops.count_qubits(); if (n_qubits < 0) { @@ -57,35 +57,35 @@ tn::CsrMatrix GetMatrixImp(const qubit::QubitOperator& ops, int n_qubits) { fmt::format("n_qubits ({}) is less than local qubit number ({}).", n_qubits, n_local_qubits)); } - mq::VT pauli_mask; - mq::VT consts; + quafu::VT pauli_mask; + quafu::VT consts; for (auto [term, pr] : ops.get_terms()) { consts.push_back(tn::ops::cpu::to_vector(pr.const_value)[0]); - mq::VT out = {0, 0, 0, 0, 0, 0}; + quafu::VT out = {0, 0, 0, 0, 0, 0}; for (auto& [idx, w] : term) { - for (mq::index_t i = 0; i < 3; i++) { - if (static_cast(w) - 1 == i) { + for (quafu::index_t i = 0; i < 3; i++) { + if (static_cast(w) - 1 == i) { out[i] += (static_cast(1) << idx); out[3 + i] += 1; break; } } } - pauli_mask.push_back(mq::PauliMask({out[0], out[1], out[2], out[3], out[4], out[5]})); + pauli_mask.push_back(quafu::PauliMask({out[0], out[1], out[2], out[3], out[4], out[5]})); } auto dim = static_cast(1) << n_qubits; - mq::VT> all_value(dim); - mq::index_t nnz = 0; + quafu::VT> all_value(dim); + quafu::index_t nnz = 0; #pragma omp parallel for schedule(static) reduction(+ : nnz) - for (mq::index_t i = 0; i < dim; i++) { + for (quafu::index_t i = 0; i < dim; i++) { ele_set vals; - for (mq::index_t term_idx = 0; term_idx < ops.size(); term_idx++) { + for (quafu::index_t term_idx = 0; term_idx < ops.size(); term_idx++) { auto& mask = pauli_mask[term_idx]; auto mask_f = mask.mask_x | mask.mask_y; auto j = (i ^ mask_f); - auto axis2power = mq::CountOne(static_cast(i & mask.mask_z)); // -1 - auto axis3power = mq::CountOne(static_cast(i & mask.mask_y)); // -1j + auto axis2power = quafu::CountOne(static_cast(i & mask.mask_z)); // -1 + auto axis3power = quafu::CountOne(static_cast(i & mask.mask_y)); // -1j auto val = polar[(mask.num_y + 2 * axis3power + 2 * axis2power) & 3] * consts[term_idx]; typename EleComp::ele_t ele_new = {j, val}; auto prev = vals.find(ele_new); @@ -101,16 +101,16 @@ tn::CsrMatrix GetMatrixImp(const qubit::QubitOperator& ops, int n_qubits) { nnz += vals.size(); all_value[i] = vals; } - auto indptr = reinterpret_cast(malloc(sizeof(mq::index_t) * (dim + 1))); - auto indices = reinterpret_cast(malloc(sizeof(mq::index_t) * nnz)); + auto indptr = reinterpret_cast(malloc(sizeof(quafu::index_t) * (dim + 1))); + auto indices = reinterpret_cast(malloc(sizeof(quafu::index_t) * nnz)); auto data = reinterpret_cast(malloc(sizeof(calc_type) * nnz)); indptr[0] = 0; - for (mq::index_t i = 0; i < all_value.size(); i++) { + for (quafu::index_t i = 0; i < all_value.size(); i++) { auto& vals = all_value[i]; indptr[i + 1] = indptr[i] + vals.size(); } #pragma omp parallel for schedule(static) - for (mq::index_t i = 0; i < all_value.size(); i++) { + for (quafu::index_t i = 0; i < all_value.size(); i++) { auto& vals = all_value[i]; auto begin = indptr[i]; for (auto& [idx, val] : vals) { diff --git a/ccsrc/lib/math/operators/transform/CMakeLists.txt b/ccsrc/lib/math/operators/transform/CMakeLists.txt index c852680d2..67c794c93 100644 --- a/ccsrc/lib/math/operators/transform/CMakeLists.txt +++ b/ccsrc/lib/math/operators/transform/CMakeLists.txt @@ -17,7 +17,7 @@ # ============================================================================== target_sources( - mq_math + quafu_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/fermion_number_operator.cpp ${CMAKE_CURRENT_LIST_DIR}/jordan_wigner.cpp ${CMAKE_CURRENT_LIST_DIR}/transform_ladder_operator.cpp diff --git a/ccsrc/lib/math/pr/CMakeLists.txt b/ccsrc/lib/math/pr/CMakeLists.txt index 4b5808cc1..86ecd96a5 100644 --- a/ccsrc/lib/math/pr/CMakeLists.txt +++ b/ccsrc/lib/math/pr/CMakeLists.txt @@ -16,4 +16,4 @@ # # ============================================================================== -target_sources(mq_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/parameter_resolver.cpp) +target_sources(quafu_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/parameter_resolver.cpp) diff --git a/ccsrc/lib/math/tensor/CMakeLists.txt b/ccsrc/lib/math/tensor/CMakeLists.txt index 63e506248..75f7446ed 100644 --- a/ccsrc/lib/math/tensor/CMakeLists.txt +++ b/ccsrc/lib/math/tensor/CMakeLists.txt @@ -17,11 +17,11 @@ # ============================================================================== # lint_cmake: -whitespace/indent -target_sources(mq_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/traits.cpp ${CMAKE_CURRENT_LIST_DIR}/tensor.cpp +target_sources(quafu_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/traits.cpp ${CMAKE_CURRENT_LIST_DIR}/tensor.cpp ${CMAKE_CURRENT_LIST_DIR}/csr_matrix.cpp) -# target_compile_options(mq_math PUBLIC "-Wno-return-type") target_compile_options(mq_math PUBLIC "-Wno-narrowing") -# target_compile_options(mq_math PUBLIC "-Wno-pointer-arith") +# target_compile_options(quafu_math PUBLIC "-Wno-return-type") target_compile_options(quafu_math PUBLIC "-Wno-narrowing") +# target_compile_options(quafu_math PUBLIC "-Wno-pointer-arith") add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ops) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ops_cpu) diff --git a/ccsrc/lib/math/tensor/csr_matrix.cpp b/ccsrc/lib/math/tensor/csr_matrix.cpp index e04d372ca..538fa1e93 100644 --- a/ccsrc/lib/math/tensor/csr_matrix.cpp +++ b/ccsrc/lib/math/tensor/csr_matrix.cpp @@ -54,8 +54,8 @@ CsrMatrix::CsrMatrix(const CsrMatrix& t) { this->nnz = t.nnz; this->indices_ = reinterpret_cast(malloc(sizeof(size_t) * nnz)); this->indptr_ = reinterpret_cast(malloc(sizeof(size_t) * (n_row + 1))); - mindquantum::safe_copy(this->indices_, sizeof(size_t) * nnz, t.indices_, sizeof(size_t) * nnz); - mindquantum::safe_copy(this->indptr_, sizeof(size_t) * (n_row + 1), t.indptr_, sizeof(size_t) * (n_row + 1)); + quafu::safe_copy(this->indices_, sizeof(size_t) * nnz, t.indices_, sizeof(size_t) * nnz); + quafu::safe_copy(this->indptr_, sizeof(size_t) * (n_row + 1), t.indptr_, sizeof(size_t) * (n_row + 1)); this->data_ = t.data_; } CsrMatrix& CsrMatrix::operator=(const CsrMatrix& t) { @@ -70,8 +70,8 @@ CsrMatrix& CsrMatrix::operator=(const CsrMatrix& t) { } this->indices_ = reinterpret_cast(malloc(sizeof(size_t) * nnz)); this->indptr_ = reinterpret_cast(malloc(sizeof(size_t) * (n_row + 1))); - mindquantum::safe_copy(this->indices_, sizeof(size_t) * nnz, t.indices_, sizeof(size_t) * nnz); - mindquantum::safe_copy(this->indptr_, sizeof(size_t) * (n_row + 1), t.indptr_, sizeof(size_t) * (n_row + 1)); + quafu::safe_copy(this->indices_, sizeof(size_t) * nnz, t.indices_, sizeof(size_t) * nnz); + quafu::safe_copy(this->indptr_, sizeof(size_t) * (n_row + 1), t.indptr_, sizeof(size_t) * (n_row + 1)); this->data_ = t.data_; return *this; } diff --git a/ccsrc/lib/math/tensor/ops/CMakeLists.txt b/ccsrc/lib/math/tensor/ops/CMakeLists.txt index 43beb1924..4b72641c6 100644 --- a/ccsrc/lib/math/tensor/ops/CMakeLists.txt +++ b/ccsrc/lib/math/tensor/ops/CMakeLists.txt @@ -17,5 +17,5 @@ # ============================================================================== target_sources( - mq_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/memory_operator.cpp ${CMAKE_CURRENT_LIST_DIR}/concrete_tensor.cpp + quafu_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/memory_operator.cpp ${CMAKE_CURRENT_LIST_DIR}/concrete_tensor.cpp ${CMAKE_CURRENT_LIST_DIR}/basic_math.cpp ${CMAKE_CURRENT_LIST_DIR}/advance_math.cpp) diff --git a/ccsrc/lib/math/tensor/ops_cpu/CMakeLists.txt b/ccsrc/lib/math/tensor/ops_cpu/CMakeLists.txt index 43beb1924..4b72641c6 100644 --- a/ccsrc/lib/math/tensor/ops_cpu/CMakeLists.txt +++ b/ccsrc/lib/math/tensor/ops_cpu/CMakeLists.txt @@ -17,5 +17,5 @@ # ============================================================================== target_sources( - mq_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/memory_operator.cpp ${CMAKE_CURRENT_LIST_DIR}/concrete_tensor.cpp + quafu_math PRIVATE ${CMAKE_CURRENT_LIST_DIR}/memory_operator.cpp ${CMAKE_CURRENT_LIST_DIR}/concrete_tensor.cpp ${CMAKE_CURRENT_LIST_DIR}/basic_math.cpp ${CMAKE_CURRENT_LIST_DIR}/advance_math.cpp) diff --git a/ccsrc/lib/math/tensor/ops_cpu/advance_math.cpp b/ccsrc/lib/math/tensor/ops_cpu/advance_math.cpp index cd518a42b..ab466b458 100644 --- a/ccsrc/lib/math/tensor/ops_cpu/advance_math.cpp +++ b/ccsrc/lib/math/tensor/ops_cpu/advance_math.cpp @@ -181,7 +181,7 @@ Tensor Gather(const std::vector& tensors) { auto out = init(tot_len, dtype); size_t idx = 0; for (auto& t : tensors) { - mindquantum::safe_copy(reinterpret_cast(out.data) + idx, bit_size(t.dtype) * t.dim, t.data, + quafu::safe_copy(reinterpret_cast(out.data) + idx, bit_size(t.dtype) * t.dim, t.data, bit_size(t.dtype) * t.dim); idx += bit_size(t.dtype) * t.dim; } diff --git a/ccsrc/lib/math/tensor/ops_cpu/memory_operator.cpp b/ccsrc/lib/math/tensor/ops_cpu/memory_operator.cpp index d3254a4ae..95196f7f2 100644 --- a/ccsrc/lib/math/tensor/ops_cpu/memory_operator.cpp +++ b/ccsrc/lib/math/tensor/ops_cpu/memory_operator.cpp @@ -178,7 +178,7 @@ Tensor get(const Tensor& t, size_t idx) { throw std::runtime_error("index out of range for get."); } auto out = cpu::init(1, t.dtype); - mindquantum::safe_copy(out.data, bit_size(t.dtype), reinterpret_cast(t.data) + idx * bit_size(t.dtype), + quafu::safe_copy(out.data, bit_size(t.dtype), reinterpret_cast(t.data) + idx * bit_size(t.dtype), bit_size(t.dtype)); return out; } diff --git a/ccsrc/lib/mq_base/CMakeLists.txt b/ccsrc/lib/quafu_base/CMakeLists.txt similarity index 84% rename from ccsrc/lib/mq_base/CMakeLists.txt rename to ccsrc/lib/quafu_base/CMakeLists.txt index 37b7c0d9c..9b7ba9029 100644 --- a/ccsrc/lib/mq_base/CMakeLists.txt +++ b/ccsrc/lib/quafu_base/CMakeLists.txt @@ -19,11 +19,11 @@ # lint_cmake: -whitespace/indent target_sources( - mq_base PRIVATE ${CMAKE_CURRENT_LIST_DIR}/utils.cc $<$:${CMAKE_CURRENT_LIST_DIR}/logging.cpp> + quafu_base PRIVATE ${CMAKE_CURRENT_LIST_DIR}/utils.cc $<$:${CMAKE_CURRENT_LIST_DIR}/logging.cpp> ${CMAKE_CURRENT_LIST_DIR}/gates/gates.cpp ${CMAKE_CURRENT_LIST_DIR}/libc_compat.cpp) if(ENABLE_CUDA) - target_compile_definitions(mq_base PUBLIC GPUACCELERATED) + target_compile_definitions(quafu_base PUBLIC GPUACCELERATED) endif() # ============================================================================== diff --git a/ccsrc/lib/mq_base/gates/CPPLINT.cfg b/ccsrc/lib/quafu_base/gates/CPPLINT.cfg similarity index 100% rename from ccsrc/lib/mq_base/gates/CPPLINT.cfg rename to ccsrc/lib/quafu_base/gates/CPPLINT.cfg diff --git a/ccsrc/lib/mq_base/gates/gates.cpp b/ccsrc/lib/quafu_base/gates/gates.cpp similarity index 98% rename from ccsrc/lib/mq_base/gates/gates.cpp rename to ccsrc/lib/quafu_base/gates/gates.cpp index 25415e85c..aabc2de17 100644 --- a/ccsrc/lib/mq_base/gates/gates.cpp +++ b/ccsrc/lib/quafu_base/gates/gates.cpp @@ -18,14 +18,14 @@ #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "math/tensor/matrix.h" #include "math/tensor/ops/advance_math.h" #include "math/tensor/tensor.h" #include "math/tensor/traits.h" #include "ops/basic_gate.h" -namespace mindquantum { +namespace quafu { tensor::Matrix U3Matrix(tensor::Tensor theta, tensor::Tensor phi, tensor::Tensor lambda) { auto el = tensor::ops::exp(lambda * std::complex(0, 1)); auto ep = tensor::ops::exp(phi * std::complex(0, 1)); @@ -177,4 +177,4 @@ FSim::FSim(const parameter::ParameterResolver& theta, const parameter::Parameter this->base_matrix_ = FSimMatrix(theta.const_value, phi.const_value); } } -} // namespace mindquantum +} // namespace quafu diff --git a/ccsrc/lib/mq_base/libc_compat.cpp b/ccsrc/lib/quafu_base/libc_compat.cpp similarity index 100% rename from ccsrc/lib/mq_base/libc_compat.cpp rename to ccsrc/lib/quafu_base/libc_compat.cpp diff --git a/ccsrc/lib/mq_base/logging.cpp b/ccsrc/lib/quafu_base/logging.cpp similarity index 87% rename from ccsrc/lib/mq_base/logging.cpp rename to ccsrc/lib/quafu_base/logging.cpp index 286c73ed8..7ed157e1a 100644 --- a/ccsrc/lib/mq_base/logging.cpp +++ b/ccsrc/lib/quafu_base/logging.cpp @@ -20,9 +20,9 @@ #include -namespace mindquantum::logging { +namespace quafu::logging { void set_log_file(const std::string& filename) { spdlog::set_default_logger(spdlog::basic_logger_mt("default_log", filename)); - MQ_INFO("Setting log file to {}", filename); + QUAFU_INFO("Setting log file to {}", filename); } -} // namespace mindquantum::logging +} // namespace quafu::logging diff --git a/ccsrc/lib/mq_base/utils.cc b/ccsrc/lib/quafu_base/utils.cc similarity index 96% rename from ccsrc/lib/mq_base/utils.cc rename to ccsrc/lib/quafu_base/utils.cc index 59f9ebaa9..a0f9ea9ac 100644 --- a/ccsrc/lib/mq_base/utils.cc +++ b/ccsrc/lib/quafu_base/utils.cc @@ -16,9 +16,9 @@ #include "core/utils.h" -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" -namespace mindquantum { +namespace quafu { const VT> POLAR = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; TimePoint NOW() { return std::chrono::steady_clock::now(); @@ -64,4 +64,4 @@ PauliMask GetPauliMask(const VT &pws) { PauliMask res = {out[0], out[1], out[2], out[3], out[4], out[5]}; return res; } -} // namespace mindquantum +} // namespace quafu diff --git a/ccsrc/lib/simulator/CMakeLists.txt b/ccsrc/lib/simulator/CMakeLists.txt index 45087801d..e332ba575 100644 --- a/ccsrc/lib/simulator/CMakeLists.txt +++ b/ccsrc/lib/simulator/CMakeLists.txt @@ -16,60 +16,60 @@ # # ============================================================================== -add_library(mqsim_common STATIC ${CMAKE_CURRENT_LIST_DIR}/utils.cpp ${CMAKE_CURRENT_LIST_DIR}/timer.cpp) -target_link_libraries(mqsim_common PUBLIC mq_base) -force_at_least_cxx17_workaround(mqsim_common) -append_to_property(mq_install_targets GLOBAL mqsim_common) +add_library(quafusim_common STATIC ${CMAKE_CURRENT_LIST_DIR}/utils.cpp ${CMAKE_CURRENT_LIST_DIR}/timer.cpp) +target_link_libraries(quafusim_common PUBLIC quafu_base) +force_at_least_cxx17_workaround(quafusim_common) +append_to_property(quafu_install_targets GLOBAL quafusim_common) if(MSVC) - target_compile_options(mqsim_common PUBLIC /wd4661 /openmp:llvm) + target_compile_options(quafusim_common PUBLIC /wd4661 /openmp:llvm) endif() -add_library(mqsim_vector_cpu STATIC) -target_link_libraries(mqsim_vector_cpu PUBLIC mqsim_common mq_math intrin_flag_CXX) -force_at_least_cxx17_workaround(mqsim_vector_cpu) -append_to_property(mq_install_targets GLOBAL mqsim_vector_cpu) +add_library(quafusim_vector_cpu STATIC) +target_link_libraries(quafusim_vector_cpu PUBLIC quafusim_common quafu_math intrin_flag_CXX) +force_at_least_cxx17_workaround(quafusim_vector_cpu) +append_to_property(quafu_install_targets GLOBAL quafusim_vector_cpu) if(X86_64) - add_executable(mqrt) - target_link_libraries(mqrt PUBLIC mqsim_vector_cpu) - force_at_least_cxx17_workaround(mqrt) - append_to_property(mq_install_targets GLOBAL mqrt) + add_executable(quafurt) + target_link_libraries(quafurt PUBLIC quafusim_vector_cpu) + force_at_least_cxx17_workaround(quafurt) + append_to_property(quafu_install_targets GLOBAL quafurt) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/vector/detail/runtime) endif() # ============================================================================== -# add_library( mqsim_vector_cpu STATIC ${CMAKE_CURRENT_LIST_DIR}/vector/detail/cpu_vector_policy.cpp +# add_library( quafusim_vector_cpu STATIC ${CMAKE_CURRENT_LIST_DIR}/vector/detail/cpu_vector_policy.cpp # ${CMAKE_CURRENT_LIST_DIR}/vector/detail/cpu_vector_policy_zlike.cpp # ${CMAKE_CURRENT_LIST_DIR}/vector/detail/cpu_vector_policy_xlike.cpp # ${CMAKE_CURRENT_LIST_DIR}/vector/detail/cpu_vector_policy_single_ops.cpp # ${CMAKE_CURRENT_LIST_DIR}/vector/detail/cpu_vector_policy_gate_expec.cpp) -# target_link_libraries(mqsim_vector_cpu PUBLIC mqsim_common intrin_flag_CXX) -# force_at_least_cxx17_workaround(mqsim_vector_cpu) append_to_property(mq_install_targets GLOBAL mqsim_vector_cpu) +# target_link_libraries(quafusim_vector_cpu PUBLIC quafusim_common intrin_flag_CXX) +# force_at_least_cxx17_workaround(quafusim_vector_cpu) append_to_property(quafu_install_targets GLOBAL quafusim_vector_cpu) # ============================================================================== if(ENABLE_CUDA) - add_library(mqsim_vector_gpu STATIC) - target_link_libraries(mqsim_vector_gpu PUBLIC mqsim_common CUDA_mindquantum) - set_target_properties(mqsim_vector_gpu PROPERTIES CUDA_RUNTIME_LIBRARY $,Static,Shared>) - force_at_least_cxx17_workaround(mqsim_vector_gpu) - append_to_property(mq_install_targets GLOBAL mqsim_vector_gpu) + add_library(quafusim_vector_gpu STATIC) + target_link_libraries(quafusim_vector_gpu PUBLIC quafusim_common CUDA_quafu) + set_target_properties(quafusim_vector_gpu PROPERTIES CUDA_RUNTIME_LIBRARY $,Static,Shared>) + force_at_least_cxx17_workaround(quafusim_vector_gpu) + append_to_property(quafu_install_targets GLOBAL quafusim_vector_gpu) endif() add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/vector/detail) # ============================================================================== -add_library(mqsim_densitymatrix_cpu STATIC) -target_link_libraries(mqsim_densitymatrix_cpu PUBLIC mqsim_common mq_math intrin_flag_CXX) -force_at_least_cxx17_workaround(mqsim_densitymatrix_cpu) -append_to_property(mq_install_targets GLOBAL mqsim_densitymatrix_cpu) +add_library(quafusim_densitymatrix_cpu STATIC) +target_link_libraries(quafusim_densitymatrix_cpu PUBLIC quafusim_common quafu_math intrin_flag_CXX) +force_at_least_cxx17_workaround(quafusim_densitymatrix_cpu) +append_to_property(quafu_install_targets GLOBAL quafusim_densitymatrix_cpu) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/densitymatrix/detail) # ============================================================================== -add_library(mqsim_stabilizer STATIC) -target_link_libraries(mqsim_stabilizer PUBLIC mqsim_common mq_math intrin_flag_CXX) -force_at_least_cxx17_workaround(mqsim_stabilizer) -append_to_property(mq_install_targets GLOBAL mqsim_stabilizer) +add_library(quafusim_stabilizer STATIC) +target_link_libraries(quafusim_stabilizer PUBLIC quafusim_common quafu_math intrin_flag_CXX) +force_at_least_cxx17_workaround(quafusim_stabilizer) +append_to_property(quafu_install_targets GLOBAL quafusim_stabilizer) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/stabilizer) diff --git a/ccsrc/lib/simulator/densitymatrix/detail/CMakeLists.txt b/ccsrc/lib/simulator/densitymatrix/detail/CMakeLists.txt index f25708241..bb92e7747 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/CMakeLists.txt +++ b/ccsrc/lib/simulator/densitymatrix/detail/CMakeLists.txt @@ -21,7 +21,7 @@ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/cpu_common) if(X86_64) - target_compile_definitions(mqsim_densitymatrix_cpu PUBLIC __x86_64__) + target_compile_definitions(quafusim_densitymatrix_cpu PUBLIC __x86_64__) elseif(AARCH64) - target_compile_definitions(mqsim_densitymatrix_cpu PUBLIC __amd64) + target_compile_definitions(quafusim_densitymatrix_cpu PUBLIC __amd64) endif() diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/CMakeLists.txt b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/CMakeLists.txt index 043e9092c..149a23b2a 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/CMakeLists.txt +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/CMakeLists.txt @@ -19,7 +19,7 @@ # lint_cmake: -whitespace/indent target_sources( - mqsim_densitymatrix_cpu + quafusim_densitymatrix_cpu PRIVATE ${CMAKE_CURRENT_LIST_DIR}/cpu_densitymatrix_core_policy.cpp ${CMAKE_CURRENT_LIST_DIR}/cpu_densitymatrix_core_channel.cpp ${CMAKE_CURRENT_LIST_DIR}/cpu_densitymatrix_core_condition.cpp diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_channel.cpp b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_channel.cpp index ef460dbd3..67826a45c 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_channel.cpp +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_channel.cpp @@ -26,11 +26,11 @@ #endif #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { // Single qubit operator // ======================================================================================================== -// method is based on 'mq_vector' simulator, extended to densitymatrix +// method is based on 'quafu_vector' simulator, extended to densitymatrix template void CPUDensityMatrixPolicyBase::ApplySingleQubitChannel(const qs_data_p_t& src_out, qs_data_p_t* des_p, qbit_t obj_qubit, @@ -209,4 +209,4 @@ template struct CPUDensityMatrixPolicyBase; template struct CPUDensityMatrixPolicyBase; #endif -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_condition.cpp b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_condition.cpp index 7b503c5a2..cd9534e74 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_condition.cpp +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_condition.cpp @@ -27,11 +27,11 @@ #endif #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { template auto CPUDensityMatrixPolicyBase::DiagonalConditionalCollect(const qs_data_p_t& qs, index_t mask, - index_t condi, index_t dim) - -> calc_type { + index_t condi, + index_t dim) -> calc_type { if (qs == nullptr) { if ((0 & mask) == condi) { return 1.0; @@ -42,7 +42,7 @@ auto CPUDensityMatrixPolicyBase::DiagonalConditionalCollec calc_type res_real = 0; // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel + QUAFU_DO_PRAGMA(omp parallel for schedule(static) reduction(+: res_real)), dim, DimTh, for (omp::idx_t i = 0; i (dim); i++) { if ((i & mask) == condi) { @@ -168,4 +168,4 @@ template struct CPUDensityMatrixPolicyBase; template struct CPUDensityMatrixPolicyBase; #endif -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_gate_expect.cpp b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_gate_expect.cpp index 9628c3854..e75b33d62 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_gate_expect.cpp +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_gate_expect.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ #include "config/openmp.h" -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "core/utils.h" #include "math/pr/parameter_resolver.h" #include "simulator/utils.h" @@ -27,7 +27,7 @@ #endif #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { template auto CPUDensityMatrixPolicyBase::ExpectDiffRPS(const qs_data_p_t& qs_out, const qs_data_p_t& ham_matrix_out, @@ -54,7 +54,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRPS(const qs_da // clang-format off if (!ctrl_mask) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:e_r, e_i) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:e_r, e_i) schedule(static)), dim, DimTh, for (omp::idx_t i = 0; i < dim; i++) { auto j = i ^ mask_f; if (j <= i) { @@ -82,7 +82,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRPS(const qs_da }) } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:e_r, e_i) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:e_r, e_i) schedule(static)), dim, DimTh, for (omp::idx_t i = 0; i < dim; i++) { if ((i & ctrl_mask) == ctrl_mask) { auto j = i ^ mask_f; @@ -196,7 +196,7 @@ auto CPUDensityMatrixPolicyBase::ExpectationOfTerms(const auto coeff = coeff_; // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:e_r, e_i) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:e_r, e_i) schedule(static)), dim, DimTh, for (omp::idx_t i = 0; i (dim); i++) { auto j = (i ^ mask_f); if (i <= j) { @@ -237,7 +237,7 @@ auto CPUDensityMatrixPolicyBase::ExpectationOfCsr( auto indices = a->indices_; // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:e_r, e_i) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:e_r, e_i) schedule(static)), dim, DimTh, for (omp::idx_t i = 0; i < dim; i++) { qs_data_t sum = {0.0, 0.0}; for (index_t j = indptr[i]; j < indptr[i + 1]; j++) { @@ -283,7 +283,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffSingleQubitMatr if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); auto j = i + mask.obj_mask; @@ -301,7 +301,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffSingleQubitMatr } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); if ((i & mask.ctrl_mask) == mask.ctrl_mask) { @@ -362,7 +362,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffTwoQubitsMatrix if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 4); a++) { index_t r0; // row index of reduced matrix entry SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -392,7 +392,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffTwoQubitsMatrix } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 4); a++) { index_t r0; // row index of reduced matrix entry SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -482,24 +482,23 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffNQubitsMatrix( } calc_type res_real = 0, res_imag = 0; THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, - for (omp::idx_t a = 0; a < static_cast(dim); a++) { - if (((a & ctrl_mask) == ctrl_mask) && ((a & obj_mask) == 0)) { - qs_data_t this_res = 0; - for (index_t col = 0; col < dim; col++) { - for (size_t i = 0; i < m_dim; i++) { - qs_data_t tmp = 0; - for (size_t j = 0; j < m_dim; j++) { - tmp += m[i][j] * GetValue(qs, obj_masks[j] | a, col); - } - this_res += tmp - * GetValue(ham_matrix, col, obj_masks[i] | a); - } - } - res_real += this_res.real(); - res_imag += this_res.imag(); - } - }); + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + for (omp::idx_t a = 0; a < static_cast(dim); a++) { + if (((a & ctrl_mask) == ctrl_mask) && ((a & obj_mask) == 0)) { + qs_data_t this_res = 0; + for (index_t col = 0; col < dim; col++) { + for (size_t i = 0; i < m_dim; i++) { + qs_data_t tmp = 0; + for (size_t j = 0; j < m_dim; j++) { + tmp += m[i][j] * GetValue(qs, obj_masks[j] | a, col); + } + this_res += tmp * GetValue(ham_matrix, col, obj_masks[i] | a); + } + } + res_real += this_res.real(); + res_imag += this_res.imag(); + } + }); if (will_free) { derived::FreeState(&qs); } @@ -548,7 +547,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRX(const qs_dat if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); auto j = i + mask.obj_mask; @@ -565,7 +564,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRX(const qs_dat } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); if ((i & mask.ctrl_mask) == mask.ctrl_mask) { @@ -617,7 +616,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRY(const qs_dat if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); auto j = i + mask.obj_mask; @@ -634,7 +633,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRY(const qs_dat } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); if ((i & mask.ctrl_mask) == mask.ctrl_mask) { @@ -686,7 +685,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRZ(const qs_dat if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); auto j = i + mask.obj_mask; @@ -703,7 +702,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRZ(const qs_dat } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); if ((i & mask.ctrl_mask) == mask.ctrl_mask) { @@ -755,7 +754,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffPS(const qs_dat if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); auto j = i + mask.obj_mask; @@ -771,7 +770,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffPS(const qs_dat } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); if ((i & mask.ctrl_mask) == mask.ctrl_mask) { @@ -822,7 +821,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffGP(const qs_dat if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < (dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); auto j = i + mask.obj_mask; @@ -839,7 +838,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffGP(const qs_dat } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < (dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); if ((i & mask.ctrl_mask) == mask.ctrl_mask) { @@ -893,7 +892,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffU3Theta(const q if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); auto j = i + mask.obj_mask; @@ -909,7 +908,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffU3Theta(const q } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); if ((i & mask.ctrl_mask) == mask.ctrl_mask) { @@ -960,7 +959,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffU3Phi(const qs_ if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); auto j = i + mask.obj_mask; @@ -976,7 +975,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffU3Phi(const qs_ } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t a = 0; a < static_cast(dim / 2); a++) { auto i = ((a & mask.obj_high_mask) << 1) + (a & mask.obj_low_mask); if ((i & mask.ctrl_mask) == mask.ctrl_mask) { @@ -1027,7 +1026,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRxx(const qs_da if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1050,7 +1049,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRxx(const qs_da } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1108,7 +1107,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRyy(const qs_da if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1131,7 +1130,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRyy(const qs_da } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1189,7 +1188,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRzz(const qs_da if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1212,7 +1211,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRzz(const qs_da } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1270,7 +1269,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRxy(const qs_da if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < (dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1293,7 +1292,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRxy(const qs_da } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < (dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1351,7 +1350,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRxz(const qs_da if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < (dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1374,7 +1373,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRxz(const qs_da } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < (dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1432,7 +1431,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRyz(const qs_da if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < (dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1455,7 +1454,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffRyz(const qs_da } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < (dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1514,7 +1513,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffSWAPalpha(const if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1535,7 +1534,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffSWAPalpha(const } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1591,7 +1590,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffGivens(const qs if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1611,7 +1610,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffGivens(const qs } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1666,7 +1665,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffFSimTheta(const if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1686,7 +1685,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffFSimTheta(const } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1741,7 +1740,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffFSimPhi(const q if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1759,7 +1758,7 @@ auto CPUDensityMatrixPolicyBase::ExpectDiffFSimPhi(const q } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t r0; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -1793,4 +1792,4 @@ template struct CPUDensityMatrixPolicyBase; template struct CPUDensityMatrixPolicyBase; #endif -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_matrix_gate.cpp b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_matrix_gate.cpp index 027c2a360..a85907489 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_matrix_gate.cpp +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_matrix_gate.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ #include "config/openmp.h" -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "core/utils.h" #include "math/pr/parameter_resolver.h" #include "simulator/utils.h" @@ -27,11 +27,11 @@ #endif #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { // Single qubit operator // ======================================================================================================== -// method is based on 'mq_vector' simulator, extended to densitymatrix +// method is based on 'quafu_vector' simulator, extended to densitymatrix template void CPUDensityMatrixPolicyBase::ApplySingleQubitMatrix(const qs_data_p_t& src_out, qs_data_p_t* des_p, qbit_t obj_qubit, @@ -398,4 +398,4 @@ template struct CPUDensityMatrixPolicyBase; template struct CPUDensityMatrixPolicyBase; #endif -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_other_gate.cpp b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_other_gate.cpp index 170e67dc3..485f9c790 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_other_gate.cpp +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_other_gate.cpp @@ -23,7 +23,7 @@ #endif #include "ops/gates.h" #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { template void CPUDensityMatrixPolicyBase::ApplyH(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, index_t dim) { @@ -63,4 +63,4 @@ template struct CPUDensityMatrixPolicyBase; template struct CPUDensityMatrixPolicyBase; #endif -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_policy.cpp b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_policy.cpp index 73808d347..bbd0a64d9 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_policy.cpp +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_policy.cpp @@ -17,7 +17,7 @@ #include #include "config/openmp.h" -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "core/utils.h" #include "math/pr/parameter_resolver.h" #include "simulator/utils.h" @@ -30,7 +30,7 @@ #endif #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { template auto CPUDensityMatrixPolicyBase::InitState(index_t dim, bool zero_state) -> qs_data_p_t { index_t n_elements = (dim * dim + dim) / 2; @@ -80,12 +80,10 @@ void CPUDensityMatrixPolicyBase::Display(const qs_data_p_t } else { for (index_t i = 0; i < dim; i++) { for (index_t j = 0; j <= i; j++) { - std::cout << "(" << qs[IdxMap(i, j)].real() << ", " << qs[IdxMap(i, j)].imag() << ")" - << ","; + std::cout << "(" << qs[IdxMap(i, j)].real() << ", " << qs[IdxMap(i, j)].imag() << ")" << ","; } for (index_t j = i + 1; j < dim; j++) { - std::cout << "(" << qs[IdxMap(j, i)].real() << ", " << -qs[IdxMap(j, i)].imag() << ")" - << ","; + std::cout << "(" << qs[IdxMap(j, i)].real() << ", " << -qs[IdxMap(j, i)].imag() << ")" << ","; } std::cout << std::endl; } @@ -200,13 +198,13 @@ auto CPUDensityMatrixPolicyBase::Purity(const qs_data_p_t& } calc_type p = 0; THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for schedule(static) reduction(+: p)), dim, DimTh, - for (omp::idx_t i = 0; i < static_cast((dim * dim + dim) / 2); - i++) { p += 2 * std::norm(qs[i]); }) + QUAFU_DO_PRAGMA(omp parallel for schedule(static) reduction(+: p)), dim, DimTh, + for (omp::idx_t i = 0; i < static_cast((dim * dim + dim) / 2); + i++) { p += 2 * std::norm(qs[i]); }) THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for schedule(static) reduction(+: p)), dim, DimTh, - for (omp::idx_t i = 0; i < static_cast(dim); - i++) { p += -std::norm(qs[IdxMap(i, i)]); }) + QUAFU_DO_PRAGMA(omp parallel for schedule(static) reduction(+: p)), dim, DimTh, + for (omp::idx_t i = 0; i < static_cast(dim); + i++) { p += -std::norm(qs[IdxMap(i, i)]); }) return p; } @@ -492,4 +490,4 @@ template struct CPUDensityMatrixPolicyBase; template struct CPUDensityMatrixPolicyBase; #endif -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_rot_pauli.cpp b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_rot_pauli.cpp index 1da67e971..bbd307c08 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_rot_pauli.cpp +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_rot_pauli.cpp @@ -26,7 +26,7 @@ #endif #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" #define MATSUM4(a1, b1, c1, d1, a2, b2, c2, d2) ((a1) * (a2) + (b1) * (b2) + (c1) * (c2) + (d1) * (d2)) -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { template void CPUDensityMatrixPolicyBase::ApplyRPS(qs_data_p_t* qs_p, const PauliMask& mask, Index ctrl_mask, calc_type val, index_t dim, @@ -993,4 +993,4 @@ template struct CPUDensityMatrixPolicyBase; template struct CPUDensityMatrixPolicyBase; #endif -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_swap_like.cpp b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_swap_like.cpp index 5c36dedc4..4da08a809 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_swap_like.cpp +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_swap_like.cpp @@ -26,7 +26,7 @@ #endif #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { template void CPUDensityMatrixPolicyBase::ApplySWAP(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, index_t dim) { @@ -317,4 +317,4 @@ template struct CPUDensityMatrixPolicyBase; template struct CPUDensityMatrixPolicyBase; #endif -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_utils.cpp b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_utils.cpp index f459ff781..475c65c20 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_utils.cpp +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_utils.cpp @@ -26,7 +26,7 @@ #endif #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { template void CPUDensityMatrixPolicyBase::SwapValue(qs_data_p_t qs, index_t x0, index_t y0, index_t x1, index_t y1, qs_data_t coeff) { @@ -48,4 +48,4 @@ template struct CPUDensityMatrixPolicyBase; template struct CPUDensityMatrixPolicyBase; #endif -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_x_like.cpp b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_x_like.cpp index a2d3905c7..0b5193161 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_x_like.cpp +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_x_like.cpp @@ -26,7 +26,7 @@ #endif #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { // X like operator // ======================================================================================================== @@ -128,4 +128,4 @@ template struct CPUDensityMatrixPolicyBase; template struct CPUDensityMatrixPolicyBase; #endif -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail diff --git a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_z_like.cpp b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_z_like.cpp index b6a014b22..0ec0964f7 100644 --- a/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_z_like.cpp +++ b/ccsrc/lib/simulator/densitymatrix/detail/cpu_common/cpu_densitymatrix_core_z_like.cpp @@ -26,7 +26,7 @@ #endif #include "simulator/densitymatrix/detail/cpu_densitymatrix_policy.h" -namespace mindquantum::sim::densitymatrix::detail { +namespace quafu::sim::densitymatrix::detail { // Z like operator // ======================================================================================================== @@ -189,4 +189,4 @@ template struct CPUDensityMatrixPolicyBase; template struct CPUDensityMatrixPolicyBase; #endif -} // namespace mindquantum::sim::densitymatrix::detail +} // namespace quafu::sim::densitymatrix::detail diff --git a/ccsrc/lib/simulator/stabilizer/CMakeLists.txt b/ccsrc/lib/simulator/stabilizer/CMakeLists.txt index e6e6febb5..78b49ff07 100644 --- a/ccsrc/lib/simulator/stabilizer/CMakeLists.txt +++ b/ccsrc/lib/simulator/stabilizer/CMakeLists.txt @@ -16,7 +16,7 @@ # # ============================================================================== -target_sources(mqsim_stabilizer PRIVATE +target_sources(quafusim_stabilizer PRIVATE ${CMAKE_CURRENT_LIST_DIR}/query_element.cpp ${CMAKE_CURRENT_LIST_DIR}/stabilizer.cpp ${CMAKE_CURRENT_LIST_DIR}/random_benchmarking.cpp diff --git a/ccsrc/lib/simulator/stabilizer/query_element.cpp b/ccsrc/lib/simulator/stabilizer/query_element.cpp index 32ff41b06..90c501493 100644 --- a/ccsrc/lib/simulator/stabilizer/query_element.cpp +++ b/ccsrc/lib/simulator/stabilizer/query_element.cpp @@ -17,7 +17,7 @@ #include #include "simulator/stabilizer/stabilizer.h" -namespace mindquantum::stabilizer { +namespace quafu::stabilizer { std::pair DetermineClass(size_t i) { if (i < 576) { return {0, i}; @@ -324,4 +324,4 @@ void Verification() { } } } -} // namespace mindquantum::stabilizer +} // namespace quafu::stabilizer diff --git a/ccsrc/lib/simulator/stabilizer/random_benchmarking.cpp b/ccsrc/lib/simulator/stabilizer/random_benchmarking.cpp index 4093df942..8e1fdfae0 100644 --- a/ccsrc/lib/simulator/stabilizer/random_benchmarking.cpp +++ b/ccsrc/lib/simulator/stabilizer/random_benchmarking.cpp @@ -18,7 +18,7 @@ #include #include "simulator/stabilizer/stabilizer.h" -namespace mindquantum::stabilizer { +namespace quafu::stabilizer { VT SingleQubitRBCircuit(size_t len, int seed) { VT out{}; if (len < 2) { @@ -62,4 +62,4 @@ VT DoubleQubitsRBCircuit(size_t len, int seed) { out.push_back(last_stab); return out; } -} // namespace mindquantum::stabilizer +} // namespace quafu::stabilizer diff --git a/ccsrc/lib/simulator/stabilizer/stabilizer.cpp b/ccsrc/lib/simulator/stabilizer/stabilizer.cpp index f5ca54f45..f303efa28 100644 --- a/ccsrc/lib/simulator/stabilizer/stabilizer.cpp +++ b/ccsrc/lib/simulator/stabilizer/stabilizer.cpp @@ -21,12 +21,12 @@ #include #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "math/longbits/longbits.h" #include "ops/basic_gate.h" #include "ops/gate_id.h" -namespace mindquantum::stabilizer { +namespace quafu::stabilizer { StabilizerTableau::StabilizerTableau(size_t n_qubits, unsigned seed) : n_qubits(n_qubits), seed(seed), rnd_eng_(seed) { phase = LongBits(2 * n_qubits); table = std::vector(2 * n_qubits, LongBits(n_qubits * 2)); @@ -634,4 +634,4 @@ double StabilizerTableau::GetExpectation(const VT>& ham_termli } return expectation; } -} // namespace mindquantum::stabilizer +} // namespace quafu::stabilizer diff --git a/ccsrc/lib/simulator/timer.cpp b/ccsrc/lib/simulator/timer.cpp index c3d924755..5758230b0 100644 --- a/ccsrc/lib/simulator/timer.cpp +++ b/ccsrc/lib/simulator/timer.cpp @@ -18,7 +18,7 @@ #include -namespace mindquantum::timer { +namespace quafu::timer { TimePoint NOW() { return std::chrono::steady_clock::now(); } @@ -87,4 +87,4 @@ void Timer::Analyze() { << time_unit::time_unit_v() << std::endl; } } -} // namespace mindquantum::timer +} // namespace quafu::timer diff --git a/ccsrc/lib/simulator/utils.cpp b/ccsrc/lib/simulator/utils.cpp index 77b2b54a0..547305fdb 100644 --- a/ccsrc/lib/simulator/utils.cpp +++ b/ccsrc/lib/simulator/utils.cpp @@ -19,7 +19,7 @@ #include #include -namespace mindquantum::sim { +namespace quafu::sim { index_t QIndexToMask(qbits_t objs) { return std::accumulate(objs.begin(), objs.end(), index_t(0), [](index_t a, qbit_t b) { return a + (static_cast(1) << b); }); @@ -72,4 +72,4 @@ DoubleQubitGateMask::DoubleQubitGateMask(const qbits_t &obj_qubits, const qbits_ obj_rev_low_mask = ~obj_low_mask; obj_rev_high_mask = ~obj_high_mask; } -} // namespace mindquantum::sim +} // namespace quafu::sim diff --git a/ccsrc/lib/simulator/vector/detail/CMakeLists.txt b/ccsrc/lib/simulator/vector/detail/CMakeLists.txt index eb817ccd7..eb465201c 100644 --- a/ccsrc/lib/simulator/vector/detail/CMakeLists.txt +++ b/ccsrc/lib/simulator/vector/detail/CMakeLists.txt @@ -22,9 +22,9 @@ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/cpu_common) if(X86_64) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/cpu_avx_double) - target_compile_definitions(mqsim_vector_cpu PUBLIC __x86_64__) + target_compile_definitions(quafusim_vector_cpu PUBLIC __x86_64__) elseif(AARCH64) - target_compile_definitions(mqsim_vector_cpu PUBLIC __amd64) + target_compile_definitions(quafusim_vector_cpu PUBLIC __amd64) endif() if(ENABLE_CUDA) diff --git a/ccsrc/lib/simulator/vector/detail/cpu_avx_double/CMakeLists.txt b/ccsrc/lib/simulator/vector/detail/cpu_avx_double/CMakeLists.txt index 2f7ebfea2..69233b385 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_avx_double/CMakeLists.txt +++ b/ccsrc/lib/simulator/vector/detail/cpu_avx_double/CMakeLists.txt @@ -18,5 +18,5 @@ # lint_cmake: -whitespace/indent -target_sources(mqsim_vector_cpu PRIVATE ${CMAKE_CURRENT_LIST_DIR}/cpu_vector_core_matrix_gate.cpp +target_sources(quafusim_vector_cpu PRIVATE ${CMAKE_CURRENT_LIST_DIR}/cpu_vector_core_matrix_gate.cpp ${CMAKE_CURRENT_LIST_DIR}/cpu_vector_core_gate_expect.cpp) diff --git a/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp b/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp index 0c4e8044c..bf48ce7d1 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_gate_expect.cpp @@ -18,7 +18,7 @@ #include "simulator/utils.h" #include "simulator/vector/detail/cpu_vector_avx_double_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { auto CPUVectorPolicyAvxDouble::ExpectDiffSingleQubitMatrix(const qs_data_p_t& bra_out, const qs_data_p_t& ket_out, const qbits_t& objs, const qbits_t& ctrls, const VVT& m, index_t dim) -> qs_data_t { @@ -44,7 +44,7 @@ auto CPUVectorPolicyAvxDouble::ExpectDiffSingleQubitMatrix(const qs_data_p_t& br if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 2); l++) { auto i = ((l & mask.obj_high_mask) << 1) + (l & mask.obj_low_mask); auto j = i + mask.obj_mask; @@ -75,7 +75,7 @@ auto CPUVectorPolicyAvxDouble::ExpectDiffSingleQubitMatrix(const qs_data_p_t& br auto second_high_mask = ~second_low_mask; // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { auto i = ((l & first_high_mask) << 1) + (l & first_low_mask); i = ((i & second_high_mask) << 1) + (i & second_low_mask) + mask.ctrl_mask; @@ -94,7 +94,7 @@ auto CPUVectorPolicyAvxDouble::ExpectDiffSingleQubitMatrix(const qs_data_p_t& br } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 2); l++) { auto i = ((l & mask.obj_high_mask) << 1) + (l & mask.obj_low_mask); if ((i & mask.ctrl_mask) == mask.ctrl_mask) { @@ -121,4 +121,4 @@ auto CPUVectorPolicyAvxDouble::ExpectDiffSingleQubitMatrix(const qs_data_p_t& br } return {res_real, res_imag}; }; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_matrix_gate.cpp b/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_matrix_gate.cpp index 104d7ad1c..3380a568a 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_matrix_gate.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_avx_double/cpu_vector_core_matrix_gate.cpp @@ -19,7 +19,7 @@ #include "simulator/utils.h" #include "simulator/vector/detail/cpu_vector_avx_double_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { void CPUVectorPolicyAvxDouble::ApplySingleQubitMatrix(const qs_data_p_t& src_out, qs_data_p_t* des_p, qbit_t obj_qubit, const qbits_t& ctrls, const std::vector>& m, index_t dim) { @@ -67,4 +67,4 @@ void CPUVectorPolicyAvxDouble::ApplySingleQubitMatrix(const qs_data_p_t& src_out CPUVectorPolicyAvxDouble::FreeState(&src); } } -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/cpu_common/CMakeLists.txt b/ccsrc/lib/simulator/vector/detail/cpu_common/CMakeLists.txt index 047ec5816..831ee1591 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_common/CMakeLists.txt +++ b/ccsrc/lib/simulator/vector/detail/cpu_common/CMakeLists.txt @@ -19,7 +19,7 @@ # lint_cmake: -whitespace/indent target_sources( - mqsim_vector_cpu + quafusim_vector_cpu PRIVATE ${CMAKE_CURRENT_LIST_DIR}/cpu_vector_core_policy.cpp ${CMAKE_CURRENT_LIST_DIR}/cpu_vector_core_condition.cpp ${CMAKE_CURRENT_LIST_DIR}/cpu_vector_core_dot_like.cpp diff --git a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_condition.cpp b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_condition.cpp index d7e4b4eaa..a17859b59 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_condition.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_condition.cpp @@ -26,7 +26,7 @@ # include "simulator/vector/detail/cpu_vector_arm_float_policy.h" #endif #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template template void CPUVectorPolicyBase::ConditionalBinary(const qs_data_p_t& src, qs_data_p_t* des_p, @@ -136,20 +136,20 @@ auto CPUVectorPolicyBase::ConditionalCollect(const qs_data } if (abs) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for schedule(static) reduction(+: res_real)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for schedule(static) reduction(+: res_real)), dim, DimTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { - if ((i & mask) == condi) { - res_real += qs[i].real() * qs[i].real() + qs[i].imag() * qs[i].imag(); - } + if ((i & mask) == condi) { + res_real += qs[i].real() * qs[i].real() + qs[i].imag() * qs[i].imag(); + } }); } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for schedule(static) reduction(+: res_real, res_imag)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for schedule(static) reduction(+: res_real, res_imag)), dim, DimTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { - if ((i & mask) == condi) { - res_real += qs[i].real(); - res_imag += qs[i].imag(); - } + if ((i & mask) == condi) { + res_real += qs[i].real(); + res_imag += qs[i].imag(); + } }); } return qs_data_t(res_real, res_imag); @@ -162,4 +162,4 @@ template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; #endif -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_dot_like.cpp b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_dot_like.cpp index 5e77410c0..a4d43324b 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_dot_like.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_dot_like.cpp @@ -28,10 +28,10 @@ #endif #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template -auto CPUVectorPolicyBase::Vdot(const qs_data_p_t& bra, const qs_data_p_t& ket, index_t dim) - -> py_qs_data_t { +auto CPUVectorPolicyBase::Vdot(const qs_data_p_t& bra, const qs_data_p_t& ket, + index_t dim) -> py_qs_data_t { if (bra == nullptr && ket == nullptr) { return 1.0; } else if (bra == nullptr) { @@ -42,7 +42,7 @@ auto CPUVectorPolicyBase::Vdot(const qs_data_p_t& bra, con calc_type res_real = 0, res_imag = 0; // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { res_real += bra[i].real() * ket[i].real() + bra[i].imag() * ket[i].imag(); res_imag += bra[i].real() * ket[i].imag() - bra[i].imag() * ket[i].real(); @@ -74,7 +74,7 @@ auto CPUVectorPolicyBase::ConditionVdot(const qs_data_p_t& calc_type res_real = 0, res_imag = 0; // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { if ((i & mask) == condi) { res_real += bra[i].real() * ket[i].real() + bra[i].imag() * ket[i].imag(); @@ -95,7 +95,7 @@ auto CPUVectorPolicyBase::OneStateVdot(const qs_data_p_t& calc_type res_real = 0, res_imag = 0; // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 2); l++) { auto i = ((l & mask.obj_high_mask) << 1) + (l & mask.obj_low_mask) + mask.obj_mask; res_real += bra[i].real() * ket[i].real() + bra[i].imag() * ket[i].imag(); @@ -119,7 +119,7 @@ auto CPUVectorPolicyBase::ZeroStateVdot(const qs_data_p_t& calc_type res_real = 0, res_imag = 0; // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 2); l++) { auto i = ((l & mask.obj_high_mask) << 1) + (l & mask.obj_low_mask); res_real += bra[i].real() * ket[i].real() + bra[i].imag() * ket[i].imag(); @@ -231,4 +231,4 @@ template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; #endif -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_gate_expect.cpp b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_gate_expect.cpp index 0fb5de1a7..8f25380b8 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_gate_expect.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_gate_expect.cpp @@ -26,13 +26,13 @@ # include "simulator/vector/detail/cpu_vector_arm_float_policy.h" #endif #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template auto CPUVectorPolicyBase::ExpectDiffNQubitsMatrix(const qs_data_p_t& bra_out, const qs_data_p_t& ket_out, const qbits_t& objs, const qbits_t& ctrls, - const VVT& gate, index_t dim) - -> qs_data_t { + const VVT& gate, + index_t dim) -> qs_data_t { auto bra = bra_out; auto ket = ket_out; bool will_free_bra = false, will_free_ket = false; @@ -65,19 +65,19 @@ auto CPUVectorPolicyBase::ExpectDiffNQubitsMatrix(const qs auto obj_mask = obj_masks.back(); calc_type res_real = 0, res_imag = 0; THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim); l++) { - if (((l & ctrl_mask) == ctrl_mask) && ((l & obj_mask) == 0)) { - for (size_t i = 0; i < m_dim; i++) { - qs_data_t tmp = 0; - for (size_t j = 0; j < m_dim; j++) { - tmp += gate[i][j] * ket[obj_masks[j] | l]; - } - tmp = std::conj(bra[obj_masks[i] | l]) * tmp; - res_real += tmp.real(); - res_imag += tmp.imag(); - } - } + if (((l & ctrl_mask) == ctrl_mask) && ((l & obj_mask) == 0)) { + for (size_t i = 0; i < m_dim; i++) { + qs_data_t tmp = 0; + for (size_t j = 0; j < m_dim; j++) { + tmp += gate[i][j] * ket[obj_masks[j] | l]; + } + tmp = std::conj(bra[obj_masks[i] | l]) * tmp; + res_real += tmp.real(); + res_imag += tmp.imag(); + } + } }) if (will_free_bra) { derived::FreeState(&bra); @@ -92,8 +92,8 @@ template auto CPUVectorPolicyBase::ExpectDiffTwoQubitsMatrix(const qs_data_p_t& bra_out, const qs_data_p_t& ket_out, const qbits_t& objs, const qbits_t& ctrls, - const VVT& gate, index_t dim) - -> qs_data_t { + const VVT& gate, + index_t dim) -> qs_data_t { auto bra = bra_out; auto ket = ket_out; bool will_free_bra = false, will_free_ket = false; @@ -110,7 +110,7 @@ auto CPUVectorPolicyBase::ExpectDiffTwoQubitsMatrix(const // clang-format off if (!mask.ctrl_mask) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t i; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, @@ -131,7 +131,7 @@ auto CPUVectorPolicyBase::ExpectDiffTwoQubitsMatrix(const }) } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { index_t i; SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, @@ -185,7 +185,7 @@ auto CPUVectorPolicyBase::ExpectDiffRPS(const qs_data_p_t& // clang-format off if (!ctrl_mask) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t i = 0; i < dim; i++) { auto j = i ^ mask_f; if (i <= j) { @@ -207,7 +207,7 @@ auto CPUVectorPolicyBase::ExpectDiffRPS(const qs_data_p_t& }) } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t i = 0; i < dim; i++) { if ((i & ctrl_mask) == ctrl_mask) { auto j = i ^ mask_f; @@ -244,8 +244,8 @@ template auto CPUVectorPolicyBase::ExpectDiffSingleQubitMatrix(const qs_data_p_t& bra_out, const qs_data_p_t& ket_out, const qbits_t& objs, const qbits_t& ctrls, - const VVT& m, index_t dim) - -> qs_data_t { + const VVT& m, + index_t dim) -> qs_data_t { auto bra = bra_out; auto ket = ket_out; bool will_free_bra = false, will_free_ket = false; @@ -262,7 +262,7 @@ auto CPUVectorPolicyBase::ExpectDiffSingleQubitMatrix(cons if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 2); l++) { auto i = ((l & mask.obj_high_mask) << 1) + (l & mask.obj_low_mask); auto j = i + mask.obj_mask; @@ -289,7 +289,7 @@ auto CPUVectorPolicyBase::ExpectDiffSingleQubitMatrix(cons auto second_high_mask = ~second_low_mask; // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { auto i = ((l & first_high_mask) << 1) + (l & first_low_mask); i = ((i & second_high_mask) << 1) + (i & second_low_mask) + mask.ctrl_mask; @@ -304,7 +304,7 @@ auto CPUVectorPolicyBase::ExpectDiffSingleQubitMatrix(cons } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 2); l++) { auto i = ((l & mask.obj_high_mask) << 1) + (l & mask.obj_low_mask); if ((i & mask.ctrl_mask) == mask.ctrl_mask) { @@ -331,8 +331,8 @@ auto CPUVectorPolicyBase::ExpectDiffSingleQubitMatrix(cons template auto CPUVectorPolicyBase::ExpectDiffMatrixGate(const qs_data_p_t& bra, const qs_data_p_t& ket, const qbits_t& objs, const qbits_t& ctrls, - const VVT& m, index_t dim) - -> qs_data_t { + const VVT& m, + index_t dim) -> qs_data_t { if (objs.size() == 1) { return derived::ExpectDiffSingleQubitMatrix(bra, ket, objs, ctrls, m, dim); } @@ -406,7 +406,7 @@ auto CPUVectorPolicyBase::ExpectDiffPS(const qs_data_p_t& if (!mask.ctrl_mask) { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 2); l++) { auto i = ((l & mask.obj_high_mask) << 1) + (l & mask.obj_low_mask); auto j = i + mask.obj_mask; @@ -418,7 +418,7 @@ auto CPUVectorPolicyBase::ExpectDiffPS(const qs_data_p_t& } else { // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 2); l++) { auto i = ((l & mask.obj_high_mask) << 1) + (l & mask.obj_low_mask); if ((i & mask.ctrl_mask) == mask.ctrl_mask) { @@ -460,47 +460,45 @@ auto CPUVectorPolicyBase::ExpectDiffRxx(const qs_data_p_t& calc_type res_real = 0, res_imag = 0; if (!mask.ctrl_mask) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v00 = c * ket[i] + s * ket[m]; - auto v01 = c * ket[j] + s * ket[k]; - auto v10 = c * ket[k] + s * ket[j]; - auto v11 = c * ket[m] + s * ket[i]; - auto this_res = std::conj(bra[i]) * v00; - this_res += std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - this_res += std::conj(bra[m]) * v11; - res_real += this_res.real(); - res_imag += this_res.imag(); + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v00 = c * ket[i] + s * ket[m]; + auto v01 = c * ket[j] + s * ket[k]; + auto v10 = c * ket[k] + s * ket[j]; + auto v11 = c * ket[m] + s * ket[i]; + auto this_res = std::conj(bra[i]) * v00; + this_res += std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + this_res += std::conj(bra[m]) * v11; + res_real += this_res.real(); + res_imag += this_res.imag(); }) } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - if ((i & mask.ctrl_mask) == mask.ctrl_mask) { - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v00 = c * ket[i] + s * ket[m]; - auto v01 = c * ket[j] + s * ket[k]; - auto v10 = c * ket[k] + s * ket[j]; - auto v11 = c * ket[m] + s * ket[i]; - auto this_res = std::conj(bra[i]) * v00; - this_res += std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - this_res += std::conj(bra[m]) * v11; - res_real += this_res.real(); - res_imag += this_res.imag(); - } + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + if ((i & mask.ctrl_mask) == mask.ctrl_mask) { + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v00 = c * ket[i] + s * ket[m]; + auto v01 = c * ket[j] + s * ket[k]; + auto v10 = c * ket[k] + s * ket[j]; + auto v11 = c * ket[m] + s * ket[i]; + auto this_res = std::conj(bra[i]) * v00; + this_res += std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + this_res += std::conj(bra[m]) * v11; + res_real += this_res.real(); + res_imag += this_res.imag(); + } }) } if (will_free_bra) { @@ -533,47 +531,45 @@ auto CPUVectorPolicyBase::ExpectDiffRxy(const qs_data_p_t& calc_type res_real = 0, res_imag = 0; if (!mask.ctrl_mask) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v00 = c * ket[i] - s * ket[m]; - auto v01 = c * ket[j] - s * ket[k]; - auto v10 = c * ket[k] + s * ket[j]; - auto v11 = c * ket[m] + s * ket[i]; - auto this_res = std::conj(bra[i]) * v00; - this_res += std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - this_res += std::conj(bra[m]) * v11; - res_real += this_res.real(); - res_imag += this_res.imag(); + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v00 = c * ket[i] - s * ket[m]; + auto v01 = c * ket[j] - s * ket[k]; + auto v10 = c * ket[k] + s * ket[j]; + auto v11 = c * ket[m] + s * ket[i]; + auto this_res = std::conj(bra[i]) * v00; + this_res += std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + this_res += std::conj(bra[m]) * v11; + res_real += this_res.real(); + res_imag += this_res.imag(); }) } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - if ((i & mask.ctrl_mask) == mask.ctrl_mask) { - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v00 = c * ket[i] - s * ket[m]; - auto v01 = c * ket[j] - s * ket[k]; - auto v10 = c * ket[k] + s * ket[j]; - auto v11 = c * ket[m] + s * ket[i]; - auto this_res = std::conj(bra[i]) * v00; - this_res += std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - this_res += std::conj(bra[m]) * v11; - res_real += this_res.real(); - res_imag += this_res.imag(); - } + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + if ((i & mask.ctrl_mask) == mask.ctrl_mask) { + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v00 = c * ket[i] - s * ket[m]; + auto v01 = c * ket[j] - s * ket[k]; + auto v10 = c * ket[k] + s * ket[j]; + auto v11 = c * ket[m] + s * ket[i]; + auto this_res = std::conj(bra[i]) * v00; + this_res += std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + this_res += std::conj(bra[m]) * v11; + res_real += this_res.real(); + res_imag += this_res.imag(); + } }) } if (will_free_bra) { @@ -606,37 +602,35 @@ auto CPUVectorPolicyBase::ExpectDiffGivens(const qs_data_p calc_type res_real = 0, res_imag = 0; if (!mask.ctrl_mask) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v01 = c * ket[j] - s * ket[k]; - auto v10 = s * ket[j] + c * ket[k]; - auto this_res = std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - res_real += this_res.real(); - res_imag += this_res.imag(); + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v01 = c * ket[j] - s * ket[k]; + auto v10 = s * ket[j] + c * ket[k]; + auto this_res = std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + res_real += this_res.real(); + res_imag += this_res.imag(); }) } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - if ((i & mask.ctrl_mask) == mask.ctrl_mask) { - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v01 = c * ket[j] - s * ket[k]; - auto v10 = s * ket[j] + c * ket[k]; - auto this_res = std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - res_real += this_res.real(); - res_imag += this_res.imag(); - } + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + if ((i & mask.ctrl_mask) == mask.ctrl_mask) { + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v01 = c * ket[j] - s * ket[k]; + auto v10 = s * ket[j] + c * ket[k]; + auto this_res = std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + res_real += this_res.real(); + res_imag += this_res.imag(); + } }) } if (will_free_bra) { @@ -669,47 +663,45 @@ auto CPUVectorPolicyBase::ExpectDiffRxz(const qs_data_p_t& calc_type res_real = 0, res_imag = 0; if (!mask.ctrl_mask) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v00 = c * ket[i] + s * ket[j]; - auto v01 = c * ket[j] + s * ket[i]; - auto v10 = c * ket[k] - s * ket[m]; - auto v11 = c * ket[m] - s * ket[k]; - auto this_res = std::conj(bra[i]) * v00; - this_res += std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - this_res += std::conj(bra[m]) * v11; - res_real += this_res.real(); - res_imag += this_res.imag(); + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v00 = c * ket[i] + s * ket[j]; + auto v01 = c * ket[j] + s * ket[i]; + auto v10 = c * ket[k] - s * ket[m]; + auto v11 = c * ket[m] - s * ket[k]; + auto this_res = std::conj(bra[i]) * v00; + this_res += std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + this_res += std::conj(bra[m]) * v11; + res_real += this_res.real(); + res_imag += this_res.imag(); }) } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - if ((i & mask.ctrl_mask) == mask.ctrl_mask) { - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v00 = c * ket[i] + s * ket[j]; - auto v01 = c * ket[j] + s * ket[i]; - auto v10 = c * ket[k] - s * ket[m]; - auto v11 = c * ket[m] - s * ket[k]; - auto this_res = std::conj(bra[i]) * v00; - this_res += std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - this_res += std::conj(bra[m]) * v11; - res_real += this_res.real(); - res_imag += this_res.imag(); - } + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + if ((i & mask.ctrl_mask) == mask.ctrl_mask) { + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v00 = c * ket[i] + s * ket[j]; + auto v01 = c * ket[j] + s * ket[i]; + auto v10 = c * ket[k] - s * ket[m]; + auto v11 = c * ket[m] - s * ket[k]; + auto this_res = std::conj(bra[i]) * v00; + this_res += std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + this_res += std::conj(bra[m]) * v11; + res_real += this_res.real(); + res_imag += this_res.imag(); + } }) } if (will_free_bra) { @@ -742,47 +734,45 @@ auto CPUVectorPolicyBase::ExpectDiffRyz(const qs_data_p_t& calc_type res_real = 0, res_imag = 0; if (!mask.ctrl_mask) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v00 = c * ket[i] - s * ket[j]; - auto v01 = c * ket[j] + s * ket[i]; - auto v10 = c * ket[k] + s * ket[m]; - auto v11 = c * ket[m] - s * ket[k]; - auto this_res = std::conj(bra[i]) * v00; - this_res += std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - this_res += std::conj(bra[m]) * v11; - res_real += this_res.real(); - res_imag += this_res.imag(); + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v00 = c * ket[i] - s * ket[j]; + auto v01 = c * ket[j] + s * ket[i]; + auto v10 = c * ket[k] + s * ket[m]; + auto v11 = c * ket[m] - s * ket[k]; + auto this_res = std::conj(bra[i]) * v00; + this_res += std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + this_res += std::conj(bra[m]) * v11; + res_real += this_res.real(); + res_imag += this_res.imag(); }) } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - if ((i & mask.ctrl_mask) == mask.ctrl_mask) { - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v00 = c * ket[i] - s * ket[j]; - auto v01 = c * ket[j] + s * ket[i]; - auto v10 = c * ket[k] + s * ket[m]; - auto v11 = c * ket[m] - s * ket[k]; - auto this_res = std::conj(bra[i]) * v00; - this_res += std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - this_res += std::conj(bra[m]) * v11; - res_real += this_res.real(); - res_imag += this_res.imag(); - } + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + if ((i & mask.ctrl_mask) == mask.ctrl_mask) { + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v00 = c * ket[i] - s * ket[j]; + auto v01 = c * ket[j] + s * ket[i]; + auto v10 = c * ket[k] + s * ket[m]; + auto v11 = c * ket[m] - s * ket[k]; + auto this_res = std::conj(bra[i]) * v00; + this_res += std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + this_res += std::conj(bra[m]) * v11; + res_real += this_res.real(); + res_imag += this_res.imag(); + } }) } if (will_free_bra) { @@ -815,47 +805,45 @@ auto CPUVectorPolicyBase::ExpectDiffRyy(const qs_data_p_t& calc_type res_real = 0, res_imag = 0; if (!mask.ctrl_mask) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v00 = c * ket[i] + s * ket[m]; - auto v01 = c * ket[j] - s * ket[k]; - auto v10 = c * ket[k] - s * ket[j]; - auto v11 = c * ket[m] + s * ket[i]; - auto this_res = std::conj(bra[i]) * v00; - this_res += std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - this_res += std::conj(bra[m]) * v11; - res_real += this_res.real(); - res_imag += this_res.imag(); + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v00 = c * ket[i] + s * ket[m]; + auto v01 = c * ket[j] - s * ket[k]; + auto v10 = c * ket[k] - s * ket[j]; + auto v11 = c * ket[m] + s * ket[i]; + auto this_res = std::conj(bra[i]) * v00; + this_res += std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + this_res += std::conj(bra[m]) * v11; + res_real += this_res.real(); + res_imag += this_res.imag(); }) } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - if ((i & mask.ctrl_mask) == mask.ctrl_mask) { - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v00 = c * ket[i] + s * ket[m]; - auto v01 = c * ket[j] - s * ket[k]; - auto v10 = c * ket[k] - s * ket[j]; - auto v11 = c * ket[m] + s * ket[i]; - auto this_res = std::conj(bra[i]) * v00; - this_res += std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - this_res += std::conj(bra[m]) * v11; - res_real += this_res.real(); - res_imag += this_res.imag(); - } + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + if ((i & mask.ctrl_mask) == mask.ctrl_mask) { + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v00 = c * ket[i] + s * ket[m]; + auto v01 = c * ket[j] - s * ket[k]; + auto v10 = c * ket[k] - s * ket[j]; + auto v11 = c * ket[m] + s * ket[i]; + auto this_res = std::conj(bra[i]) * v00; + this_res += std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + this_res += std::conj(bra[m]) * v11; + res_real += this_res.real(); + res_imag += this_res.imag(); + } }) } if (will_free_bra) { @@ -891,39 +879,37 @@ auto CPUVectorPolicyBase::ExpectDiffRzz(const qs_data_p_t& calc_type res_real = 0, res_imag = 0; if (!mask.ctrl_mask) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto this_res = std::conj(bra[i]) * ket[i] * me; - this_res += std::conj(bra[j]) * ket[j] * e; - this_res += std::conj(bra[k]) * ket[k] * e; - this_res += std::conj(bra[m]) * ket[m] * me; - res_real += this_res.real(); - res_imag += this_res.imag(); + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto this_res = std::conj(bra[i]) * ket[i] * me; + this_res += std::conj(bra[j]) * ket[j] * e; + this_res += std::conj(bra[k]) * ket[k] * e; + this_res += std::conj(bra[m]) * ket[m] * me; + res_real += this_res.real(); + res_imag += this_res.imag(); }) } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - if ((i & mask.ctrl_mask) == mask.ctrl_mask) { - auto m = i + mask.obj_mask; - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto this_res = std::conj(bra[i]) * ket[i] * me; - this_res += std::conj(bra[j]) * ket[j] * e; - this_res += std::conj(bra[k]) * ket[k] * e; - this_res += std::conj(bra[m]) * ket[m] * me; - res_real += this_res.real(); - res_imag += this_res.imag(); - } + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + if ((i & mask.ctrl_mask) == mask.ctrl_mask) { + auto m = i + mask.obj_mask; + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto this_res = std::conj(bra[i]) * ket[i] * me; + this_res += std::conj(bra[j]) * ket[j] * e; + this_res += std::conj(bra[k]) * ket[k] * e; + this_res += std::conj(bra[m]) * ket[m] * me; + res_real += this_res.real(); + res_imag += this_res.imag(); + } }) } if (will_free_bra) { @@ -938,8 +924,8 @@ auto CPUVectorPolicyBase::ExpectDiffRzz(const qs_data_p_t& template auto CPUVectorPolicyBase::ExpectDiffSWAPalpha(const qs_data_p_t& bra_out, const qs_data_p_t& ket_out, const qbits_t& objs, - const qbits_t& ctrls, calc_type val, index_t dim) - -> qs_data_t { + const qbits_t& ctrls, calc_type val, + index_t dim) -> qs_data_t { auto bra = bra_out; auto ket = ket_out; bool will_free_bra = false, will_free_ket = false; @@ -958,37 +944,35 @@ auto CPUVectorPolicyBase::ExpectDiffSWAPalpha(const qs_dat calc_type res_real = 0, res_imag = 0; if (!mask.ctrl_mask) { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v01 = a * ket[j] + b * ket[k]; - auto v10 = a * ket[k] + b * ket[j]; - auto this_res = std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - res_real += this_res.real(); - res_imag += this_res.imag(); + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v01 = a * ket[j] + b * ket[k]; + auto v10 = a * ket[k] + b * ket[j]; + auto this_res = std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + res_real += this_res.real(); + res_imag += this_res.imag(); }) } else { THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t l = 0; l < static_cast(dim / 4); l++) { - index_t i; - SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, - mask.obj_high_mask, mask.obj_rev_high_mask, l, i); - if ((i & mask.ctrl_mask) == mask.ctrl_mask) { - auto j = i + mask.obj_min_mask; - auto k = i + mask.obj_max_mask; - auto v01 = a * ket[j] + b * ket[k]; - auto v10 = a * ket[k] + b * ket[j]; - auto this_res = std::conj(bra[j]) * v01; - this_res += std::conj(bra[k]) * v10; - res_real += this_res.real(); - res_imag += this_res.imag(); - } + index_t i; + SHIFT_BIT_TWO(mask.obj_low_mask, mask.obj_rev_low_mask, mask.obj_high_mask, mask.obj_rev_high_mask, l, i); + if ((i & mask.ctrl_mask) == mask.ctrl_mask) { + auto j = i + mask.obj_min_mask; + auto k = i + mask.obj_max_mask; + auto v01 = a * ket[j] + b * ket[k]; + auto v10 = a * ket[k] + b * ket[j]; + auto this_res = std::conj(bra[j]) * v01; + this_res += std::conj(bra[k]) * v10; + res_real += this_res.real(); + res_imag += this_res.imag(); + } }) } if (will_free_bra) { @@ -1006,4 +990,4 @@ template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; #endif -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_matrix_gate.cpp b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_matrix_gate.cpp index f4cd148ea..04f48a5d1 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_matrix_gate.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_matrix_gate.cpp @@ -24,7 +24,7 @@ # include "simulator/vector/detail/cpu_vector_arm_float_policy.h" #endif #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void CPUVectorPolicyBase::ApplyNQubitsMatrix(const qs_data_p_t& src_out, qs_data_p_t* des_p, const qbits_t& objs, const qbits_t& ctrls, @@ -214,4 +214,4 @@ template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; #endif -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_other_gate.cpp b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_other_gate.cpp index 0742bf58b..22ae1a628 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_other_gate.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_other_gate.cpp @@ -26,7 +26,7 @@ #endif #include "ops/gates.h" #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void CPUVectorPolicyBase::ApplyH(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, index_t dim) { @@ -64,4 +64,4 @@ template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; #endif -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_policy.cpp b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_policy.cpp index b9054bd67..1f8add7cd 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_policy.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_policy.cpp @@ -22,7 +22,7 @@ #include "config/details/macros.h" #include "config/openmp.h" #include "config/type_promotion.h" -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "core/utils.h" #include "math/pr/parameter_resolver.h" #include "simulator/utils.h" @@ -34,7 +34,7 @@ # include "simulator/vector/detail/cpu_vector_arm_float_policy.h" #endif #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template auto CPUVectorPolicyBase::InitState(index_t dim, bool zero_state) -> qs_data_p_t { if (dim == 0 || dim > (~static_cast(0))) { @@ -101,8 +101,7 @@ auto CPUVectorPolicyBase::Copy(const qs_data_p_t& qs, inde qs_data_p_t out = nullptr; if (qs != nullptr) { out = derived::InitState(dim, false); - THRESHOLD_OMP_FOR( - dim, DimTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { out[i] = qs[i]; }) + THRESHOLD_OMP_FOR(dim, DimTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { out[i] = qs[i]; }) } return out; }; @@ -111,8 +110,7 @@ template auto CPUVectorPolicyBase::GetQS(const qs_data_p_t& qs, index_t dim) -> VT { VT out(dim); if (qs != nullptr) { - THRESHOLD_OMP_FOR( - dim, DimTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { out[i] = qs[i]; }) + THRESHOLD_OMP_FOR(dim, DimTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { out[i] = qs[i]; }) } else { out[0] = 1.0; } @@ -128,14 +126,13 @@ void CPUVectorPolicyBase::SetQS(qs_data_p_t* qs_p, const V if (qs == nullptr) { qs = derived::InitState(dim, false); } - THRESHOLD_OMP_FOR( - dim, DimTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { qs[i] = qs_out[i]; }) + THRESHOLD_OMP_FOR(dim, DimTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { qs[i] = qs_out[i]; }) } template auto CPUVectorPolicyBase::ApplyTerms(qs_data_p_t* qs_p, - const std::vector>& ham, index_t dim) - -> qs_data_p_t { + const std::vector>& ham, + index_t dim) -> qs_data_p_t { auto& qs = (*qs_p); if (qs == nullptr) { qs = derived::InitState(dim); @@ -235,7 +232,7 @@ auto CPUVectorPolicyBase::ExpectationOfTerms(const qs_data calc_type res_real = 0, res_imag = 0; // clang-format off THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, + QUAFU_DO_PRAGMA(omp parallel for reduction(+:res_real, res_imag) schedule(static)), dim, DimTh, for (omp::idx_t i = 0; i < static_cast(dim); i++) { auto j = (i ^ mask_f); if (i <= j) { @@ -269,18 +266,18 @@ auto CPUVectorPolicyBase::GroundStateOfZZs(const std::map::max(); auto dim = static_cast(1) << n_qubits; THRESHOLD_OMP( - MQ_DO_PRAGMA(omp parallel for reduction(min:result) schedule(static)), dim, DimTh, - for (omp::idx_t i = 0; i < (static_cast(1) << n_qubits); i++) { - calc_type ith_energy = 0; - for (auto& [mask, coeff] : masks_value) { - if (CountOne(i & mask) & 1) { - ith_energy -= coeff; - } else { - ith_energy += coeff; - } - } - result = std::min(result, ith_energy); - }); + QUAFU_DO_PRAGMA(omp parallel for reduction(min:result) schedule(static)), dim, DimTh, + for (omp::idx_t i = 0; i < (static_cast(1) << n_qubits); i++) { + calc_type ith_energy = 0; + for (auto& [mask, coeff] : masks_value) { + if (CountOne(i & mask) & 1) { + ith_energy -= coeff; + } else { + ith_energy += coeff; + } + } + result = std::min(result, ith_energy); + }); return result; } @@ -341,4 +338,4 @@ template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; #endif -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_rot_pauli.cpp b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_rot_pauli.cpp index 1f6d42fe1..3a14ced1f 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_rot_pauli.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_rot_pauli.cpp @@ -25,7 +25,7 @@ # include "simulator/vector/detail/cpu_vector_arm_float_policy.h" #endif #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { constexpr int ROT_PAULI_FACTOR = 2; template void CPUVectorPolicyBase::ApplyRxx(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, @@ -546,4 +546,4 @@ template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; #endif -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_swap_like.cpp b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_swap_like.cpp index 54c7ddc9b..9c45a286c 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_swap_like.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_swap_like.cpp @@ -26,7 +26,7 @@ # include "simulator/vector/detail/cpu_vector_arm_float_policy.h" #endif #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void CPUVectorPolicyBase::ApplySWAP(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, index_t dim) { @@ -194,4 +194,4 @@ template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; #endif -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_x_like.cpp b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_x_like.cpp index 367f01dcb..9694cb08b 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_x_like.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_x_like.cpp @@ -24,7 +24,7 @@ # include "simulator/vector/detail/cpu_vector_arm_float_policy.h" #endif #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void CPUVectorPolicyBase::ApplyXLike(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, qs_data_t v1, qs_data_t v2, index_t dim) { @@ -74,4 +74,4 @@ template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; #endif -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_z_like.cpp b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_z_like.cpp index 9caee52c1..3d2556e44 100644 --- a/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_z_like.cpp +++ b/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_z_like.cpp @@ -24,7 +24,7 @@ # include "simulator/vector/detail/cpu_vector_arm_float_policy.h" #endif #include "simulator/vector/detail/cpu_vector_policy.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void CPUVectorPolicyBase::ApplyZLike(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, qs_data_t val, index_t dim) { @@ -151,4 +151,4 @@ template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; template struct CPUVectorPolicyBase; #endif -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/gpu/CMakeLists.txt b/ccsrc/lib/simulator/vector/detail/gpu/CMakeLists.txt index 4637cf1c7..bb54c9064 100644 --- a/ccsrc/lib/simulator/vector/detail/gpu/CMakeLists.txt +++ b/ccsrc/lib/simulator/vector/detail/gpu/CMakeLists.txt @@ -19,7 +19,7 @@ # lint_cmake: -whitespace/indent target_sources( - mqsim_vector_gpu + quafusim_vector_gpu PRIVATE ${CMAKE_CURRENT_LIST_DIR}/gpu_vector_core_x_like.cu ${CMAKE_CURRENT_LIST_DIR}/gpu_vector_core_condition.cu ${CMAKE_CURRENT_LIST_DIR}/gpu_vector_core_dot_like.cu diff --git a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_condition.cu b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_condition.cu index 9a624be01..b7d61f5a9 100644 --- a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_condition.cu +++ b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_condition.cu @@ -24,7 +24,7 @@ #include "thrust/functional.h" #include "thrust/inner_product.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template template @@ -155,4 +155,4 @@ auto GPUVectorPolicyBase::ConditionalCollect(const qs_data template struct GPUVectorPolicyBase; template struct GPUVectorPolicyBase; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_dot_like.cu b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_dot_like.cu index d5256195e..2e6f21cf9 100644 --- a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_dot_like.cu +++ b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_dot_like.cu @@ -25,7 +25,7 @@ #include "thrust/functional.h" #include "thrust/inner_product.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template auto GPUVectorPolicyBase::Vdot(const qs_data_p_t& bra, const qs_data_p_t& ket, index_t dim) -> py_qs_data_t { @@ -271,4 +271,4 @@ auto GPUVectorPolicyBase::ExpectationOfCsr( template struct GPUVectorPolicyBase; template struct GPUVectorPolicyBase; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_gate_expect.cu b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_gate_expect.cu index 36bd0e497..c06b7dbbf 100644 --- a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_gate_expect.cu +++ b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_gate_expect.cu @@ -25,7 +25,7 @@ #include "thrust/functional.h" #include "thrust/inner_product.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template auto GPUVectorPolicyBase::ExpectDiffRPS(const qs_data_p_t& bra_out, const qs_data_p_t& ket_out, const PauliMask& mask, Index ctrl_mask, calc_type val, @@ -1145,4 +1145,4 @@ auto GPUVectorPolicyBase::ExpectDiffSWAPalpha(const qs_dat template struct GPUVectorPolicyBase; template struct GPUVectorPolicyBase; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_matrix_gate.cu b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_matrix_gate.cu index 1b5cc13a7..c4a0a49a4 100644 --- a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_matrix_gate.cu +++ b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_matrix_gate.cu @@ -24,7 +24,7 @@ #include "thrust/device_vector.h" #include "thrust/functional.h" #include "thrust/inner_product.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void GPUVectorPolicyBase::ApplyNQubitsMatrix(const qs_data_p_t& src_out, qs_data_p_t* des_p, const qbits_t& objs, const qbits_t& ctrls, @@ -258,4 +258,4 @@ void GPUVectorPolicyBase::ApplyMatrixGate(const qs_data_p_ template struct GPUVectorPolicyBase; template struct GPUVectorPolicyBase; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_other_gate.cu b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_other_gate.cu index 635ecbede..9bcdd7292 100644 --- a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_other_gate.cu +++ b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_other_gate.cu @@ -25,7 +25,7 @@ #include "thrust/functional.h" #include "thrust/inner_product.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void GPUVectorPolicyBase::ApplyH(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, @@ -61,4 +61,4 @@ void GPUVectorPolicyBase::ApplyGP(qs_data_p_t* qs_p, qbit_ template struct GPUVectorPolicyBase; template struct GPUVectorPolicyBase; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_policy.cu b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_policy.cu index 5da11cada..d0ad5f4c9 100644 --- a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_policy.cu +++ b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_policy.cu @@ -29,7 +29,7 @@ #include "thrust/functional.h" #include "thrust/inner_product.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template auto GPUVectorPolicyBase::InitState(index_t dim, bool zero_state) -> qs_data_p_t { qs_data_p_t qs; @@ -386,4 +386,4 @@ VT GPUVectorPolicyBase::LowerBound(const VT; template struct GPUVectorPolicyBase; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_rot_pauli.cu b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_rot_pauli.cu index d7f4d7c0c..68ee9a4d3 100644 --- a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_rot_pauli.cu +++ b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_rot_pauli.cu @@ -24,7 +24,7 @@ #include "thrust/functional.h" #include "thrust/inner_product.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void GPUVectorPolicyBase::ApplyRPS(qs_data_p_t* qs_p, const PauliMask& mask, Index ctrl_mask, calc_type val, index_t dim, bool diff) { @@ -590,4 +590,4 @@ void GPUVectorPolicyBase::ApplyGivens(qs_data_p_t* qs_p, c template struct GPUVectorPolicyBase; template struct GPUVectorPolicyBase; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_swap_like.cu b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_swap_like.cu index ac79ce38d..0af3700ed 100644 --- a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_swap_like.cu +++ b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_swap_like.cu @@ -24,7 +24,7 @@ #include "thrust/functional.h" #include "thrust/inner_product.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void GPUVectorPolicyBase::ApplySWAP(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, @@ -194,4 +194,4 @@ void GPUVectorPolicyBase::ApplySWAPalpha(qs_data_p_t* qs_p template struct GPUVectorPolicyBase; template struct GPUVectorPolicyBase; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_x_like.cu b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_x_like.cu index fc536568e..b816e479d 100644 --- a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_x_like.cu +++ b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_x_like.cu @@ -24,7 +24,7 @@ #include "thrust/functional.h" #include "thrust/inner_product.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void GPUVectorPolicyBase::ApplyXLike(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, qs_data_t v1, qs_data_t v2, index_t dim) { @@ -74,4 +74,4 @@ void GPUVectorPolicyBase::ApplyY(qs_data_p_t* qs_p, const template struct GPUVectorPolicyBase; template struct GPUVectorPolicyBase; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_z_like.cu b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_z_like.cu index cee7e0e6f..2a94b304d 100644 --- a/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_z_like.cu +++ b/ccsrc/lib/simulator/vector/detail/gpu/gpu_vector_core_z_like.cu @@ -24,7 +24,7 @@ #include "thrust/functional.h" #include "thrust/inner_product.h" -namespace mindquantum::sim::vector::detail { +namespace quafu::sim::vector::detail { template void GPUVectorPolicyBase::ApplyZLike(qs_data_p_t* qs_p, const qbits_t& objs, const qbits_t& ctrls, qs_data_t val, index_t dim) { @@ -154,4 +154,4 @@ void GPUVectorPolicyBase::ApplyILike(qs_data_p_t* qs_p, co template struct GPUVectorPolicyBase; template struct GPUVectorPolicyBase; -} // namespace mindquantum::sim::vector::detail +} // namespace quafu::sim::vector::detail diff --git a/ccsrc/lib/simulator/vector/detail/runtime/CMakeLists.txt b/ccsrc/lib/simulator/vector/detail/runtime/CMakeLists.txt index 9ec562dad..38edec474 100644 --- a/ccsrc/lib/simulator/vector/detail/runtime/CMakeLists.txt +++ b/ccsrc/lib/simulator/vector/detail/runtime/CMakeLists.txt @@ -18,5 +18,5 @@ # lint_cmake: -whitespace/indent -target_sources(mqrt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/cmd.cpp ${CMAKE_CURRENT_LIST_DIR}/mqrt.cpp +target_sources(quafurt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/cmd.cpp ${CMAKE_CURRENT_LIST_DIR}/quafurt.cpp ${CMAKE_CURRENT_LIST_DIR}/utils.cpp) diff --git a/ccsrc/lib/simulator/vector/detail/runtime/cmd.cpp b/ccsrc/lib/simulator/vector/detail/runtime/cmd.cpp index 3a745fd62..e0cf6bf0a 100644 --- a/ccsrc/lib/simulator/vector/detail/runtime/cmd.cpp +++ b/ccsrc/lib/simulator/vector/detail/runtime/cmd.cpp @@ -32,7 +32,7 @@ #include "simulator/vector/vector_state.h" constexpr int MAX_SHOTS = 100000; -namespace mindquantum::sim::rt { +namespace quafu::sim::rt { int cmd(const std::vector &args) { if (args.size() < 4) { throw std::runtime_error("You should set n_qubits and random seed when running simulator."); @@ -236,4 +236,4 @@ int cmd_file(const char *filename) { cmd(cmds); return 0; } -} // namespace mindquantum::sim::rt +} // namespace quafu::sim::rt diff --git a/ccsrc/lib/simulator/vector/detail/runtime/mqrt.cpp b/ccsrc/lib/simulator/vector/detail/runtime/quafurt.cpp similarity index 95% rename from ccsrc/lib/simulator/vector/detail/runtime/mqrt.cpp rename to ccsrc/lib/simulator/vector/detail/runtime/quafurt.cpp index 663ad3aae..b8eb5a274 100644 --- a/ccsrc/lib/simulator/vector/detail/runtime/mqrt.cpp +++ b/ccsrc/lib/simulator/vector/detail/runtime/quafurt.cpp @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) { return 0; } if (args[1] == "cmd") { - return mindquantum::sim::rt::cmd(args); + return quafu::sim::rt::cmd(args); } throw std::runtime_error("First arg is runtime type, should be 'cmd'."); } diff --git a/ccsrc/lib/simulator/vector/detail/runtime/utils.cpp b/ccsrc/lib/simulator/vector/detail/runtime/utils.cpp index c754ff459..2fb008cc5 100644 --- a/ccsrc/lib/simulator/vector/detail/runtime/utils.cpp +++ b/ccsrc/lib/simulator/vector/detail/runtime/utils.cpp @@ -16,7 +16,7 @@ #include "simulator/vector/runtime/utils.h" -namespace mindquantum::sim::rt { +namespace quafu::sim::rt { std::tuple convert_int(const std::string &s, int64_t limit, bool raise_error) { char *p = nullptr; Index converted = strtol(s.c_str(), &p, 10); @@ -47,4 +47,4 @@ std::tuple convert_double(const std::string &s, bool raise_error) } return {true, converted}; } -} // namespace mindquantum::sim::rt +} // namespace quafu::sim::rt diff --git a/ccsrc/python/CMakeLists.txt b/ccsrc/python/CMakeLists.txt index b2fa5403d..371256875 100644 --- a/ccsrc/python/CMakeLists.txt +++ b/ccsrc/python/CMakeLists.txt @@ -21,7 +21,7 @@ add_subdirectory(core) # ============================================================================== add_subdirectory(algorithm) -add_subdirectory(mqbackend) +add_subdirectory(quafubackend) add_subdirectory(simulator) add_subdirectory(device) add_subdirectory(math) diff --git a/ccsrc/python/algorithm/CMakeLists.txt b/ccsrc/python/algorithm/CMakeLists.txt index 66da5c23b..729d54519 100644 --- a/ccsrc/python/algorithm/CMakeLists.txt +++ b/ccsrc/python/algorithm/CMakeLists.txt @@ -19,8 +19,8 @@ if(ENABLE_CUDA) pybind11_add_module(_qaia_sb MODULE ${CMAKE_CURRENT_SOURCE_DIR}/lib/_qaia_sb.cu - OUTPUT_HINT "${MQ_PYTHON_PACKAGE_NAME}") + OUTPUT_HINT "${QUAFU_PYTHON_PACKAGE_NAME}") force_at_least_cxx17_workaround(_qaia_sb) - target_link_libraries(_qaia_sb PUBLIC mq_python_core qaia_sb_gpu) + target_link_libraries(_qaia_sb PUBLIC quafu_python_core qaia_sb_gpu) set_target_properties(_qaia_sb PROPERTIES CUDA_RUNTIME_LIBRARY $,Static,Shared>) endif() diff --git a/ccsrc/python/algorithm/lib/_qaia_sb.cu b/ccsrc/python/algorithm/lib/_qaia_sb.cu index b2567733d..5b7ceaa9a 100644 --- a/ccsrc/python/algorithm/lib/_qaia_sb.cu +++ b/ccsrc/python/algorithm/lib/_qaia_sb.cu @@ -35,11 +35,11 @@ #include "config/constexpr_type_name.h" #include "config/format/std_complex.h" #include "config/type_traits.h" -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" namespace py = pybind11; using namespace pybind11::literals; // NOLINT(build/namespaces_literals) -using mindquantum::Index; +using quafu::Index; template void sb_update(const py::object& csr, const py::array_t& x, const py::array_t& h, int B, float xi, @@ -59,7 +59,7 @@ void sb_update(const py::object& csr, const py::array_t& x, const py::ar int nrows = shape[0].cast(); int ncols = shape[1].cast(); int N = nrows; - mindquantum::sparse::CsrBase csr_matrix(N, nnz, raw_indptr, raw_indices, raw_data); + quafu::sparse::CsrBase csr_matrix(N, nnz, raw_indptr, raw_indices, raw_data); double* raw_x = static_cast(x.request().ptr); int x_size = x.size(); @@ -68,16 +68,16 @@ void sb_update(const py::object& csr, const py::array_t& x, const py::ar + "), but got length " + std::to_string(x_size)); } - mindquantum::algorithm::qaia::detail::Para paras(B, xi, delta, dt, n_iter); + quafu::algorithm::qaia::detail::Para paras(B, xi, delta, dt, n_iter); double* raw_h = static_cast(h.request().ptr); int h_size = h.size(); - mindquantum::algorithm::qaia::detail::SBUpdater::update(csr_matrix, raw_x, paras, raw_h, h_size); + quafu::algorithm::qaia::detail::SBUpdater::update(csr_matrix, raw_x, paras, raw_h, h_size); } PYBIND11_MODULE(_qaia_sb, module) { - module.def("cuda_init", mindquantum::algorithm::qaia::detail::SBBase::cublas_warmup, "warmup cuBLAS"); + module.def("cuda_init", quafu::algorithm::qaia::detail::SBBase::cublas_warmup, "warmup cuBLAS"); module.def("bsb_update_h_int8", &sb_update<0, int8_t, true>, "BSB update func(int8_t) with h"); module.def("bsb_update_h_half", &sb_update<0, half, true>, "BSB update func(half) with h"); module.def("dsb_update_h_int8", &sb_update<1, int8_t, true>, "DSB update func(int8_t) with h"); diff --git a/ccsrc/python/core/CMakeLists.txt b/ccsrc/python/core/CMakeLists.txt index 2abc81e7a..caa6dd107 100644 --- a/ccsrc/python/core/CMakeLists.txt +++ b/ccsrc/python/core/CMakeLists.txt @@ -16,11 +16,11 @@ # # ============================================================================== -add_library(mq_python_core INTERFACE) -target_include_directories(mq_python_core INTERFACE $ - $) +add_library(quafu_python_core INTERFACE) +target_include_directories(quafu_python_core INTERFACE $ + $) -install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/python DESTINATION ${MQ_INSTALL_INCLUDEDIR}) -append_to_property(mq_install_targets GLOBAL mq_python_core) +install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/python DESTINATION ${QUAFU_INSTALL_INCLUDEDIR}) +append_to_property(quafu_install_targets GLOBAL quafu_python_core) # ============================================================================== diff --git a/ccsrc/python/core/include/python/core/sparse/csrhdmatrix.h b/ccsrc/python/core/include/python/core/sparse/csrhdmatrix.h index 7ed54feb2..eb4b5d80c 100644 --- a/ccsrc/python/core/include/python/core/sparse/csrhdmatrix.h +++ b/ccsrc/python/core/include/python/core/sparse/csrhdmatrix.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_PYTHON_CSRHDMATRIX_HPP -#define MQ_PYTHON_CSRHDMATRIX_HPP +#ifndef QUAFU_PYTHON_CSRHDMATRIX_HPP +#define QUAFU_PYTHON_CSRHDMATRIX_HPP #include #include @@ -23,7 +23,7 @@ #include "core/sparse/csrhdmatrix.h" -namespace mindquantum::python { +namespace quafu::python { template struct CsrHdMatrix : sparse::CsrHdMatrix { using sparse::CsrHdMatrix::CsrHdMatrix; @@ -52,6 +52,6 @@ struct CsrHdMatrix : sparse::CsrHdMatrix { } } }; -} // namespace mindquantum::python +} // namespace quafu::python -#endif /* MQ_PYTHON_CSRHDMATRIX_HPP */ +#endif /* QUAFU_PYTHON_CSRHDMATRIX_HPP */ diff --git a/ccsrc/python/device/CMakeLists.txt b/ccsrc/python/device/CMakeLists.txt index d88ac7276..e8566a903 100644 --- a/ccsrc/python/device/CMakeLists.txt +++ b/ccsrc/python/device/CMakeLists.txt @@ -16,11 +16,11 @@ # # ============================================================================== -add_library(mq_python_device INTERFACE) -target_include_directories(mq_python_device INTERFACE $ - $) +add_library(quafu_python_device INTERFACE) +target_include_directories(quafu_python_device INTERFACE $ + $) -install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/python DESTINATION ${MQ_INSTALL_INCLUDEDIR}) -append_to_property(mq_install_targets GLOBAL mq_python_device) +install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/python DESTINATION ${QUAFU_INSTALL_INCLUDEDIR}) +append_to_property(quafu_install_targets GLOBAL quafu_python_device) # ============================================================================== diff --git a/ccsrc/python/device/include/python/device/binding.h b/ccsrc/python/device/include/python/device/binding.h index b9125e192..fb6193a0c 100644 --- a/ccsrc/python/device/include/python/device/binding.h +++ b/ccsrc/python/device/include/python/device/binding.h @@ -40,8 +40,8 @@ namespace py = pybind11; using namespace pybind11::literals; // NOLINT(build/namespaces_literals) -namespace mm = mindquantum::mapping; -namespace mindquantum::python { +namespace mm = quafu::mapping; +namespace quafu::python { void BindTopology(py::module &module) { // NOLINT(runtime/references) auto qnode_module = py::class_>(module, "QubitNode") @@ -118,25 +118,25 @@ void BindTopology(py::module &module) { // NOLINT(runtime/references) .def("n_row", &mm::GridQubits::NRow, "Get row number.") .def("n_col", &mm::GridQubits::NCol, "Get column number."); grid_qubits_m.doc() = "Grid qubit topology."; -} // namespace mindquantum::mapping +} // namespace quafu::mapping void BindQubitMapping(py::module &module) { // NOLINT(runtime/references) auto saber_m = py::class_>(module, "SABRE") - .def(py::init> &, + .def(py::init> &, const std::shared_ptr &>(), "Initialize saber method.") .def("solve", &mm::SABRE::Solve, "iter_num"_a, "W"_a, "delta1"_a, "delta2"_a, "Solve qubit mapping problem with saber method."); saber_m.doc() = "SABER method to implement qubit mapping task."; //------------------------------------------------------------------------------ - auto ha_saber_m = py::class_>(module, "MQ_SABRE") - .def(py::init> &, + auto ha_saber_m = py::class_>(module, "QUAFU_SABRE") + .def(py::init> &, const std::shared_ptr &, const std::vector, std::vector>> &>(), - "Initialize mq_saber method.") - .def("solve", &mm::MQ_SABRE::Solve, "W"_a, "alpha1"_a, "alpha2"_a, "alpha3"_a, + "Initialize quafu_saber method.") + .def("solve", &mm::QUAFU_SABRE::Solve, "W"_a, "alpha1"_a, "alpha2"_a, "alpha3"_a, "Solve qubit mapping problem with ha_saber method."); - ha_saber_m.doc() = "MQ_SABER method to implement qubit mapping task."; + ha_saber_m.doc() = "QUAFU_SABER method to implement qubit mapping task."; } -} // namespace mindquantum::python +} // namespace quafu::python #endif diff --git a/ccsrc/python/math/CMakeLists.txt b/ccsrc/python/math/CMakeLists.txt index 5ad17f57a..72b380918 100644 --- a/ccsrc/python/math/CMakeLists.txt +++ b/ccsrc/python/math/CMakeLists.txt @@ -19,11 +19,11 @@ # lint_cmake: -whitespace/indent add_library(_math_python_interface INTERFACE) target_include_directories(_math_python_interface INTERFACE $ - $) -append_to_property(mq_install_targets GLOBAL _math_python_interface) + $) +append_to_property(quafu_install_targets GLOBAL _math_python_interface) -install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/python DESTINATION ${MQ_INSTALL_INCLUDEDIR}) +install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/python DESTINATION ${QUAFU_INSTALL_INCLUDEDIR}) -pybind11_add_module(_math MODULE ${CMAKE_CURRENT_SOURCE_DIR}/lib/bind_math.cpp OUTPUT_HINT "${MQ_PYTHON_PACKAGE_NAME}") -force_at_least_cxx17_workaround(_mq_vector) -target_link_libraries(_math PUBLIC mq_math _math_python_interface) +pybind11_add_module(_math MODULE ${CMAKE_CURRENT_SOURCE_DIR}/lib/bind_math.cpp OUTPUT_HINT "${QUAFU_PYTHON_PACKAGE_NAME}") +force_at_least_cxx17_workaround(_quafu_vector) +target_link_libraries(_math PUBLIC quafu_math _math_python_interface) diff --git a/ccsrc/python/math/include/python/python_tensor.h b/ccsrc/python/math/include/python/python_tensor.h index e85a6e6a3..a824af72d 100644 --- a/ccsrc/python/math/include/python/python_tensor.h +++ b/ccsrc/python/math/include/python/python_tensor.h @@ -23,7 +23,7 @@ #include "math/tensor/ops_cpu/memory_operator.h" #include "math/tensor/tensor.h" -namespace mindquantum::python { +namespace quafu::python { template tensor::Tensor from_numpy(const pybind11::array_t &arr) { pybind11::buffer_info buf = arr.request(); @@ -32,5 +32,5 @@ tensor::Tensor from_numpy(const pybind11::array_t &arr) { } return tensor::ops::cpu::copy>(buf.ptr, buf.size); } -} // namespace mindquantum::python +} // namespace quafu::python #endif /* PYTHON_TENSOR_HPP_ */ diff --git a/ccsrc/python/math/lib/bind_math.cpp b/ccsrc/python/math/lib/bind_math.cpp index 05849b04c..ffbf62f5d 100644 --- a/ccsrc/python/math/lib/bind_math.cpp +++ b/ccsrc/python/math/lib/bind_math.cpp @@ -29,7 +29,7 @@ #include #include -#include "core/mq_base_types.h" +#include "core/quafu_base_types.h" #include "math/operators/fermion_operator_view.h" #include "math/operators/qubit_operator_view.h" #include "math/operators/sparsing.h" @@ -64,7 +64,7 @@ using namespace pybind11::literals; // NOLINT(build/namespaces_literals) .def(std::complex() op py::self) \ .def(std::complex() op py::self) -namespace mindquantum::python { +namespace quafu::python { void BindTensor(py::module &module) { // NOLINT(runtime/references) py::class_>(module, "Tensor", py::buffer_protocol()) .def(py::init<>()) @@ -183,9 +183,9 @@ void BindPR(py::module &module) { // NOLINT(runtime/references) .def("update", &pr_t::Update); } struct IdxArrayWrapper { - mindquantum::index_t *data = nullptr; - mindquantum::index_t dim; - IdxArrayWrapper(mindquantum::index_t *data, mindquantum::index_t dim) : data(data), dim(dim) { + quafu::index_t *data = nullptr; + quafu::index_t dim; + IdxArrayWrapper(quafu::index_t *data, quafu::index_t dim) : data(data), dim(dim) { } IdxArrayWrapper() = default; }; @@ -195,15 +195,15 @@ void BindCsrMatrix(py::module &module) { // NOLINT(runtime/references) py::class_>(module, "idx_array_wrapper", py::buffer_protocol()) .def(py::init<>()) .def_buffer([](IdxArrayWrapper &t) -> py::buffer_info { - auto format = py::format_descriptor::format(); + auto format = py::format_descriptor::format(); // clang-format off return py::buffer_info( t.data, - sizeof(mindquantum::index_t), + sizeof(quafu::index_t), format, 1, {t.dim, }, - {sizeof(mindquantum::index_t)}); + {sizeof(quafu::index_t)}); // clang-format on }); py::class_>(module, "csr_matrix") @@ -337,44 +337,40 @@ void BindTransform(py::module &module) { // NOLINT(runtime/references) module.def("ternary_tree", &operators::transform::ternary_tree, "ops"_a, "n_qubits"_a); module.def("bravyi_kitaev_superfast", &operators::transform::bravyi_kitaev_superfast, "ops"_a); } -} // namespace mindquantum::python +} // namespace quafu::python #undef BIND_TENSOR_OPS #undef BIND_TENSOR_OPS_REV PYBIND11_MODULE(_math, m) { - m.doc() = "MindQuantum Math module."; + m.doc() = "quafu Math module."; auto dtype_id = py::enum_(m, "dtype") .value("complex64", tensor::TDtype::Complex64) .value("complex128", tensor::TDtype::Complex128) .value("float32", tensor::TDtype::Float32) .value("float64", tensor::TDtype::Float64); dtype_id.attr("__repr__") = pybind11::cpp_function( - [](const tensor::TDtype &dtype) -> pybind11::str { return "mindquantum." + tensor::dtype_to_string(dtype); }, + [](const tensor::TDtype &dtype) -> pybind11::str { return "quafu." + tensor::dtype_to_string(dtype); }, pybind11::name("name"), pybind11::is_method(dtype_id)); dtype_id.attr("__str__") = pybind11::cpp_function( - [](const tensor::TDtype &dtype) -> pybind11::str { return "mindquantum." + tensor::dtype_to_string(dtype); }, + [](const tensor::TDtype &dtype) -> pybind11::str { return "quafu." + tensor::dtype_to_string(dtype); }, pybind11::name("name"), pybind11::is_method(dtype_id)); auto device_id = py::enum_(m, "device").value("CPU", tensor::TDevice::CPU).value("GPU", tensor::TDevice::GPU); device_id.attr("__repr__") = pybind11::cpp_function( - [](const tensor::TDevice &device) -> pybind11::str { - return "mindquantum." + tensor::device_to_string(device); - }, + [](const tensor::TDevice &device) -> pybind11::str { return "quafu." + tensor::device_to_string(device); }, pybind11::name("name"), pybind11::is_method(device_id)); device_id.attr("__str__") = pybind11::cpp_function( - [](const tensor::TDevice &device) -> pybind11::str { - return "mindquantum." + tensor::device_to_string(device); - }, + [](const tensor::TDevice &device) -> pybind11::str { return "quafu." + tensor::device_to_string(device); }, pybind11::name("name"), pybind11::is_method(device_id)); - py::module tensor_module = m.def_submodule("tensor", "MindQuantum Tensor module."); - mindquantum::python::BindTensor(tensor_module); - mindquantum::python::BindCsrMatrix(tensor_module); + py::module tensor_module = m.def_submodule("tensor", "quafu Tensor module."); + quafu::python::BindTensor(tensor_module); + quafu::python::BindCsrMatrix(tensor_module); - py::module pr_module = m.def_submodule("pr", "MindQuantum ParameterResolver module."); - mindquantum::python::BindPR(pr_module); + py::module pr_module = m.def_submodule("pr", "quafu ParameterResolver module."); + quafu::python::BindPR(pr_module); - py::module ops_module = m.def_submodule("ops", "MindQuantum Operators module."); - mindquantum::python::BindQubitOperator(ops_module); - mindquantum::python::BindTransform(ops_module); + py::module ops_module = m.def_submodule("ops", "quafu Operators module."); + quafu::python::BindQubitOperator(ops_module); + quafu::python::BindTransform(ops_module); } diff --git a/ccsrc/python/mqbackend/lib/binding.cc b/ccsrc/python/mqbackend/lib/binding.cc deleted file mode 100644 index 1eff2a207..000000000 --- a/ccsrc/python/mqbackend/lib/binding.cc +++ /dev/null @@ -1,340 +0,0 @@ -/** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "python/device/binding.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config/constexpr_type_name.h" -#include "config/format/std_complex.h" -#include "config/type_traits.h" -#include "core/mq_base_types.h" -#include "core/sparse/algo.h" -#include "core/sparse/csrhdmatrix.h" -#include "core/sparse/paulimat.h" -#include "math/pr/parameter_resolver.h" -#include "math/tensor/matrix.h" -#include "ops/basic_gate.h" -#include "ops/gate_id.h" -#include "ops/gates.h" -#include "ops/hamiltonian.h" - -#include "python/core/sparse/csrhdmatrix.h" -#include "python/ops/basic_gate.h" -#include "python/ops/build_env.h" - -namespace py = pybind11; - -using namespace pybind11::literals; // NOLINT(build/namespaces_literals) - -namespace mindquantum::python { -void init_logging(pybind11::module &module); // NOLINT(runtime/references)NOLINT - -void BindTypeIndependentGate(py::module &module) { // NOLINT(runtime/references) - using mindquantum::Index; - using mindquantum::qbits_t; - using mindquantum::VT; - py::class_>( - module, "MeasureGate") - .def(py::init(), "name"_a, "obj_qubits"_a) - .def(py::init(), "name"_a, "obj_qubits"_a, "reset_to"_a); - py::class_>(module, "IGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, "XGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, "YGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, "ZGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>( - module, "GroupedPauli") - .def(py::init(), "paulis"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "HGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, - "ISWAPGate") - .def(py::init(), "daggered"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, - "SWAPGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, "SGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, - "SdagGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, "SXGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, - "SXdagGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, "TGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, - "TdagGate") - .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>( - module, "PauliChannel") - .def(py::init(), "px"_a, "py"_a, "pz"_a, - "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, "GroupedPauliChannel") - .def(py::init &, const qbits_t &, const qbits_t &>(), "probs"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "DepolarizingChannel") - .def(py::init(), "p"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "AmplitudeDampingChannel") - .def(py::init(), "daggered"_a, "damping_coeff"_a, - "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, "PhaseDampingChannel") - .def(py::init(), "damping_coeff"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "ThermalRelaxationChannel") - .def(py::init(), "t1"_a, "t2"_a, "gate_time"_a, - "obj_qubits"_a, "ctrl_qubits"_a = VT()); -} - -void BindTypeDependentGate(py::module &module) { // NOLINT(runtime/references) - using mindquantum::CT; - using mindquantum::Index; - using mindquantum::qbits_t; - using mindquantum::VT; - using mindquantum::VVT; - using parameter::ParameterResolver; - py::class_>(module, "RXGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "RYGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "RZGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "RxxGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "RyyGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "RzzGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "RxyGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "RxzGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "RyzGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, - "GivensGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>( - module, "RotPauliString") - .def(py::init(), - "pauli_string"_a, "pr"_a, "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>( - module, "SWAPalphaGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "GPGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "PSGate") - .def(py::init(), "pr"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); - py::class_>(module, "u3") - .def(py::init(), - "theta"_a, "phi"_a, "lambda"_a, "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, "rn") - .def(py::init(), - "alpha"_a, "beta"_a, "gamma"_a, "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, "fsim") - .def(py::init(), - "theta"_a, "phi"_a, "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>( - module, "KrausChannel") - .def(py::init>> &, const qbits_t &, const qbits_t &>(), "kraus_operator_set"_a, - "obj_qubits"_a, "ctrl_qubits"_a = VT()); - py::class_>(module, - "CustomGate") - .def( - py::init(), - "name"_a, "m_addr"_a, "dm_addr"_a, "dim"_a, "pr"_a, "obj_qubits"_a, "ctrl_qubits"_a = VT()) - .def(py::init(), "name"_a, "mat"_a, - "obj_qubits"_a, "ctrl_qubits"_a); - py::class_>(module, "CustomTwoParamGate") - .def(py::init(), - "name"_a, "m_addr"_a, "dm_addr1"_a, "dm_addr2"_a, "dim"_a, "pr1"_a, "pr2"_a, "obj_qubits"_a, - "ctrl_qubits"_a = VT()); -} -template -auto BindOther(py::module &module) { - using namespace pybind11::literals; // NOLINT(build/namespaces_literals) - using mindquantum::CT; - using mindquantum::Hamiltonian; - using mindquantum::Index; - using mindquantum::PauliTerm; - using mindquantum::VS; - using mindquantum::VT; - using mindquantum::VVT; - using mindquantum::python::CsrHdMatrix; - using parameter::ParameterResolver; - // matrix - - // parameter resolver - using mindquantum::sparse::Csr_Plus_Csr; - using mindquantum::sparse::GetPauliMat; - using mindquantum::sparse::PauliMat; - using mindquantum::sparse::PauliMatToCsrHdMatrix; - using mindquantum::sparse::SparseHamiltonian; - using mindquantum::sparse::TransposeCsrHdMatrix; - // pauli mat - py::class_, std::shared_ptr>>(module, "pauli_mat") - .def(py::init<>()) - .def(py::init &, Index>()) - .def_readonly("n_qubits", &PauliMat::n_qubits_) - .def_readonly("dim", &PauliMat::dim_) - .def_readwrite("coeff", &PauliMat::p_) - .def("PrintInfo", &PauliMat::PrintInfo); - - module.def("get_pauli_mat", &GetPauliMat); - - // // csr_hd_matrix - py::class_, std::shared_ptr>>(module, "csr_hd_matrix") - .def(py::init<>()) - .def(py::init, py::array_t, py::array_t>>()) - .def("PrintInfo", &CsrHdMatrix::PrintInfo); - module.def("csr_plus_csr", &Csr_Plus_Csr); - module.def("transpose_csr_hd_matrix", &TransposeCsrHdMatrix); - module.def("pauli_mat_to_csr_hd_matrix", &PauliMatToCsrHdMatrix); - - // hamiltonian - py::class_, std::shared_ptr>>(module, "hamiltonian") - .def(py::init<>()) - .def(py::init> &>()) - .def(py::init> &, Index>()) - .def(py::init>, Index>()) - .def_readwrite("how_to", &Hamiltonian::how_to_) - .def_readwrite("n_qubits", &Hamiltonian::n_qubits_) - .def_readwrite("ham", &Hamiltonian::ham_) - .def_readwrite("ham_sparse_main", &Hamiltonian::ham_sparse_main_) - .def_readwrite("ham_sparse_second", &Hamiltonian::ham_sparse_second_); - module.def("sparse_hamiltonian", &SparseHamiltonian); -} -} // namespace mindquantum::python - -// Interface with python -PYBIND11_MODULE(mqbackend, m) { - m.doc() = "MindQuantum C++ plugin"; - - py::module logging = m.def_submodule("logging", "MindQuantum-C++ logging module"); - mindquantum::python::init_logging(logging); - - auto gate_id = py::enum_(m, "GateID") - .value("I", mindquantum::GateID::I) - .value("X", mindquantum::GateID::X) - .value("Y", mindquantum::GateID::Y) - .value("Z", mindquantum::GateID::Z) - .value("RX", mindquantum::GateID::RX) - .value("RY", mindquantum::GateID::RY) - .value("RZ", mindquantum::GateID::RZ) - .value("Rxx", mindquantum::GateID::Rxx) - .value("Ryy", mindquantum::GateID::Ryy) - .value("Rzz", mindquantum::GateID::Rzz) - .value("Givens", mindquantum::GateID::Givens) - .value("Rn", mindquantum::GateID::Rn) - .value("H", mindquantum::GateID::H) - .value("SWAP", mindquantum::GateID::SWAP) - .value("ISWAP", mindquantum::GateID::ISWAP) - .value("SWAPalpha", mindquantum::GateID::SWAPalpha) - .value("T", mindquantum::GateID::T) - .value("Tdag", mindquantum::GateID::Tdag) - .value("S", mindquantum::GateID::S) - .value("Sdag", mindquantum::GateID::Sdag) - .value("SX", mindquantum::GateID::SX) - .value("SXdag", mindquantum::GateID::SXdag) - .value("CNOT", mindquantum::GateID::CNOT) - .value("CZ", mindquantum::GateID::CZ) - .value("PauliString", mindquantum::GateID::PauliString) - .value("RotPauliString", mindquantum::GateID::RPS) - .value("GP", mindquantum::GateID::GP) - .value("PS", mindquantum::GateID::PS) - .value("U3", mindquantum::GateID::U3) - .value("FSim", mindquantum::GateID::FSim) - .value("M", mindquantum::GateID::M) - .value("PL", mindquantum::GateID::PL) - .value("DEP", mindquantum::GateID::DEP) - .value("AD", mindquantum::GateID::AD) - .value("PD", mindquantum::GateID::PD) - .value("KRAUS", mindquantum::GateID::KRAUS) - .value("TR", mindquantum::GateID::TR) - .value("CUSTOM", mindquantum::GateID::CUSTOM) - .value("CUSTOM_TWO_PARAM", mindquantum::GateID::CUSTOM_TWO_PARAM); - gate_id.attr("__repr__") = pybind11::cpp_function( - [](const mindquantum::GateID &id) -> pybind11::str { return fmt::format("GateID.{}", id); }, - pybind11::name("name"), pybind11::is_method(gate_id)); - gate_id.attr("__str__") = pybind11::cpp_function( - [](const mindquantum::GateID &id) -> pybind11::str { return fmt::format("{}", id); }, pybind11::name("name"), - pybind11::is_method(gate_id)); - - m.attr("EQ_TOLERANCE") = py::float_(1.e-8); - - py::module gate = m.def_submodule("gate", "MindQuantum-C++ gate"); - py::class_>(gate, "BasicGate") - .def(py::init()) - .def("get_id", &mindquantum::BasicGate::GetID) - .def("get_obj_qubits", &mindquantum::BasicGate::GetObjQubits) - .def("get_ctrl_qubits", &mindquantum::BasicGate::GetCtrlQubits); - mindquantum::python::BindTypeIndependentGate(gate); - mindquantum::python::BindTypeDependentGate(gate); - - py::module mqbackend_double = m.def_submodule("double", "MindQuantum-C++ double backend"); - mindquantum::python::BindOther(mqbackend_double); - py::module mqbackend_float = m.def_submodule("float", "MindQuantum-C++ double backend"); - mindquantum::python::BindOther(mqbackend_float); - - py::module c = m.def_submodule("c", "pybind11 c++ env"); - mindquantum::BindPybind11Env(c); - - py::module device = m.def_submodule("device", "Quantum device module"); - mindquantum::python::BindTopology(device); - mindquantum::python::BindQubitMapping(device); -} diff --git a/ccsrc/python/mqbackend/CMakeLists.txt b/ccsrc/python/quafubackend/CMakeLists.txt similarity index 65% rename from ccsrc/python/mqbackend/CMakeLists.txt rename to ccsrc/python/quafubackend/CMakeLists.txt index 8cfc871a4..5991f636c 100644 --- a/ccsrc/python/mqbackend/CMakeLists.txt +++ b/ccsrc/python/quafubackend/CMakeLists.txt @@ -18,14 +18,14 @@ # lint_cmake: -whitespace/indent,-whitespace/extra -add_library(mqbackend_python_interface INTERFACE) -target_include_directories(mqbackend_python_interface INTERFACE $ - $) -append_to_property(mq_install_targets GLOBAL mqbackend_python_interface) +add_library(quafubackend_python_interface INTERFACE) +target_include_directories(quafubackend_python_interface INTERFACE $ + $) +append_to_property(quafu_install_targets GLOBAL quafubackend_python_interface) # ------------------------------------------------------------------------------ -install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/python DESTINATION ${MQ_INSTALL_INCLUDEDIR}) +install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/python DESTINATION ${QUAFU_INSTALL_INCLUDEDIR}) # ============================================================================== @@ -46,24 +46,24 @@ if(_lto_workaround) endif() pybind11_add_module( - mqbackend MODULE + quafubackend MODULE OUTPUT_HINT - "${MQ_PYTHON_PACKAGE_NAME}" ${CMAKE_CURRENT_LIST_DIR}/lib/binding.cc ${CMAKE_CURRENT_LIST_DIR}/lib/logging.cpp + "${QUAFU_PYTHON_PACKAGE_NAME}" ${CMAKE_CURRENT_LIST_DIR}/lib/binding.cc ${CMAKE_CURRENT_LIST_DIR}/lib/logging.cpp ${CMAKE_CURRENT_LIST_DIR}/lib/build_env.cpp) if(_lto_workaround) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) endif() -target_include_directories(mqbackend PRIVATE $) +target_include_directories(quafubackend PRIVATE $) -force_at_least_cxx17_workaround(mqbackend) -target_link_libraries(mqbackend PUBLIC ${MQ_OPENMP_TARGET} mq_base mq_python_core mqbackend_python_interface - mq_python_device) +force_at_least_cxx17_workaround(quafubackend) +target_link_libraries(quafubackend PUBLIC ${QUAFU_OPENMP_TARGET} quafu_base quafu_python_core quafubackend_python_interface + quafu_python_device) # ------------------------------------------------------------------------------ -get_target_property(_mqbackend_output_dir mqbackend LIBRARY_OUTPUT_DIRECTORY) -if(NOT _mqbackend_output_dir) - set(_mqbackend_output_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +get_target_property(_quafubackend_output_dir quafubackend LIBRARY_OUTPUT_DIRECTORY) +if(NOT _quafubackend_output_dir) + set(_quafubackend_output_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") endif() diff --git a/ccsrc/python/mqbackend/include/python/ops/basic_gate.h b/ccsrc/python/quafubackend/include/python/ops/basic_gate.h similarity index 89% rename from ccsrc/python/mqbackend/include/python/ops/basic_gate.h rename to ccsrc/python/quafubackend/include/python/ops/basic_gate.h index 3cb28e58a..7416a7568 100644 --- a/ccsrc/python/mqbackend/include/python/ops/basic_gate.h +++ b/ccsrc/python/quafubackend/include/python/ops/basic_gate.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_PYTHON_BASIC_GATE_HPP -#define MQ_PYTHON_BASIC_GATE_HPP +#ifndef QUAFU_PYTHON_BASIC_GATE_HPP +#define QUAFU_PYTHON_BASIC_GATE_HPP #include #include @@ -25,7 +25,7 @@ #include "ops/basic_gate.h" -namespace mindquantum::python { +namespace quafu::python { template inline VVT> CastArray(const pybind11::object& fun, T theta) { pybind11::array_t> a = fun(theta); @@ -47,6 +47,6 @@ inline VVT> CastArray(const pybind11::object& fun, T theta) { } return matrix; } -} // namespace mindquantum::python +} // namespace quafu::python -#endif /* MQ_PYTHON_BASIC_GATE_HPP */ +#endif /* QUAFU_PYTHON_BASIC_GATE_HPP */ diff --git a/ccsrc/python/mqbackend/include/python/ops/build_env.h b/ccsrc/python/quafubackend/include/python/ops/build_env.h similarity index 88% rename from ccsrc/python/mqbackend/include/python/ops/build_env.h rename to ccsrc/python/quafubackend/include/python/ops/build_env.h index e53a28e15..906194aa3 100644 --- a/ccsrc/python/mqbackend/include/python/ops/build_env.h +++ b/ccsrc/python/quafubackend/include/python/ops/build_env.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_PYTHON_BUILD_ENV_HPP_ -#define MQ_PYTHON_BUILD_ENV_HPP_ +#ifndef QUAFU_PYTHON_BUILD_ENV_HPP_ +#define QUAFU_PYTHON_BUILD_ENV_HPP_ #include #include @@ -23,10 +23,10 @@ #include namespace py = pybind11; -namespace mindquantum { +namespace quafu { std::string GetBuildABI(); std::string GetCompilerType(); std::string GetStdLib(); void BindPybind11Env(py::module &module); // NOLINT(runtime/references) -} // namespace mindquantum +} // namespace quafu #endif diff --git a/ccsrc/python/mqbackend/lib/CPPLINT.cfg b/ccsrc/python/quafubackend/lib/CPPLINT.cfg similarity index 100% rename from ccsrc/python/mqbackend/lib/CPPLINT.cfg rename to ccsrc/python/quafubackend/lib/CPPLINT.cfg diff --git a/ccsrc/python/quafubackend/lib/binding.cc b/ccsrc/python/quafubackend/lib/binding.cc new file mode 100644 index 000000000..4a6f8a86b --- /dev/null +++ b/ccsrc/python/quafubackend/lib/binding.cc @@ -0,0 +1,328 @@ +/** + * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "python/device/binding.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "config/constexpr_type_name.h" +#include "config/format/std_complex.h" +#include "config/type_traits.h" +#include "core/quafu_base_types.h" +#include "core/sparse/algo.h" +#include "core/sparse/csrhdmatrix.h" +#include "core/sparse/paulimat.h" +#include "math/pr/parameter_resolver.h" +#include "math/tensor/matrix.h" +#include "ops/basic_gate.h" +#include "ops/gate_id.h" +#include "ops/gates.h" +#include "ops/hamiltonian.h" + +#include "python/core/sparse/csrhdmatrix.h" +#include "python/ops/basic_gate.h" +#include "python/ops/build_env.h" + +namespace py = pybind11; + +using namespace pybind11::literals; // NOLINT(build/namespaces_literals) + +namespace quafu::python { +void init_logging(pybind11::module &module); // NOLINT(runtime/references)NOLINT + +void BindTypeIndependentGate(py::module &module) { // NOLINT(runtime/references) + using quafu::Index; + using quafu::qbits_t; + using quafu::VT; + py::class_>(module, "MeasureGate") + .def(py::init(), "name"_a, "obj_qubits"_a) + .def(py::init(), "name"_a, "obj_qubits"_a, "reset_to"_a); + py::class_>(module, "IGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "XGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "YGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "ZGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "GroupedPauli") + .def(py::init(), "paulis"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "HGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "ISWAPGate") + .def(py::init(), "daggered"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "SWAPGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "SGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "SdagGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "SXGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "SXdagGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "TGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "TdagGate") + .def(py::init(), "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "PauliChannel") + .def(py::init(), "px"_a, "py"_a, "pz"_a, + "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>( + module, "GroupedPauliChannel") + .def(py::init &, const qbits_t &, const qbits_t &>(), "probs"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>( + module, "DepolarizingChannel") + .def(py::init(), "p"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>( + module, "AmplitudeDampingChannel") + .def(py::init(), "daggered"_a, "damping_coeff"_a, + "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>( + module, "PhaseDampingChannel") + .def(py::init(), "damping_coeff"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>( + module, "ThermalRelaxationChannel") + .def(py::init(), "t1"_a, "t2"_a, "gate_time"_a, + "obj_qubits"_a, "ctrl_qubits"_a = VT()); +} + +void BindTypeDependentGate(py::module &module) { // NOLINT(runtime/references) + using parameter::ParameterResolver; + using quafu::CT; + using quafu::Index; + using quafu::qbits_t; + using quafu::VT; + using quafu::VVT; + py::class_>(module, "RXGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "RYGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "RZGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "RxxGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "RyyGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "RzzGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "RxyGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "RxzGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "RyzGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "GivensGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, + "RotPauliString") + .def(py::init(), + "pauli_string"_a, "pr"_a, "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "SWAPalphaGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "GPGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "PSGate") + .def(py::init(), "pr"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); + py::class_>(module, "u3") + .def(py::init(), + "theta"_a, "phi"_a, "lambda"_a, "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "rn") + .def(py::init(), + "alpha"_a, "beta"_a, "gamma"_a, "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "fsim") + .def(py::init(), + "theta"_a, "phi"_a, "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "KrausChannel") + .def(py::init>> &, const qbits_t &, const qbits_t &>(), "kraus_operator_set"_a, + "obj_qubits"_a, "ctrl_qubits"_a = VT()); + py::class_>(module, "CustomGate") + .def( + py::init(), + "name"_a, "m_addr"_a, "dm_addr"_a, "dim"_a, "pr"_a, "obj_qubits"_a, "ctrl_qubits"_a = VT()) + .def(py::init(), "name"_a, "mat"_a, + "obj_qubits"_a, "ctrl_qubits"_a); + py::class_>( + module, "CustomTwoParamGate") + .def(py::init(), + "name"_a, "m_addr"_a, "dm_addr1"_a, "dm_addr2"_a, "dim"_a, "pr1"_a, "pr2"_a, "obj_qubits"_a, + "ctrl_qubits"_a = VT()); +} +template +auto BindOther(py::module &module) { + using namespace pybind11::literals; // NOLINT(build/namespaces_literals) + using parameter::ParameterResolver; + using quafu::CT; + using quafu::Hamiltonian; + using quafu::Index; + using quafu::PauliTerm; + using quafu::VS; + using quafu::VT; + using quafu::VVT; + using quafu::python::CsrHdMatrix; + // matrix + + // parameter resolver + using quafu::sparse::Csr_Plus_Csr; + using quafu::sparse::GetPauliMat; + using quafu::sparse::PauliMat; + using quafu::sparse::PauliMatToCsrHdMatrix; + using quafu::sparse::SparseHamiltonian; + using quafu::sparse::TransposeCsrHdMatrix; + // pauli mat + py::class_, std::shared_ptr>>(module, "pauli_mat") + .def(py::init<>()) + .def(py::init &, Index>()) + .def_readonly("n_qubits", &PauliMat::n_qubits_) + .def_readonly("dim", &PauliMat::dim_) + .def_readwrite("coeff", &PauliMat::p_) + .def("PrintInfo", &PauliMat::PrintInfo); + + module.def("get_pauli_mat", &GetPauliMat); + + // // csr_hd_matrix + py::class_, std::shared_ptr>>(module, "csr_hd_matrix") + .def(py::init<>()) + .def(py::init, py::array_t, py::array_t>>()) + .def("PrintInfo", &CsrHdMatrix::PrintInfo); + module.def("csr_plus_csr", &Csr_Plus_Csr); + module.def("transpose_csr_hd_matrix", &TransposeCsrHdMatrix); + module.def("pauli_mat_to_csr_hd_matrix", &PauliMatToCsrHdMatrix); + + // hamiltonian + py::class_, std::shared_ptr>>(module, "hamiltonian") + .def(py::init<>()) + .def(py::init> &>()) + .def(py::init> &, Index>()) + .def(py::init>, Index>()) + .def_readwrite("how_to", &Hamiltonian::how_to_) + .def_readwrite("n_qubits", &Hamiltonian::n_qubits_) + .def_readwrite("ham", &Hamiltonian::ham_) + .def_readwrite("ham_sparse_main", &Hamiltonian::ham_sparse_main_) + .def_readwrite("ham_sparse_second", &Hamiltonian::ham_sparse_second_); + module.def("sparse_hamiltonian", &SparseHamiltonian); +} +} // namespace quafu::python + +// Interface with python +PYBIND11_MODULE(quafubackend, m) { + m.doc() = "quafu C++ plugin"; + + py::module logging = m.def_submodule("logging", "quafu-C++ logging module"); + quafu::python::init_logging(logging); + + auto gate_id = py::enum_(m, "GateID") + .value("I", quafu::GateID::I) + .value("X", quafu::GateID::X) + .value("Y", quafu::GateID::Y) + .value("Z", quafu::GateID::Z) + .value("RX", quafu::GateID::RX) + .value("RY", quafu::GateID::RY) + .value("RZ", quafu::GateID::RZ) + .value("Rxx", quafu::GateID::Rxx) + .value("Ryy", quafu::GateID::Ryy) + .value("Rzz", quafu::GateID::Rzz) + .value("Givens", quafu::GateID::Givens) + .value("Rn", quafu::GateID::Rn) + .value("H", quafu::GateID::H) + .value("SWAP", quafu::GateID::SWAP) + .value("ISWAP", quafu::GateID::ISWAP) + .value("SWAPalpha", quafu::GateID::SWAPalpha) + .value("T", quafu::GateID::T) + .value("Tdag", quafu::GateID::Tdag) + .value("S", quafu::GateID::S) + .value("Sdag", quafu::GateID::Sdag) + .value("SX", quafu::GateID::SX) + .value("SXdag", quafu::GateID::SXdag) + .value("CNOT", quafu::GateID::CNOT) + .value("CZ", quafu::GateID::CZ) + .value("PauliString", quafu::GateID::PauliString) + .value("RotPauliString", quafu::GateID::RPS) + .value("GP", quafu::GateID::GP) + .value("PS", quafu::GateID::PS) + .value("U3", quafu::GateID::U3) + .value("FSim", quafu::GateID::FSim) + .value("M", quafu::GateID::M) + .value("PL", quafu::GateID::PL) + .value("DEP", quafu::GateID::DEP) + .value("AD", quafu::GateID::AD) + .value("PD", quafu::GateID::PD) + .value("KRAUS", quafu::GateID::KRAUS) + .value("TR", quafu::GateID::TR) + .value("CUSTOM", quafu::GateID::CUSTOM) + .value("CUSTOM_TWO_PARAM", quafu::GateID::CUSTOM_TWO_PARAM); + gate_id.attr("__repr__") = pybind11::cpp_function( + [](const quafu::GateID &id) -> pybind11::str { return fmt::format("GateID.{}", id); }, pybind11::name("name"), + pybind11::is_method(gate_id)); + gate_id.attr("__str__") = pybind11::cpp_function( + [](const quafu::GateID &id) -> pybind11::str { return fmt::format("{}", id); }, pybind11::name("name"), + pybind11::is_method(gate_id)); + + m.attr("EQ_TOLERANCE") = py::float_(1.e-8); + + py::module gate = m.def_submodule("gate", "quafu-C++ gate"); + py::class_>(gate, "BasicGate") + .def(py::init()) + .def("get_id", &quafu::BasicGate::GetID) + .def("get_obj_qubits", &quafu::BasicGate::GetObjQubits) + .def("get_ctrl_qubits", &quafu::BasicGate::GetCtrlQubits); + quafu::python::BindTypeIndependentGate(gate); + quafu::python::BindTypeDependentGate(gate); + + py::module quafubackend_double = m.def_submodule("double", "quafu-C++ double backend"); + quafu::python::BindOther(quafubackend_double); + py::module quafubackend_float = m.def_submodule("float", "quafu-C++ double backend"); + quafu::python::BindOther(quafubackend_float); + + py::module c = m.def_submodule("c", "pybind11 c++ env"); + quafu::BindPybind11Env(c); + + py::module device = m.def_submodule("device", "Quantum device module"); + quafu::python::BindTopology(device); + quafu::python::BindQubitMapping(device); +} diff --git a/ccsrc/python/mqbackend/lib/build_env.cpp b/ccsrc/python/quafubackend/lib/build_env.cpp similarity index 92% rename from ccsrc/python/mqbackend/lib/build_env.cpp rename to ccsrc/python/quafubackend/lib/build_env.cpp index 5f255381f..dc9e4d473 100644 --- a/ccsrc/python/mqbackend/lib/build_env.cpp +++ b/ccsrc/python/quafubackend/lib/build_env.cpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef MQ_PYTHON_BUILD_ENV_HPP_ -#define MQ_PYTHON_BUILD_ENV_HPP_ +#ifndef QUAFU_PYTHON_BUILD_ENV_HPP_ +#define QUAFU_PYTHON_BUILD_ENV_HPP_ #include "python/ops/build_env.h" #include @@ -27,7 +27,7 @@ #define macro_value_to_string(x) macro_to_string(x) namespace py = pybind11; -namespace mindquantum { +namespace quafu { std::string GetBuildABI() { auto abi = macro_value_to_string(PYBIND11_BUILD_ABI); abi.erase(std::remove(abi.begin(), abi.end(), '\"'), abi.end()); @@ -49,5 +49,5 @@ void BindPybind11Env(py::module &module) { module.def("compiler_type", &GetCompilerType); module.def("std_lib", &GetStdLib); } -} // namespace mindquantum +} // namespace quafu #endif diff --git a/ccsrc/python/mqbackend/lib/logging.cpp b/ccsrc/python/quafubackend/lib/logging.cpp similarity index 94% rename from ccsrc/python/mqbackend/lib/logging.cpp rename to ccsrc/python/quafubackend/lib/logging.cpp index 4432054bb..4c66fe0e2 100644 --- a/ccsrc/python/mqbackend/lib/logging.cpp +++ b/ccsrc/python/quafubackend/lib/logging.cpp @@ -45,7 +45,7 @@ void enable_logging(spdlog::level::level_enum level) { #ifdef ENABLE_LOGGING spdlog::default_logger()->set_level(level); #else - std::cout << "Cannot enable logging because this version of MindQuantum was not compiled with it!\n"; + std::cout << "Cannot enable logging because this version of quafu was not compiled with it!\n"; #endif // ENABLE_LOGGING current_level_ = level; } @@ -54,12 +54,12 @@ void disable_logging() { #ifdef ENABLE_LOGGING spdlog::default_logger()->set_level(spdlog::level::off); #else - std::cout << "Cannot disable logging because this version of MindQuantum was not compiled with it!\n"; + std::cout << "Cannot disable logging because this version of quafu was not compiled with it!\n"; #endif // ENABLE_LOGGING current_level_ = spdlog::level::off; } -namespace mindquantum::python { +namespace quafu::python { void init_logging(pybind11::module& module) { using namespace pybind11::literals; @@ -81,4 +81,4 @@ void init_logging(pybind11::module& module) { disable_logging(); #endif // ENABLE_LOGGING } -} // namespace mindquantum::python +} // namespace quafu::python diff --git a/ccsrc/python/simulator/CMakeLists.txt b/ccsrc/python/simulator/CMakeLists.txt index ba1c6636c..4d51c78d4 100644 --- a/ccsrc/python/simulator/CMakeLists.txt +++ b/ccsrc/python/simulator/CMakeLists.txt @@ -18,35 +18,35 @@ # lint_cmake: -whitespace/indent -pybind11_add_module(_mq_vector MODULE ${CMAKE_CURRENT_SOURCE_DIR}/lib/_mq_vector.cpp - OUTPUT_HINT "${MQ_PYTHON_PACKAGE_NAME}") +pybind11_add_module(_quafu_vector MODULE ${CMAKE_CURRENT_SOURCE_DIR}/lib/_quafu_vector.cpp + OUTPUT_HINT "${QUAFU_PYTHON_PACKAGE_NAME}") -target_include_directories(_mq_vector PRIVATE $) -force_at_least_cxx17_workaround(_mq_vector) -target_link_libraries(_mq_vector PUBLIC mq_python_core mqsim_vector_cpu mqsim_stabilizer) +target_include_directories(_quafu_vector PRIVATE $) +force_at_least_cxx17_workaround(_quafu_vector) +target_link_libraries(_quafu_vector PUBLIC quafu_python_core quafusim_vector_cpu quafusim_stabilizer) # ------------------------------------------------------------------------------ if(ENABLE_CUDA) - pybind11_add_module(_mq_vector_gpu MODULE ${CMAKE_CURRENT_SOURCE_DIR}/lib/_mq_vector_gpu.cu - OUTPUT_HINT "${MQ_PYTHON_PACKAGE_NAME}") + pybind11_add_module(_quafu_vector_gpu MODULE ${CMAKE_CURRENT_SOURCE_DIR}/lib/_quafu_vector_gpu.cu + OUTPUT_HINT "${QUAFU_PYTHON_PACKAGE_NAME}") - target_include_directories(_mq_vector_gpu PRIVATE $) - force_at_least_cxx17_workaround(_mq_vector_gpu) - target_link_libraries(_mq_vector_gpu PUBLIC mq_python_core mqsim_vector_gpu) - set_target_properties(_mq_vector_gpu PROPERTIES CUDA_RUNTIME_LIBRARY $,Static,Shared>) + target_include_directories(_quafu_vector_gpu PRIVATE $) + force_at_least_cxx17_workaround(_quafu_vector_gpu) + target_link_libraries(_quafu_vector_gpu PUBLIC quafu_python_core quafusim_vector_gpu) + set_target_properties(_quafu_vector_gpu PROPERTIES CUDA_RUNTIME_LIBRARY $,Static,Shared>) endif() # ------------------------------------------------------------------------------ # lint_cmake: -whitespace/indent -pybind11_add_module(_mq_matrix MODULE ${CMAKE_CURRENT_SOURCE_DIR}/lib/_mq_matrix.cpp - OUTPUT_HINT "${MQ_PYTHON_PACKAGE_NAME}") +pybind11_add_module(_quafu_matrix MODULE ${CMAKE_CURRENT_SOURCE_DIR}/lib/_quafu_matrix.cpp + OUTPUT_HINT "${QUAFU_PYTHON_PACKAGE_NAME}") -target_include_directories(_mq_matrix PRIVATE $) -force_at_least_cxx17_workaround(_mq_matrix) -target_link_libraries(_mq_matrix PUBLIC mq_python_core mqsim_densitymatrix_cpu) +target_include_directories(_quafu_matrix PRIVATE $) +force_at_least_cxx17_workaround(_quafu_matrix) +target_link_libraries(_quafu_matrix PUBLIC quafu_python_core quafusim_densitymatrix_cpu) # ------------------------------------------------------------------------------ diff --git a/ccsrc/python/simulator/include/CMakeLists.txt b/ccsrc/python/simulator/include/CMakeLists.txt index 235f8154d..28a20d8c3 100644 --- a/ccsrc/python/simulator/include/CMakeLists.txt +++ b/ccsrc/python/simulator/include/CMakeLists.txt @@ -18,7 +18,7 @@ add_library(bind_lib INTERFACE) target_include_directories(bind_lib INTERFACE $) -target_link_libraries(_mq_vector PUBLIC bind_lib) -target_link_libraries(_mq_matrix PUBLIC bind_lib) -append_to_property(mq_install_targets GLOBAL bind_lib) -install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/python DESTINATION ${MQ_INSTALL_INCLUDEDIR}) +target_link_libraries(_quafu_vector PUBLIC bind_lib) +target_link_libraries(_quafu_matrix PUBLIC bind_lib) +append_to_property(quafu_install_targets GLOBAL bind_lib) +install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/python DESTINATION ${QUAFU_INSTALL_INCLUDEDIR}) diff --git a/ccsrc/python/simulator/include/python/densitymatrix/bind_mat_state.h b/ccsrc/python/simulator/include/python/densitymatrix/bind_mat_state.h index 9dd99718e..3f0cf9622 100644 --- a/ccsrc/python/simulator/include/python/densitymatrix/bind_mat_state.h +++ b/ccsrc/python/simulator/include/python/densitymatrix/bind_mat_state.h @@ -44,7 +44,7 @@ template auto BindSim(pybind11::module& module, const std::string_view& name) { // NOLINT using namespace pybind11::literals; // NOLINT - using qbit_t = mindquantum::qbit_t; + using qbit_t = quafu::qbit_t; return pybind11::class_(module, name.data()) .def(pybind11::init(), "n_qubits"_a, "seed"_a = 42) diff --git a/ccsrc/python/simulator/include/python/vector/bind_vec_state.h b/ccsrc/python/simulator/include/python/vector/bind_vec_state.h index 4e7bc6472..8c2f4e026 100644 --- a/ccsrc/python/simulator/include/python/vector/bind_vec_state.h +++ b/ccsrc/python/simulator/include/python/vector/bind_vec_state.h @@ -46,7 +46,7 @@ template auto BindSim(pybind11::module& module, const std::string_view& name) { // NOLINT using namespace pybind11::literals; // NOLINT - using qbit_t = mindquantum::qbit_t; + using qbit_t = quafu::qbit_t; using calc_type = typename sim_t::calc_type; using circuit_t = typename sim_t::circuit_t; @@ -65,14 +65,14 @@ auto BindSim(pybind11::module& module, const std::string_view& name) { // NOLIN .def("sampling_measure_ending_without_noise", &sim_t::SamplingMeasurementEndingWithoutNoise) .def("get_circuit_matrix", &sim_t::GetCircuitMatrix) .def("get_expectation", - pybind11::overload_cast&, const circuit_t&, const circuit_t&, + pybind11::overload_cast&, const circuit_t&, const circuit_t&, const typename sim_t::derived_t&, const parameter::ParameterResolver&>( &sim_t::GetExpectation, pybind11::const_)) .def("get_expectation", - pybind11::overload_cast&, const circuit_t&, const circuit_t&, + pybind11::overload_cast&, const circuit_t&, const circuit_t&, const parameter::ParameterResolver&>(&sim_t::GetExpectation, pybind11::const_)) .def("get_expectation", - pybind11::overload_cast&, const circuit_t&, + pybind11::overload_cast&, const circuit_t&, const parameter::ParameterResolver&>(&sim_t::GetExpectation, pybind11::const_)) .def("qram_expectation_with_grad", &sim_t::QramExpectationWithGrad) .def("get_expectation_with_grad_multi_multi", &sim_t::GetExpectationWithGradMultiMulti) @@ -85,7 +85,7 @@ auto BindSim(pybind11::module& module, const std::string_view& name) { // NOLIN template auto BindBlas(pybind11::module& module) { // NOLINT using qs_policy_t = typename sim_t::qs_policy_t; - module.def("inner_product", mindquantum::sim::vector::detail::BLAS::InnerProduct); + module.def("inner_product", quafu::sim::vector::detail::BLAS::InnerProduct); } #endif diff --git a/ccsrc/python/simulator/lib/_mq_matrix.cpp b/ccsrc/python/simulator/lib/_quafu_matrix.cpp similarity index 63% rename from ccsrc/python/simulator/lib/_mq_matrix.cpp rename to ccsrc/python/simulator/lib/_quafu_matrix.cpp index a2b49ea4f..9fc5f3acd 100644 --- a/ccsrc/python/simulator/lib/_mq_matrix.cpp +++ b/ccsrc/python/simulator/lib/_quafu_matrix.cpp @@ -32,31 +32,31 @@ #include "python/densitymatrix/bind_mat_state.h" -PYBIND11_MODULE(_mq_matrix, module) { +PYBIND11_MODULE(_quafu_matrix, module) { #ifdef __CUDACC__ - using float_policy_t = mindquantum::sim::densitymatrix::detail::GPUDensityMatrixPolicyFloat; - using double_policy_t = mindquantum::sim::densitymatrix::detail::GPUDensityMatrixPolicyDouble; + using float_policy_t = quafu::sim::densitymatrix::detail::GPUDensityMatrixPolicyFloat; + using double_policy_t = quafu::sim::densitymatrix::detail::GPUDensityMatrixPolicyDouble; #elif defined(__x86_64__) - using float_policy_t = mindquantum::sim::densitymatrix::detail::CPUDensityMatrixPolicyAvxFloat; - using double_policy_t = mindquantum::sim::densitymatrix::detail::CPUDensityMatrixPolicyAvxDouble; + using float_policy_t = quafu::sim::densitymatrix::detail::CPUDensityMatrixPolicyAvxFloat; + using double_policy_t = quafu::sim::densitymatrix::detail::CPUDensityMatrixPolicyAvxDouble; #elif defined(__amd64) - using float_policy_t = mindquantum::sim::densitymatrix::detail::CPUDensityMatrixPolicyArmFloat; - using double_policy_t = mindquantum::sim::densitymatrix::detail::CPUDensityMatrixPolicyArmDouble; + using float_policy_t = quafu::sim::densitymatrix::detail::CPUDensityMatrixPolicyArmFloat; + using double_policy_t = quafu::sim::densitymatrix::detail::CPUDensityMatrixPolicyArmDouble; #endif // __CUDACC__ - using float_mat_sim = mindquantum::sim::densitymatrix::detail::DensityMatrixState; - using double_mat_sim = mindquantum::sim::densitymatrix::detail::DensityMatrixState; + using float_mat_sim = quafu::sim::densitymatrix::detail::DensityMatrixState; + using double_mat_sim = quafu::sim::densitymatrix::detail::DensityMatrixState; - module.doc() = "MindQuantum c++ density matrix state simulator."; + module.doc() = "quafu c++ density matrix state simulator."; pybind11::module float_sim = module.def_submodule("float", "float simulator"); pybind11::module double_sim = module.def_submodule("double", "double simulator"); - BindSim(float_sim, "mqmatrix") - .def("complex128", &float_mat_sim::astype) - .def("complex64", &float_mat_sim::astype) - .def("sim_name", [](const float_mat_sim& sim) { return "mqmatrix"; }); - BindSim(double_sim, "mqmatrix") - .def("complex128", &double_mat_sim::astype) - .def("complex64", &double_mat_sim::astype) - .def("sim_name", [](const double_mat_sim& sim) { return "mqmatrix"; }); + BindSim(float_sim, "quafumatrix") + .def("complex128", &float_mat_sim::astype) + .def("complex64", &float_mat_sim::astype) + .def("sim_name", [](const float_mat_sim& sim) { return "quafumatrix"; }); + BindSim(double_sim, "quafumatrix") + .def("complex128", &double_mat_sim::astype) + .def("complex64", &double_mat_sim::astype) + .def("sim_name", [](const double_mat_sim& sim) { return "quafumatrix"; }); } diff --git a/ccsrc/python/simulator/lib/_mq_vector.cpp b/ccsrc/python/simulator/lib/_quafu_vector.cpp similarity index 75% rename from ccsrc/python/simulator/lib/_mq_vector.cpp rename to ccsrc/python/simulator/lib/_quafu_vector.cpp index fe24795e7..e3e494dc7 100644 --- a/ccsrc/python/simulator/lib/_mq_vector.cpp +++ b/ccsrc/python/simulator/lib/_quafu_vector.cpp @@ -37,59 +37,59 @@ #include "python/vector/bind_vec_state.h" -PYBIND11_MODULE(_mq_vector, module) { +PYBIND11_MODULE(_quafu_vector, module) { using namespace pybind11::literals; // NOLINT - std::string sim_name = "mqvector"; + std::string sim_name = "quafuvector"; #ifdef __CUDACC__ - using float_policy_t = mindquantum::sim::vector::detail::GPUVectorPolicyFloat; - using double_policy_t = mindquantum::sim::vector::detail::GPUVectorPolicyDouble; - sim_name = "mqvector_gpu"; + using float_policy_t = quafu::sim::vector::detail::GPUVectorPolicyFloat; + using double_policy_t = quafu::sim::vector::detail::GPUVectorPolicyDouble; + sim_name = "quafuvector_gpu"; #elif defined(__x86_64__) - using float_policy_t = mindquantum::sim::vector::detail::CPUVectorPolicyAvxFloat; - using double_policy_t = mindquantum::sim::vector::detail::CPUVectorPolicyAvxDouble; + using float_policy_t = quafu::sim::vector::detail::CPUVectorPolicyAvxFloat; + using double_policy_t = quafu::sim::vector::detail::CPUVectorPolicyAvxDouble; #elif defined(__amd64) - using float_policy_t = mindquantum::sim::vector::detail::CPUVectorPolicyArmFloat; - using double_policy_t = mindquantum::sim::vector::detail::CPUVectorPolicyArmDouble; + using float_policy_t = quafu::sim::vector::detail::CPUVectorPolicyArmFloat; + using double_policy_t = quafu::sim::vector::detail::CPUVectorPolicyArmDouble; #endif // __CUDACC__ - using float_vec_sim = mindquantum::sim::vector::detail::VectorState; - using double_vec_sim = mindquantum::sim::vector::detail::VectorState; + using float_vec_sim = quafu::sim::vector::detail::VectorState; + using double_vec_sim = quafu::sim::vector::detail::VectorState; - module.doc() = "MindQuantum c++ vector state simulator."; + module.doc() = "quafu c++ vector state simulator."; pybind11::module float_sim = module.def_submodule("float", "float simulator"); pybind11::module double_sim = module.def_submodule("double", "double simulator"); BindSim(float_sim, sim_name) - .def("complex128", &float_vec_sim::astype) - .def("complex64", &float_vec_sim::astype) + .def("complex128", &float_vec_sim::astype) + .def("complex64", &float_vec_sim::astype) .def("sim_name", [](const float_vec_sim& sim) { #ifdef __CUDACC__ - return "mqvector_gpu"; + return "quafuvector_gpu"; #else - return "mqvector"; + return "quafuvector"; #endif }); BindSim(double_sim, sim_name) - .def("complex128", &double_vec_sim::astype) - .def("complex64", &double_vec_sim::astype) + .def("complex128", &double_vec_sim::astype) + .def("complex64", &double_vec_sim::astype) .def("sim_name", [](const double_vec_sim& sim) { #ifdef __CUDACC__ - return "mqvector_gpu"; + return "quafuvector_gpu"; #else - return "mqvector"; + return "quafuvector"; #endif }); - pybind11::module float_blas = float_sim.def_submodule("blas", "MindQuantum simulator algebra module."); - pybind11::module double_blas = double_sim.def_submodule("blas", "MindQuantum simulator algebra module."); + pybind11::module float_blas = float_sim.def_submodule("blas", "quafu simulator algebra module."); + pybind11::module double_blas = double_sim.def_submodule("blas", "quafu simulator algebra module."); BindBlas(float_blas); BindBlas(double_blas); module.def("ground_state_of_zs", &double_policy_t::GroundStateOfZZs, "masks_value"_a, "n_qubits"_a); - pybind11::module stabilizer = module.def_submodule("stabilizer", "MindQuantum stabilizer simulator."); + pybind11::module stabilizer = module.def_submodule("stabilizer", "quafu stabilizer simulator."); #ifndef __CUDACC__ - using namespace mindquantum::stabilizer; // NOLINT + using namespace quafu::stabilizer; // NOLINT pybind11::class_(stabilizer, "StabilizerTableau") .def(pybind11::init(), "n_qubits"_a, "seed"_a = 42) .def("copy", [](const StabilizerTableau& s) { return s; }) diff --git a/ccsrc/python/simulator/lib/_mq_vector_gpu.cu b/ccsrc/python/simulator/lib/_quafu_vector_gpu.cu similarity index 88% rename from ccsrc/python/simulator/lib/_mq_vector_gpu.cu rename to ccsrc/python/simulator/lib/_quafu_vector_gpu.cu index 34c25d831..85948cce8 100644 --- a/ccsrc/python/simulator/lib/_mq_vector_gpu.cu +++ b/ccsrc/python/simulator/lib/_quafu_vector_gpu.cu @@ -14,6 +14,6 @@ * limitations under the License. */ -#define _mq_vector _mq_vector_gpu +#define _quafu_vector _quafu_vector_gpu -#include "_mq_vector.cpp" // NOLINT +#include "_quafu_vector.cpp" // NOLINT diff --git a/cmake/cmake_config.h.in b/cmake/cmake_config.h.in index a92ba2e15..2b12a3fee 100644 --- a/cmake/cmake_config.h.in +++ b/cmake/cmake_config.h.in @@ -19,8 +19,8 @@ #define VERSION_INFO @VERSION_INFO @ -#cmakedefine01 MQ_HAS_ABSEIL_CPP +#cmakedefine01 QUAFU_HAS_ABSEIL_CPP -#cmakedefine01 MQ_HAS_LONG_DOUBLE +#cmakedefine01 QUAFU_HAS_LONG_DOUBLE #endif /* CMAKE_CONFIG_HPP_IN */ diff --git a/cmake/commands/debug_print.cmake b/cmake/commands/debug_print.cmake index 3b0c168c1..5acc3ec93 100644 --- a/cmake/commands/debug_print.cmake +++ b/cmake/commands/debug_print.cmake @@ -28,7 +28,7 @@ include_guard() function(debug_print mode) if(ENABLE_CMAKE_DEBUG OR MINDQUANTUM_DEBUG - OR mindquantum_DEBUG) + OR quafu_DEBUG) math(EXPR _argc "${ARGC} - 1") foreach(_idx RANGE 1 ${_argc} 1) set(_msg "${ARGV${_idx}}") diff --git a/cmake/commands/mq_config_macros.cmake b/cmake/commands/quafu_config_macros.cmake similarity index 66% rename from cmake/commands/mq_config_macros.cmake rename to cmake/commands/quafu_config_macros.cmake index 5104745c7..1995d493f 100644 --- a/cmake/commands/mq_config_macros.cmake +++ b/cmake/commands/quafu_config_macros.cmake @@ -21,42 +21,42 @@ include_guard() include(debug_print) # ~~~ -# Set some variables within the MindQuantum's installed configuration file. +# Set some variables within the quafu's installed configuration file. # -# mq_set( +# quafu_set( # ) # -# If a specified variable already exists, save its value and then restore it later by using mq_auto_unset. +# If a specified variable already exists, save its value and then restore it later by using quafu_auto_unset. # ~~~ -macro(mq_set var value) - list(APPEND _mq_variables ${var}) +macro(quafu_set var value) + list(APPEND _quafu_variables ${var}) if(DEFINED ${var}) - debug_print(STATUS "DEBUG: mq_set: ${var} defined, saving value to ${var}_old (${${var}})") + debug_print(STATUS "DEBUG: quafu_set: ${var} defined, saving value to ${var}_old (${${var}})") set(${var}_old ${${var}}) endif() if(NOT "${value}" STREQUAL "") - debug_print(STATUS "DEBUG: mq_set: ${var} defined to ${value}") + debug_print(STATUS "DEBUG: quafu_set: ${var} defined to ${value}") set(${var} "${value}") endif() endmacro() # ~~~ -# Automatically unset any changes made by all previous calls to mq_set_variable() +# Automatically unset any changes made by all previous calls to quafu_set_variable() # -# mq_unset_auto() +# quafu_unset_auto() # ~~~ -macro(mq_unset_auto) - foreach(_var ${_mq_variables}) +macro(quafu_unset_auto) + foreach(_var ${_quafu_variables}) if(DEFINED ${_var}) - debug_print(STATUS "DEBUG: mq_unset_auto: unsetting ${_var}") + debug_print(STATUS "DEBUG: quafu_unset_auto: unsetting ${_var}") unset(${_var}) endif() if(DEFINED ${_var}_old) - debug_print(STATUS "DEBUG: mq_unset_auto: ${_var}_old defined, restoring value of ${_var} (${${_var}_old})") + debug_print(STATUS "DEBUG: quafu_unset_auto: ${_var}_old defined, restoring value of ${_var} (${${_var}_old})") set(${_var} ${${_var}_old}) unset(${_var}_old) endif() endforeach() unset(_var) # NB: not required anymore for CMake >= 3.21 (see CMP0124) - unset(_mq_variables) + unset(_quafu_variables) endmacro() diff --git a/cmake/commands/mq_link_libraries.cmake b/cmake/commands/quafu_link_libraries.cmake similarity index 82% rename from cmake/commands/mq_link_libraries.cmake rename to cmake/commands/quafu_link_libraries.cmake index 846d87b85..93b904ed6 100644 --- a/cmake/commands/mq_link_libraries.cmake +++ b/cmake/commands/quafu_link_libraries.cmake @@ -25,19 +25,19 @@ include(is_language_enabled) # ~~~ # Add one or more link libraries to some of the language specific targets (see setup_languages()) # -# mq_link_libraries([NO_MQ_TARGET, NO_TRYCOMPILE_TARGET, NO_TRYCOMPILE_FLAGCHECK_TARGET] +# quafu_link_libraries([NO_QUAFU_TARGET, NO_TRYCOMPILE_TARGET, NO_TRYCOMPILE_FLAGCHECK_TARGET] # , [, ...]) # -# Always modify the _mindquantum target. If any of TRYCOMPILE, TRYCOMPILE_FLAGCHECK is also specified, then modify +# Always modify the _quafu target. If any of TRYCOMPILE, TRYCOMPILE_FLAGCHECK is also specified, then modify # the corresponding target. # ~~~ -function(mq_link_libraries) +function(quafu_link_libraries) cmake_parse_arguments(PARSE_ARGV 0 MLL "TRYCOMPILE;TRYCOMPILE_FLAGCHECK" "" "") foreach(lang C CXX CUDA NVCXX DPCXX) is_language_enabled(${lang} _enabled) if(_enabled) - target_link_libraries(${lang}_mindquantum INTERFACE "$<$:${MLL_UNPARSED_ARGUMENTS}>") + target_link_libraries(${lang}_quafu INTERFACE "$<$:${MLL_UNPARSED_ARGUMENTS}>") if(MLL_TRYCOMPILE) target_link_libraries(${lang}_try_compile INTERFACE "$<$:${MLL_UNPARSED_ARGUMENTS}>") endif() diff --git a/cmake/compiler_flags.cmake b/cmake/compiler_flags.cmake index 5ae52b239..79a652abe 100644 --- a/cmake/compiler_flags.cmake +++ b/cmake/compiler_flags.cmake @@ -123,14 +123,14 @@ if(ENABLE_CUDA) nvhpc_flagcheck_flags FLAGCHECK LANGS NVCXX FLAGS "--flagcheck" - NO_MQ_TARGET NO_TRYCOMPILE_TARGET) + NO_QUAFU_TARGET NO_TRYCOMPILE_TARGET) test_compile_option( nvhpc_cxx_standard_flags FLAGCHECK LANGS NVCXX FLAGS "-std=c++20 -std=c++17") - set(_flag -gpu=cuda${MQ_CUDA_VERSION}) + set(_flag -gpu=cuda${QUAFU_CUDA_VERSION}) test_compile_option( nvhpc_cuda_version_flags FLAGCHECK LANGS NVCXX @@ -161,9 +161,9 @@ if(ENABLE_CUDA) message(WARNING "NVHPC does not support ${_flag}. Proceed at your own risk!") endif() - if(TARGET NVCXX_mindquantum) + if(TARGET NVCXX_quafu) # For all the languages except NVCXX, use NVHPC's filename extension detection for the language - target_compile_options(NVCXX_mindquantum INTERFACE "$<$,\ + target_compile_options(NVCXX_quafu INTERFACE "$<$,\ $,$>,$>>:-x none>") endif() endif() @@ -210,19 +210,19 @@ if(X86_64) test_compile_option( intrin_flag LANGS C CXX DPCXX - NO_MQ_TARGET NO_TRYCOMPILE_TARGET NO_TRYCOMPILE_FLAGCHECK_TARGET + NO_QUAFU_TARGET NO_TRYCOMPILE_TARGET NO_TRYCOMPILE_FLAGCHECK_TARGET FLAGS "-mavx2 -xCORE-AVX2 /QxCORE-AVX2 /arch:AVX2") elseif(AARCH64) test_compile_option( intrin_flag LANGS C CXX DPCXX - NO_MQ_TARGET NO_TRYCOMPILE_TARGET NO_TRYCOMPILE_FLAGCHECK_TARGET + NO_QUAFU_TARGET NO_TRYCOMPILE_TARGET NO_TRYCOMPILE_FLAGCHECK_TARGET FLAGS "-march=armv8.5-a -march=armv8.4-a -march=armv8.3-a -march=armv8.2-a") endif() foreach(_lang C CXX DPCXX) if(TARGET intrin_flag_${_lang}) - append_to_property(mq_install_targets GLOBAL intrin_flag_${_lang}) + append_to_property(quafu_install_targets GLOBAL intrin_flag_${_lang}) endif() endforeach() @@ -307,19 +307,19 @@ if(VERSION_INFO MATCHES [=["(.*)\.dev[0-9]+"$]=]) endif() if(VERSION_INFO MATCHES [=["(.*)"]=]) - set(MQ_VERSION ${CMAKE_MATCH_1}) + set(QUAFU_VERSION ${CMAKE_MATCH_1}) else() - set(MQ_VERSION ${VERSION_INFO}) + set(QUAFU_VERSION ${VERSION_INFO}) endif() -if("${MQ_VERSION}" STREQUAL "" AND EXISTS "${PROJECT_SOURCE_DIR}/VERSION.txt") - file(STRINGS "${PROJECT_SOURCE_DIR}/VERSION.txt" MQ_VERSION) +if("${QUAFU_VERSION}" STREQUAL "" AND EXISTS "${PROJECT_SOURCE_DIR}/VERSION.txt") + file(STRINGS "${PROJECT_SOURCE_DIR}/VERSION.txt" QUAFU_VERSION) endif() -if("${MQ_VERSION}" STREQUAL "") - message(FATAL_ERROR "Unable to get MindQuantum version number!") +if("${QUAFU_VERSION}" STREQUAL "") + message(FATAL_ERROR "Unable to get quafu version number!") else() - message(STATUS "MindQuantum version: ${MQ_VERSION}") + message(STATUS "quafu version: ${QUAFU_VERSION}") endif() # -------------------------------------- @@ -328,12 +328,12 @@ include(compiler_test) # -------------------------------------- -mq_add_compile_definitions( - "$<$:MQ_MINDSPORE_CI>" +quafu_add_compile_definitions( + "$<$:QUAFU_MINDSPORE_CI>" "$<$:USE_OPENMP>" "$<$:USE_PARALLEL_STL>" - "$<$:MQ_LOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG>" - "$<$:MQ_LOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE>" + "$<$:QUAFU_LOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG>" + "$<$:QUAFU_LOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE>" "$<$:ENABLE_LOGGING>" "$<$,$>:_GLIBCXX_DEBUG>" "$<$,$>:_FORTIFY_SOURCE=2>") @@ -342,7 +342,7 @@ mq_add_compile_definitions( # Platform specific flags if(WIN32 AND Python_VERSION VERSION_LESS 3.9) - mq_add_compile_definitions(HAVE_SNPRINTF) + quafu_add_compile_definitions(HAVE_SNPRINTF) endif() if(MSVC) @@ -361,14 +361,14 @@ if(MSVC) string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}") endif() endif() - mq_add_compile_definitions(_USE_MATH_DEFINES _CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN - "$<$:_ITERATOR_DEBUG_LEVEL=${MQ_ITERATOR_DEBUG}>") + quafu_add_compile_definitions(_USE_MATH_DEFINES _CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN + "$<$:_ITERATOR_DEBUG_LEVEL=${QUAFU_ITERATOR_DEBUG}>") elseif(MINGW) - mq_add_compile_definitions(_USE_MATH_DEFINES) + quafu_add_compile_definitions(_USE_MATH_DEFINES) foreach(lang C CXX CUDA NVCXX DPCXX) is_language_enabled(${lang} _enabled) if(_enabled) - target_compile_options(${lang}_mindquantum INTERFACE "$<$:-Wa,-mbig-obj>") + target_compile_options(${lang}_quafu INTERFACE "$<$:-Wa,-mbig-obj>") if(MACD_TRYCOMPILE) target_compile_options(${lang}_try_compile INTERFACE "$<$:-Wa,-mbig-obj>") endif() @@ -378,15 +378,15 @@ elseif(MINGW) endif() endforeach() elseif(CYGWIN) - mq_add_compile_definitions(_USE_MATH_DEFINES) + quafu_add_compile_definitions(_USE_MATH_DEFINES) elseif(MSYS) - mq_add_compile_definitions(_USE_MATH_DEFINES) + quafu_add_compile_definitions(_USE_MATH_DEFINES) endif() # ============================================================================== -set(MQ_HAS_ABSEIL_CPP ${ENABLE_ABSEIL_CPP}) -set(MQ_HAS_LONG_DOUBLE ${ENABLE_LONG_DOUBLE}) +set(QUAFU_HAS_ABSEIL_CPP ${ENABLE_ABSEIL_CPP}) +set(QUAFU_HAS_LONG_DOUBLE ${ENABLE_LONG_DOUBLE}) configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake_config.h.in ${PROJECT_BINARY_DIR}/config/cmake_config.h) add_library(cmake_config INTERFACE) @@ -394,7 +394,7 @@ target_include_directories(cmake_config INTERFACE $) - append_to_property(mq_install_targets GLOBAL ${lang}20_compat) + append_to_property(quafu_install_targets GLOBAL ${lang}20_compat) endforeach() # ------------------------------------------------------------------------------ -install(FILES ${_configured_headers} DESTINATION ${MQ_INSTALL_INCLUDEDIR}/config) +install(FILES ${_configured_headers} DESTINATION ${QUAFU_INSTALL_INCLUDEDIR}/config) # ============================================================================== diff --git a/cmake/install.cmake b/cmake/install.cmake index 87438f0e4..bf2b8de83 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -18,76 +18,76 @@ include(CMakePackageConfigHelpers) -set(_namespace mindquantum::) +set(_namespace quafu::) -get_property(mq_install_targets GLOBAL PROPERTY mq_install_targets) -list(REMOVE_DUPLICATES mq_install_targets) +get_property(quafu_install_targets GLOBAL PROPERTY quafu_install_targets) +list(REMOVE_DUPLICATES quafu_install_targets) # ============================================================================== -set(MQ_INSTALL_IN_BUILD_DIR TRUE) +set(QUAFU_INSTALL_IN_BUILD_DIR TRUE) configure_package_config_file( - ${CMAKE_CURRENT_LIST_DIR}/mindquantumConfig.cmake.in ${PROJECT_BINARY_DIR}/mindquantumConfig.cmake + ${CMAKE_CURRENT_LIST_DIR}/quafuConfig.cmake.in ${PROJECT_BINARY_DIR}/quafuConfig.cmake INSTALL_DESTINATION ${PROJECT_BINARY_DIR} INSTALL_PREFIX ${PROJECT_BINARY_DIR}) # -------------------------------------- -set(MQ_INSTALL_IN_BUILD_DIR FALSE) +set(QUAFU_INSTALL_IN_BUILD_DIR FALSE) configure_package_config_file( - ${CMAKE_CURRENT_LIST_DIR}/mindquantumConfig.cmake.in ${PROJECT_BINARY_DIR}/config_for_install/mindquantumConfig.cmake - INSTALL_DESTINATION ${MQ_INSTALL_CMAKEDIR}) + ${CMAKE_CURRENT_LIST_DIR}/quafuConfig.cmake.in ${PROJECT_BINARY_DIR}/config_for_install/quafuConfig.cmake + INSTALL_DESTINATION ${QUAFU_INSTALL_CMAKEDIR}) write_basic_package_version_file( - ${PROJECT_BINARY_DIR}/mindquantumConfigVersion.cmake + ${PROJECT_BINARY_DIR}/quafuConfigVersion.cmake COMPATIBILITY SameMajorVersion - VERSION ${MQ_VERSION}) + VERSION ${QUAFU_VERSION}) -install(FILES ${PROJECT_BINARY_DIR}/config_for_install/mindquantumConfig.cmake - ${PROJECT_BINARY_DIR}/mindquantumConfigVersion.cmake DESTINATION ${MQ_INSTALL_CMAKEDIR}) +install(FILES ${PROJECT_BINARY_DIR}/config_for_install/quafuConfig.cmake + ${PROJECT_BINARY_DIR}/quafuConfigVersion.cmake DESTINATION ${QUAFU_INSTALL_CMAKEDIR}) # ============================================================================== install(DIRECTORY ${PROJECT_SOURCE_DIR}/cmake/Modules ${PROJECT_SOURCE_DIR}/cmake/commands - DESTINATION ${MQ_INSTALL_CMAKEDIR}) -install(FILES "${CMAKE_CURRENT_LIST_DIR}/packages.cmake" DESTINATION ${MQ_INSTALL_CMAKEDIR}) + DESTINATION ${QUAFU_INSTALL_CMAKEDIR}) +install(FILES "${CMAKE_CURRENT_LIST_DIR}/packages.cmake" DESTINATION ${QUAFU_INSTALL_CMAKEDIR}) -install(DIRECTORY ${PROJECT_SOURCE_DIR}/cmake/NVCXX DESTINATION ${MQ_INSTALL_CMAKEDIR}/Modules) +install(DIRECTORY ${PROJECT_SOURCE_DIR}/cmake/NVCXX DESTINATION ${QUAFU_INSTALL_CMAKEDIR}/Modules) # ------------------------------------------------------------------------------ install( - TARGETS ${mq_install_targets} - EXPORT mindquantumTargets - PRIVATE_HEADER DESTINATION ${MQ_INSTALL_INCLUDEDIR} - PUBLIC_HEADER DESTINATION ${MQ_INSTALL_INCLUDEDIR} - ARCHIVE DESTINATION ${MQ_INSTALL_LIBDIR} - LIBRARY DESTINATION ${MQ_INSTALL_LIBDIR} - RUNTIME DESTINATION ${MQ_INSTALL_BINDIR}) + TARGETS ${quafu_install_targets} + EXPORT quafuTargets + PRIVATE_HEADER DESTINATION ${QUAFU_INSTALL_INCLUDEDIR} + PUBLIC_HEADER DESTINATION ${QUAFU_INSTALL_INCLUDEDIR} + ARCHIVE DESTINATION ${QUAFU_INSTALL_LIBDIR} + LIBRARY DESTINATION ${QUAFU_INSTALL_LIBDIR} + RUNTIME DESTINATION ${QUAFU_INSTALL_BINDIR}) install( - EXPORT mindquantumTargets + EXPORT quafuTargets NAMESPACE ${_namespace} - DESTINATION ${MQ_INSTALL_CMAKEDIR}) + DESTINATION ${QUAFU_INSTALL_CMAKEDIR}) # NB: if called from setup.py, we do not need to care about installing the Python related targets, as this will be taken # care of by Python directly. if(NOT IS_PYTHON_BUILD) install( - EXPORT mindquantumPythonTargets + EXPORT quafuPythonTargets NAMESPACE ${_namespace} - DESTINATION ${MQ_INSTALL_CMAKEDIR}) + DESTINATION ${QUAFU_INSTALL_CMAKEDIR}) export( - EXPORT mindquantumPythonTargets + EXPORT quafuPythonTargets NAMESPACE ${_namespace} - FILE mindquantumPythonTargets.cmake) + FILE quafuPythonTargets.cmake) endif() # ============================================================================== export( - EXPORT mindquantumTargets + EXPORT quafuTargets NAMESPACE ${_namespace} - FILE mindquantumTargets.cmake) -export(PACKAGE mindquantum) + FILE quafuTargets.cmake) +export(PACKAGE quafu) diff --git a/cmake/lang20_config.h.in.in b/cmake/lang20_config.h.in.in index bd25134fb..acc153aba 100644 --- a/cmake/lang20_config.h.in.in +++ b/cmake/lang20_config.h.in.in @@ -14,61 +14,61 @@ * limitations under the License. */ -#ifndef MQ_@LANG@20_CONFIG_HPP -#define MQ_@LANG@20_CONFIG_HPP +#ifndef QUAFU_@LANG@20_CONFIG_HPP +#define QUAFU_@LANG@20_CONFIG_HPP -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_CLASS_NON_TYPE_TEMPLATE_ARGS -#define MQ_HAS_CLASS_NON_TYPE_TEMPLATE_ARGS MQ_@LANG@_HAS_CLASS_NON_TYPE_TEMPLATE_ARGS +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_CLASS_NON_TYPE_TEMPLATE_ARGS +#define QUAFU_HAS_CLASS_NON_TYPE_TEMPLATE_ARGS QUAFU_@LANG@_HAS_CLASS_NON_TYPE_TEMPLATE_ARGS -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_CONCEPTS -#define MQ_HAS_CONCEPTS MQ_@LANG@_HAS_CONCEPTS +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_CONCEPTS +#define QUAFU_HAS_CONCEPTS QUAFU_@LANG@_HAS_CONCEPTS -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_CONCEPT_LIBRARY -#define MQ_HAS_CONCEPT_LIBRARY MQ_@LANG@_HAS_CONCEPT_LIBRARY +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_CONCEPT_LIBRARY +#define QUAFU_HAS_CONCEPT_LIBRARY QUAFU_@LANG@_HAS_CONCEPT_LIBRARY -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_CONCEPT_DESTRUCTIBLE -#define MQ_HAS_CONCEPT_DESTRUCTIBLE MQ_@LANG@_HAS_CONCEPT_DESTRUCTIBLE +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_CONCEPT_DESTRUCTIBLE +#define QUAFU_HAS_CONCEPT_DESTRUCTIBLE QUAFU_@LANG@_HAS_CONCEPT_DESTRUCTIBLE -@MQ_DEFINE_MACRO@ MQ_@LANG@_SUPPORTS_EXT_DEPENDENT_CONCEPTS -#define MQ_SUPPORTS_EXT_DEPENDENT_CONCEPTS MQ_@LANG@_SUPPORTS_EXT_DEPENDENT_CONCEPTS +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_SUPPORTS_EXT_DEPENDENT_CONCEPTS +#define QUAFU_SUPPORTS_EXT_DEPENDENT_CONCEPTS QUAFU_@LANG@_SUPPORTS_EXT_DEPENDENT_CONCEPTS -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_CXX20_FORMAT -#define MQ_HAS_CXX20_FORMAT MQ_@LANG@_HAS_CXX20_FORMAT +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_CXX20_FORMAT +#define QUAFU_HAS_CXX20_FORMAT QUAFU_@LANG@_HAS_CXX20_FORMAT -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_CXX20_RANGES -#define MQ_HAS_CXX20_RANGES MQ_@LANG@_HAS_CXX20_RANGES +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_CXX20_RANGES +#define QUAFU_HAS_CXX20_RANGES QUAFU_@LANG@_HAS_CXX20_RANGES -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_CXX20_SPAN -#define MQ_HAS_CXX20_SPAN MQ_@LANG@_HAS_CXX20_SPAN +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_CXX20_SPAN +#define QUAFU_HAS_CXX20_SPAN QUAFU_@LANG@_HAS_CXX20_SPAN -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_IMPLICIT_TEMPLATE_DEDUCTION_GUIDES -#define MQ_HAS_IMPLICIT_TEMPLATE_DEDUCTION_GUIDES MQ_@LANG@_HAS_IMPLICIT_TEMPLATE_DEDUCTION_GUIDES +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_IMPLICIT_TEMPLATE_DEDUCTION_GUIDES +#define QUAFU_HAS_IMPLICIT_TEMPLATE_DEDUCTION_GUIDES QUAFU_@LANG@_HAS_IMPLICIT_TEMPLATE_DEDUCTION_GUIDES -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_DETECTED_TS2 -#define MQ_HAS_DETECTED_TS2 MQ_@LANG@_HAS_DETECTED_TS2 +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_DETECTED_TS2 +#define QUAFU_HAS_DETECTED_TS2 QUAFU_@LANG@_HAS_DETECTED_TS2 -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_MAP_CONTAINS -#define MQ_HAS_MAP_CONTAINS MQ_@LANG@_HAS_MAP_CONTAINS +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_MAP_CONTAINS +#define QUAFU_HAS_MAP_CONTAINS QUAFU_@LANG@_HAS_MAP_CONTAINS -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_MAP_ERASE_IF -#define MQ_HAS_MAP_ERASE_IF MQ_@LANG@_HAS_MAP_ERASE_IF +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_MAP_ERASE_IF +#define QUAFU_HAS_MAP_ERASE_IF QUAFU_@LANG@_HAS_MAP_ERASE_IF -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_OPERATOR_NOT_EQUAL_SYNTHESIS -#define MQ_HAS_OPERATOR_NOT_EQUAL_SYNTHESIS MQ_@LANG@_HAS_OPERATOR_NOT_EQUAL_SYNTHESIS +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_OPERATOR_NOT_EQUAL_SYNTHESIS +#define QUAFU_HAS_OPERATOR_NOT_EQUAL_SYNTHESIS QUAFU_@LANG@_HAS_OPERATOR_NOT_EQUAL_SYNTHESIS -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_REMOVE_CVREF_T -#define MQ_HAS_REMOVE_CVREF_T MQ_@LANG@_HAS_REMOVE_CVREF_T +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_REMOVE_CVREF_T +#define QUAFU_HAS_REMOVE_CVREF_T QUAFU_@LANG@_HAS_REMOVE_CVREF_T -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_STD_FILESYSTEM -#define MQ_HAS_STD_FILESYSTEM MQ_@LANG@_HAS_STD_FILESYSTEM +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_STD_FILESYSTEM +#define QUAFU_HAS_STD_FILESYSTEM QUAFU_@LANG@_HAS_STD_FILESYSTEM -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_STD_LAUNDER -#define MQ_HAS_STD_LAUNDER MQ_@LANG@_HAS_STD_LAUNDER +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_STD_LAUNDER +#define QUAFU_HAS_STD_LAUNDER QUAFU_@LANG@_HAS_STD_LAUNDER -@MQ_DEFINE_MACRO@ MQ_@LANG@_HAS_CONSTEXPR_STD_VECTOR -#define MQ_HAS_CONSTEXPR_STD_VECTOR MQ_@LANG@_HAS_CONSTEXPR_STD_VECTOR +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_HAS_CONSTEXPR_STD_VECTOR +#define QUAFU_HAS_CONSTEXPR_STD_VECTOR QUAFU_@LANG@_HAS_CONSTEXPR_STD_VECTOR -@MQ_DEFINE_MACRO@ MQ_@LANG@_STD_ACCUMULATE_USE_MOVE -#define MQ_STD_ACCUMULATE_USE_MOVE MQ_@LANG@_STD_ACCUMULATE_USE_MOVE +@QUAFU_DEFINE_MACRO@ QUAFU_@LANG@_STD_ACCUMULATE_USE_MOVE +#define QUAFU_STD_ACCUMULATE_USE_MOVE QUAFU_@LANG@_STD_ACCUMULATE_USE_MOVE -#endif /* MQ_@LANG@20_CONFIG_HPP */ +#endif /* QUAFU_@LANG@20_CONFIG_HPP */ diff --git a/cmake/linker_flags.cmake b/cmake/linker_flags.cmake index 8441818dd..49f6d5b7e 100644 --- a/cmake/linker_flags.cmake +++ b/cmake/linker_flags.cmake @@ -76,13 +76,13 @@ if(ENABLE_CUDA AND _nvcxx_enabled) # NB: simply copy over the compiler options to linker options since they are the same foreach(_src_target nvhpc_cuda_flags_NVCXX nvhpc_cuda_version_flags_NVCXX) get_target_property(_flag ${_src_target} INTERFACE_COMPILE_OPTIONS) - foreach(_dst_target ${_src_target} NVCXX_mindquantum NVCXX_try_compile NVCXX_try_compile_flagcheck) + foreach(_dst_target ${_src_target} NVCXX_quafu NVCXX_try_compile NVCXX_try_compile_flagcheck) target_link_options(${_dst_target} INTERFACE ${_flag}) endforeach() endforeach() get_target_property(_flag nvhpc_gpu_compute_capability_NVCXX INTERFACE_COMPILE_OPTIONS) - foreach(_dst_target nvhpc_gpu_compute_capability_NVCXX NVCXX_mindquantum) + foreach(_dst_target nvhpc_gpu_compute_capability_NVCXX NVCXX_quafu) target_link_options(${_dst_target} INTERFACE ${_flag}) endforeach() @@ -299,8 +299,8 @@ if("${OS_NAME}" STREQUAL "MSYS-CLANG64") PATH_SUFFIXES lib REQUIRED) foreach(_lang C CXX DPCXX) - if(TARGET ${_lang}_mindquantum) - target_link_libraries(${_lang}_mindquantum INTERFACE "$<$:${_ssp_library}>") + if(TARGET ${_lang}_quafu) + target_link_libraries(${_lang}_quafu INTERFACE "$<$:${_ssp_library}>") endif() endforeach() endif() diff --git a/cmake/macros.cmake b/cmake/macros.cmake index d62ca04a9..84139f723 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -68,24 +68,24 @@ include(is_language_enabled) # ------------------------------------------------------------------------------ # ~~~ -# Setup a language for use with MindQuantum +# Setup a language for use with quafu # # setup_language() # -# This function creates 3 targets that are used throughout MindQuantum in order to store compiler and linker flags: +# This function creates 3 targets that are used throughout quafu in order to store compiler and linker flags: # - _try_compile # - _try_compile_flagcheck -# - _mindquantum +# - _quafu # # The first two are used in try_compile() calls while the last one should contain the definite list of compiler and -# linker options that MindQuantum requires for all targets. +# linker options that quafu requires for all targets. # ~~~ function(setup_language lang) add_library(${lang}_try_compile_flagcheck INTERFACE) add_library(${lang}_try_compile INTERFACE) - add_library(${lang}_mindquantum INTERFACE) + add_library(${lang}_quafu INTERFACE) - append_to_property(mq_install_targets GLOBAL ${lang}_mindquantum) + append_to_property(quafu_install_targets GLOBAL ${lang}_quafu) endfunction() # ------------------------------------------------------------------------------ @@ -93,19 +93,19 @@ endfunction() # ~~~ # Append a list of compile definitions to some of the language specific targets (see setup_language()) # -# mq_add_compile_definitions([TRYCOMPILE, TRYCOMPILE_FLAGCHECK] +# quafu_add_compile_definitions([TRYCOMPILE, TRYCOMPILE_FLAGCHECK] # , [, ...]) # -# Always modify the _mindquantum target. If any of TRYCOMPILE, TRYCOMPILE_FLAGCHECK is also specified, then modify +# Always modify the _quafu target. If any of TRYCOMPILE, TRYCOMPILE_FLAGCHECK is also specified, then modify # the corresponding target. # ~~~ -function(mq_add_compile_definitions) +function(quafu_add_compile_definitions) cmake_parse_arguments(PARSE_ARGV 0 MACD "TRYCOMPILE;TRYCOMPILE_FLAGCHECK" "" "") foreach(lang C CXX CUDA NVCXX DPCXX) is_language_enabled(${lang} _enabled) if(_enabled) - target_compile_definitions(${lang}_mindquantum + target_compile_definitions(${lang}_quafu INTERFACE "$<$:${MACD_UNPARSED_ARGUMENTS}>") if(MACD_TRYCOMPILE) target_compile_definitions(${lang}_try_compile @@ -179,7 +179,7 @@ endfunction() # ============================================================================== # ~~~ -# Macro used to disable CUDA support in MindQuantum +# Macro used to disable CUDA support in quafu # # disable_cuda([]) # ~~~ @@ -309,8 +309,8 @@ function(apply_patches) # NB: All these shenanigans with file(CONFIGURE ...) are just to make sure that we get a file with LF line # endings... get_filename_component(_patch_file_name ${_patch_file} NAME) - set(_lf_patch_file ${PROJECT_BINARY_DIR}/_mq_patch/lf_${_patch_file_name}) - set(_crlf_patch_file ${PROJECT_BINARY_DIR}/_mq_patch/crlf_${_patch_file_name}) + set(_lf_patch_file ${PROJECT_BINARY_DIR}/_quafu_patch/lf_${_patch_file_name}) + set(_crlf_patch_file ${PROJECT_BINARY_DIR}/_quafu_patch/crlf_${_patch_file_name}) file(READ "${_patch_file}" _content) # NB: escape patches that have @XXX@ since those would be replaced by the call to file(CONFIGURE) set(_at @) @@ -340,8 +340,8 @@ function(apply_patches) file(MD5 "${_lf_patch_file}" _lf_md5) file(MD5 "${_crlf_patch_file}" _crlf_md5) - set(_lf_patch_lock_file "${AP_WORKING_DIRECTORY}/mq_applied_patch_${_lf_md5}") - set(_crlf_patch_lock_file "${AP_WORKING_DIRECTORY}/mq_applied_patch_${_crlf_md5}") + set(_lf_patch_lock_file "${AP_WORKING_DIRECTORY}/quafu_applied_patch_${_lf_md5}") + set(_crlf_patch_lock_file "${AP_WORKING_DIRECTORY}/quafu_applied_patch_${_crlf_md5}") if(NOT EXISTS "${_lf_patch_lock_file}" AND NOT EXISTS "${_crlf_patch_lock_file}") message(STATUS "Applying patch ${_patch_file}") @@ -533,7 +533,7 @@ endfunction() # test_compile_option( # LANGS [...] # FLAGS [...] -# [FLAGCHECK, NO_MQ_TARGET, NO_TRYCOMPILE_TARGET, NO_TRYCOMPILE_FLAGCHECK_TARGET] +# [FLAGCHECK, NO_QUAFU_TARGET, NO_TRYCOMPILE_TARGET, NO_TRYCOMPILE_FLAGCHECK_TARGET] # [GENEX ] # [LINKER_FLAGS ] # [CMAKE_OPTION