From 93b30928afa1180ddceeab1e7a978b35018f420a Mon Sep 17 00:00:00 2001 From: cjwood Date: Fri, 13 Apr 2018 10:26:18 -0400 Subject: [PATCH] Fixing OpenMP config settings Increase shots to fix failing test cleaning up some simulator variable names --- cmake/python-build.cmake | 14 ++--- doc/conf.py | 2 +- setup.py.in | 8 +-- src/qasm-simulator-cpp/CMakeLists.txt | 62 +++++++++---------- src/qasm-simulator-cpp/README.md | 4 +- .../src/backends/base_backend.hpp | 15 ++--- .../src/backends/ideal_backend.hpp | 17 +++-- .../src/engines/base_engine.hpp | 19 ++---- src/qasm-simulator-cpp/src/simulator.hpp | 15 +++-- .../src/utilities/qubit_vector.hpp | 4 +- src/qasm-simulator-cpp/test/CMakeLists.txt | 12 ++-- test/python/qobj/cpp_measure_opt.json | 2 +- test/python/test_local_qasm_simulator_cpp.py | 6 +- 13 files changed, 85 insertions(+), 95 deletions(-) mode change 100644 => 100755 cmake/python-build.cmake mode change 100644 => 100755 doc/conf.py mode change 100644 => 100755 setup.py.in mode change 100644 => 100755 src/qasm-simulator-cpp/CMakeLists.txt mode change 100644 => 100755 src/qasm-simulator-cpp/test/CMakeLists.txt diff --git a/cmake/python-build.cmake b/cmake/python-build.cmake old mode 100644 new mode 100755 index 9ec68a917386..23abd83f703b --- a/cmake/python-build.cmake +++ b/cmake/python-build.cmake @@ -53,13 +53,13 @@ function(add_pypi_package_target TARGET_NAME PACKAGE_TYPE) endif() if(PIP_PACKAGE_PLATFORM_WHEELS) - set(COPY_QASM_SIM_TARGET ${TARGET_NAME}_copy_qasm_simulator) + set(COPY_QASM_SIM_CPP_TARGET ${TARGET_NAME}_copy_qasm_simulator_cpp) # We create a target which will depend on TARGET_NAME_WHEELS for # copying all the binaries to their final locations - add_custom_target(${COPY_QASM_SIM_TARGET}) - add_custom_command(TARGET ${COPY_QASM_SIM_TARGET} + add_custom_target(${COPY_QASM_SIM_CPP_TARGET}) + add_custom_command(TARGET ${COPY_QASM_SIM_CPP_TARGET} COMMAND ${CMAKE_COMMAND} -E copy - ${QASM_SIMULATOR_OUTPUT_DIR}/qasm_simulator_cpp${EXECUTABLE_FILE_EXTENSION} + ${QASM_SIMULATOR_CPP_OUTPUT_DIR}/qasm_simulator_cpp${EXECUTABLE_FILE_EXTENSION} ${CMAKE_CURRENT_SOURCE_DIR}/qiskit/backends) # For ' make clean' target set_property(DIRECTORY APPEND PROPERTY @@ -67,8 +67,8 @@ function(add_pypi_package_target TARGET_NAME PACKAGE_TYPE) ${CMAKE_CURRENT_SOURCE_DIR}/qiskit/backends/qasm_simulator_cpp${EXECUTABLE_FILE_EXTENSION}) # For Windows, we need to copy external .dll dependencies too if(MINGW) - foreach(dll_file ${QASM_SIMULATOR_THIRD_PARTY_DLLS}) - add_custom_command(TARGET ${COPY_QASM_SIM_TARGET} + foreach(dll_file ${QASM_SIMULATOR_CPP_THIRD_PARTY_DLLS}) + add_custom_command(TARGET ${COPY_QASM_SIM_CPP_TARGET} COMMAND ${CMAKE_COMMAND} -E copy ${dll_file} ${CMAKE_CURRENT_SOURCE_DIR}/qiskit/backends) @@ -97,7 +97,7 @@ function(add_pypi_package_target TARGET_NAME PACKAGE_TYPE) if(PIP_PACKAGE_PLATFORM_WHEELS) add_dependencies(${TARGET_NAME} ${TARGET_NAME_WHEELS} - ${COPY_QASM_SIM_TARGET} + ${COPY_QASM_SIM_CPP_TARGET} qasm_simulator_cpp) endif() diff --git a/doc/conf.py b/doc/conf.py old mode 100644 new mode 100755 index ddd91239236a..90b238fd5aa6 --- a/doc/conf.py +++ b/doc/conf.py @@ -23,7 +23,7 @@ sys.path.insert(0, os.path.abspath('.')) # Imported manually, as otherwise it will not be fully imported. -import qiskit.extensions.qiskit_simulator +import qiskit.extensions.qasm_simulator_cpp # -- General configuration ------------------------------------------------ diff --git a/setup.py.in b/setup.py.in old mode 100644 new mode 100755 index 179dac211158..55f4374ed178 --- a/setup.py.in +++ b/setup.py.in @@ -56,7 +56,7 @@ packages = ["qiskit", # C++ components compilation -class QiskitSimulatorBuild(build): +class QasmSimulatorBuild(build): def run(self): super().run() # Store the current working directory, as invoking cmake involves @@ -82,7 +82,7 @@ class QiskitSimulatorBuild(build): cmd_cmake.append("-GMinGW Makefiles") cmd_cmake.append('..') - cmd_make = ['make', 'pypi_package_copy_qiskit_simulator'] + cmd_make = ['make', 'pypi_package_copy_qasm_simulator_cpp'] try: cmd_make.append('-j%d' % cpu_count()) @@ -95,7 +95,7 @@ class QiskitSimulatorBuild(build): call(cmd_cmake) call(cmd_make) - self.execute(compile_simulator, [], 'Compiling QISKit C++ Simulator') + self.execute(compile_simulator, [], 'Compiling C++ QASM Simulator') except Exception as e: print(str(e)) print("WARNING: Seems like the cpp simulator can't be built, Qiskit will " @@ -140,7 +140,7 @@ setup( include_package_data=True, python_requires=">=3.5", cmdclass={ - 'build': QiskitSimulatorBuild, + 'build': QasmSimulatorBuild, }, distclass=BinaryDistribution, extras_require={ diff --git a/src/qasm-simulator-cpp/CMakeLists.txt b/src/qasm-simulator-cpp/CMakeLists.txt old mode 100644 new mode 100755 index 42dd7f7effeb..a18ab6b70328 --- a/src/qasm-simulator-cpp/CMakeLists.txt +++ b/src/qasm-simulator-cpp/CMakeLists.txt @@ -1,7 +1,7 @@ # CMake config file to build the C++ Simulator # -# For Windows, we always build static executables. QISKit provides with the -# necessary external binary libraries (.lib and .dll), these .lib comes from an +# For Windows, we always build static executables. QISKit provides the +# necessary external binary libraries (.lib and .dll), these .lib come from an # external source and they are simple import files, so we still need the .dll # files in order to run the final executable. We only support MinGW64 toolchain # so the static linking makes sure that other required libraries from this @@ -17,27 +17,27 @@ # # For Mac, you probably need to install static versions of the toolchain in order # to make a static executable. Additionaly, the OpenMP features are only supported -# on GNU g++ comipler, CLang doesn't include it so if you are building with CLang +# on GNU g++ compiler, CLang doesn't include it so if you are building with CLang # you won't get all the performance. project(qasm_simulator_cpp VERSION 1.0 LANGUAGES CXX) -set(QASM_SIMULATOR_SRC_DIR "${PROJECT_SOURCE_DIR}/src") -set(QASM_SIMULATOR_SRC - "${QASM_SIMULATOR_SRC_DIR}/main.cpp") -set(QASM_SIMULATOR_EXTERNAL_LIBS - "${QASM_SIMULATOR_SRC_DIR}/third-party/headers" - "${QASM_SIMULATOR_SRC_DIR}/third-party/win64/lib" +set(QASM_SIMULATOR_CPP_SRC_DIR "${PROJECT_SOURCE_DIR}/src") +set(QASM_SIMULATOR_CPP_SRC + "${QASM_SIMULATOR_CPP_SRC_DIR}/main.cpp") +set(QASM_SIMULATOR_CPP_EXTERNAL_LIBS + "${QASM_SIMULATOR_CPP_SRC_DIR}/third-party/headers" + "${QASM_SIMULATOR_CPP_SRC_DIR}/third-party/win64/lib" "${USER_LIB_PATH}") # Target definition -add_executable(qasm_simulator_cpp ${QASM_SIMULATOR_SRC}) +add_executable(qasm_simulator_cpp ${QASM_SIMULATOR_CPP_SRC}) # Target properties: C++ program set_target_properties(qasm_simulator_cpp PROPERTIES LINKER_LANGUAGE CXX) # Toolchain options -set_property(TARGET qasm_simulator_cpp PROPERTY CXX_STANDARD 14) +set_property(TARGET qasm_simulator_cpp PROPERTY CXX_STANDARD 11) # Compiler flags enable_cxx_compiler_flag_if_supported("-O3") @@ -48,13 +48,13 @@ enable_cxx_compiler_flag_if_supported("-fopenmp") if(STATIC_LINKING OR MINGW) # Hack: Seems like enable_cxx_compiler_flag_if_supported() is not properly # working on MacOS, when a flag is not supported, it cascades errors - # to the rest of the flgas being tested... and -static compilation on Mac + # to the rest of the flags being tested... and -static compilation on Mac # with gcc is failing... if(NOT APPLE) enable_cxx_compiler_flag_if_supported("-static") + enable_cxx_compiler_flag_if_supported("-static-libgcc") endif() enable_cxx_compiler_flag_if_supported("-static-libstdc++") - enable_cxx_compiler_flag_if_supported("-static-libgcc") endif() # Warnings and Errors @@ -69,11 +69,11 @@ enable_cxx_compiler_flag_if_supported("-Wredundant-decls") enable_cxx_compiler_flag_if_supported("-Wshadow") enable_cxx_compiler_flag_if_supported("-Woverloaded-virtual") -target_include_directories(qasm_simulator_cpp PRIVATE ${QASM_SIMULATOR_SRC_DIR}) -target_include_directories(qasm_simulator_cpp PRIVATE ${QASM_SIMULATOR_SRC_DIR}/backends) -target_include_directories(qasm_simulator_cpp PRIVATE ${QASM_SIMULATOR_SRC_DIR}/engines) -target_include_directories(qasm_simulator_cpp PRIVATE ${QASM_SIMULATOR_SRC_DIR}/utilities) -target_include_directories(qasm_simulator_cpp PRIVATE ${QASM_SIMULATOR_SRC_DIR}/third-party/headers) +target_include_directories(qasm_simulator_cpp PRIVATE ${QASM_SIMULATOR_CPP_SRC_DIR}) +target_include_directories(qasm_simulator_cpp PRIVATE ${QASM_SIMULATOR_CPP_SRC_DIR}/backends) +target_include_directories(qasm_simulator_cpp PRIVATE ${QASM_SIMULATOR_CPP_SRC_DIR}/engines) +target_include_directories(qasm_simulator_cpp PRIVATE ${QASM_SIMULATOR_CPP_SRC_DIR}/utilities) +target_include_directories(qasm_simulator_cpp PRIVATE ${QASM_SIMULATOR_CPP_SRC_DIR}/third-party/headers) # For header only libraries SET(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "") @@ -89,28 +89,28 @@ endif() # want CMake to find it. find_library(LIB_JSON NAMES json - PATHS ${QASM_SIMULATOR_EXTERNAL_LIBS}) + PATHS ${QASM_SIMULATOR_CPP_EXTERNAL_LIBS}) if(NOT LIB_JSON) message(FATAL_ERROR "JSON library not found!. Please provide with a USER_LIB_PATH to CMake so it can be searched there") endif() find_library(LIB_LAPACK NAMES lapack - PATHS ${QASM_SIMULATOR_EXTERNAL_LIBS}) + PATHS ${QASM_SIMULATOR_CPP_EXTERNAL_LIBS}) if(NOT LIB_LAPACK) message(FATAL_ERROR "LAPACK library not found!. Please provide with a USER_LIB_PATH to CMake so it can be searched there") endif() find_library(LIB_BLAS NAMES blas - PATHS ${QASM_SIMULATOR_EXTERNAL_LIBS}) + PATHS ${QASM_SIMULATOR_CPP_EXTERNAL_LIBS}) if(NOT LIB_BLAS) message(FATAL_ERROR "BLAS library not found!. Please provide with a USER_LIB_PATH to CMake so it can be searched there") endif() find_library(LIB_THREADS NAMES pthread - PATHS ${QASM_SIMULATOR_EXTERNAL_LIBS}) + PATHS ${QASM_SIMULATOR_CPP_EXTERNAL_LIBS}) if(NOT LIB_THREADS) message(FATAL_ERROR "Pthreads library not found!. Please provide with a USER_LIB_PATH to CMake so it can be searched there") endif() @@ -122,31 +122,31 @@ set(LIBRARIES PRIVATE ${LIB_BLAS} # Linking target_link_libraries(qasm_simulator_cpp ${LIBRARIES}) -set(QASM_SIMULATOR_OUTPUT_DIR $ +set(QASM_SIMULATOR_CPP_OUTPUT_DIR $ CACHE INTERNAL "Output directory for building QISKit C++ Simulator") if(MINGW) - set(QASM_SIMULATOR_THIRD_PARTY_DLLS - "${QASM_SIMULATOR_SRC_DIR}/third-party/win64/dll/libblas.dll" - "${QASM_SIMULATOR_SRC_DIR}/third-party/win64/dll/libgfortran_64-3.dll" - "${QASM_SIMULATOR_SRC_DIR}/third-party/win64/dll/libquadmath_64-0.dll" + set(QASM_SIMULATOR_CPP_THIRD_PARTY_DLLS + "${QASM_SIMULATOR_CPP_SRC_DIR}/third-party/win64/dll/libblas.dll" + "${QASM_SIMULATOR_CPP_SRC_DIR}/third-party/win64/dll/libgfortran_64-3.dll" + "${QASM_SIMULATOR_CPP_SRC_DIR}/third-party/win64/dll/libquadmath_64-0.dll" CACHE INTERNAL "Third-party C++ Simulator DLLs") - foreach(dll_file ${QASM_SIMULATOR_THIRD_PARTY_DLLS}) + foreach(dll_file ${QASM_SIMULATOR_CPP_THIRD_PARTY_DLLS}) add_custom_command( TARGET qasm_simulator_cpp POST_BUILD COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${dll_file} ${QASM_SIMULATOR_OUTPUT_DIR}/ + ARGS -E copy ${dll_file} ${QASM_SIMULATOR_CPP_OUTPUT_DIR}/ ) # For 'make clean' target get_filename_component(FINAL_FILE ${dll_file} NAME) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES - ${QASM_SIMULATOR_OUTPUT_DIR}/${FINAL_FILE}) + ${QASM_SIMULATOR_CPP_OUTPUT_DIR}/${FINAL_FILE}) endforeach() endif() # Tests # TODO: Enable them when ready -#add_subdirectory(${QASM_SIMULATOR_DIR}/test) \ No newline at end of file +#add_subdirectory(${QASM_SIMULATOR_CPP_DIR}/test) diff --git a/src/qasm-simulator-cpp/README.md b/src/qasm-simulator-cpp/README.md index 19e2d296f680..9ef012c23585 100644 --- a/src/qasm-simulator-cpp/README.md +++ b/src/qasm-simulator-cpp/README.md @@ -175,9 +175,7 @@ results = QuantumProgram.execute(circs, config=config) ``` -You can check the backend was successfully added using the `available_backends` method of the `QuantumProgram` class. If successful the returned list will include `local_qasm_simulator` and `local_clifford_simulator`. - -Note: `local_qasm_simulator` is provided as a shortcut and will automatically point to `local_qasm_simulator_cpp` if it is installed. However, if this simulator is not installed, then it will point to the (slower) `local_qasm_simulator_py`. +You can check the backend was successfully added using the `available_backends` method of the `QuantumProgram` class. If successful the returned list will include `local_qiskit_simulator` and `local_clifford_simulator`. ### Simulator output diff --git a/src/qasm-simulator-cpp/src/backends/base_backend.hpp b/src/qasm-simulator-cpp/src/backends/base_backend.hpp index c35a3ae580bf..cb762b4b3163 100644 --- a/src/qasm-simulator-cpp/src/backends/base_backend.hpp +++ b/src/qasm-simulator-cpp/src/backends/base_backend.hpp @@ -177,13 +177,12 @@ template class BaseBackend { */ virtual inline void set_config(json_t &config) = 0; // raises unused param warning - inline void set_omp_threads(int n) { + inline void set_num_threads(int n) { if (n > 0) - omp_threads = n; + num_threads = n; }; - inline void set_omp_threshold(int n) { - if (n > 0) - omp_threshold = n; + inline int get_num_threads() { + return num_threads; }; /** @@ -201,10 +200,8 @@ template class BaseBackend { /** * Number of threads to use for inner parallelization. */ - uint_t omp_threads = 1; - uint_t omp_threshold; - bool omp_flag = false; - + int num_threads = 1; + /** * Stores the state of measured classical registers in a QISKIT program. All * bits are initialized in the 0 state, and any unmeasured bits will hence diff --git a/src/qasm-simulator-cpp/src/backends/ideal_backend.hpp b/src/qasm-simulator-cpp/src/backends/ideal_backend.hpp index dd62a300ca2e..8592fae4d283 100644 --- a/src/qasm-simulator-cpp/src/backends/ideal_backend.hpp +++ b/src/qasm-simulator-cpp/src/backends/ideal_backend.hpp @@ -52,7 +52,7 @@ class IdealBackend : public BaseBackend { /************************ * BaseBackend Methods ************************/ - void set_config(json_t &config); + void set_config(json_t &config) override; virtual void initialize(const Circuit &prog); virtual void qc_operation(const operation &op); @@ -64,6 +64,10 @@ class IdealBackend : public BaseBackend { protected: + /************************ + * OpenMP setting + ************************/ + int omp_threshold = 16; /************************ * Apply matrices @@ -122,10 +126,7 @@ class IdealBackend : public BaseBackend { void IdealBackend::set_config(json_t &config) { // Set OMP threshold for state update functions - uint_t num_qubits_omp_threshold = 20; // default threshold - JSON::get_value(num_qubits_omp_threshold, "theshold_omp_gate", config); - qreg.set_omp_threshold(num_qubits_omp_threshold); - + JSON::get_value(omp_threshold, "threshold_omp_gate", config); // parse initial state from JSON if (JSON::check_key("initial_state", config)) { QubitVector initial_state = config["initial_state"].get(); @@ -153,13 +154,11 @@ void IdealBackend::initialize(const Circuit &prog) { } else { // reset state std::vector to default state qreg = QubitVector(prog.nqubits); + qreg.set_omp_threshold(omp_threshold); + qreg.set_omp_threads(num_threads); qreg.initialize(); } - // OpenMP settings - qreg.set_omp_threshold(omp_threshold); - qreg.set_omp_threads(omp_threads); - // TODO: make a ClassicalRegister class using BinaryVector creg.assign(prog.nclbits, 0); qreg_saved.erase(qreg_saved.begin(), qreg_saved.end()); diff --git a/src/qasm-simulator-cpp/src/engines/base_engine.hpp b/src/qasm-simulator-cpp/src/engines/base_engine.hpp index 10d1f0b20a31..592b842be8aa 100644 --- a/src/qasm-simulator-cpp/src/engines/base_engine.hpp +++ b/src/qasm-simulator-cpp/src/engines/base_engine.hpp @@ -91,9 +91,6 @@ template class BaseEngine { // Initial State StateType initial_state; - // OMP Threshold for backend - int_t omp_threshold = -1; // < 0 for automatic - //============================================================================ // Constructors //============================================================================ @@ -115,8 +112,8 @@ template class BaseEngine { * @param nshots the number of simulation shots to run */ virtual void run_program(Circuit &circ, BaseBackend *be, - uint_t nshots = 1, uint_t nthreads = 1); - virtual void initialize(BaseBackend *be, uint_t nthreads); + uint_t nshots = 1); + virtual void initialize(BaseBackend *be); virtual void execute(Circuit &circ, BaseBackend *be, uint_t nshots); @@ -155,18 +152,14 @@ template class BaseEngine { template void BaseEngine::run_program(Circuit &prog, BaseBackend *be, - uint_t nshots, uint_t nthreads) { - initialize(be, nthreads); + uint_t nshots) { + initialize(be); execute(prog, be, nshots); total_shots += nshots; } template -void BaseEngine::initialize(BaseBackend *be, - uint_t nthreads) { - // Set OpenMP settings - be->set_omp_threads(nthreads); - be->set_omp_threshold(omp_threshold); +void BaseEngine::initialize(BaseBackend *be) { // Set custom initial state if (initial_state_flag) be->set_initial_state(initial_state); @@ -308,8 +301,6 @@ inline void from_json(const json_t &js, BaseEngine &engine) { engine.initial_state_flag = true; } - // Get omp threshold - JSON::get_value(engine.omp_threshold, "omp_threshold", js); } //------------------------------------------------------------------------------ diff --git a/src/qasm-simulator-cpp/src/simulator.hpp b/src/qasm-simulator-cpp/src/simulator.hpp index 76be7e222246..71e3dcbfafed 100644 --- a/src/qasm-simulator-cpp/src/simulator.hpp +++ b/src/qasm-simulator-cpp/src/simulator.hpp @@ -197,14 +197,17 @@ json_t Simulator::run_circuit(Circuit &circ) const { threads = std::min(max_threads_shot, threads); } uint_t gate_threads = std::max(1UL, ncpus / threads); - if (max_threads_gate > 0) + if (max_threads_gate > 0) { gate_threads = std::min(max_threads_gate, gate_threads); - + } + if (gate_threads > 0) { + backend.set_num_threads(gate_threads); + } // Single-threaded shots loop if (threads < 2) { // Run shots on single-thread backend.set_rng_seed(rng_seed); - engine.run_program(circ, &backend, circ.shots, gate_threads); + engine.run_program(circ, &backend, circ.shots); } // Parallelized shots loop else { @@ -223,7 +226,7 @@ json_t Simulator::run_circuit(Circuit &circ) const { Backend be(backend); be.set_rng_seed(ss.second); futures[j] = engine; - futures[j].run_program(circ, &be, ss.first, gate_threads); + futures[j].run_program(circ, &be, ss.first); } for (auto &f : futures) engine += f; @@ -253,7 +256,7 @@ json_t Simulator::run_circuit(Circuit &circ) const { } // Add time taken and return result - ret["data"]["time_taken"] = + ret["time_taken"] = std::chrono::duration(myclock_t::now() - start).count(); // Add metadata ret["name"] = circ.name; @@ -261,6 +264,8 @@ json_t Simulator::run_circuit(Circuit &circ) const { ret["seed"] = rng_seed; if (threads > 1) ret["threads_shot"] = threads; + if (gate_threads > 1) + ret["threads_gates"] = gate_threads; // Report success ret["success"] = true; ret["status"] = std::string("DONE"); diff --git a/src/qasm-simulator-cpp/src/utilities/qubit_vector.hpp b/src/qasm-simulator-cpp/src/utilities/qubit_vector.hpp index b1c6d3099758..8b06c9de9224 100644 --- a/src/qasm-simulator-cpp/src/utilities/qubit_vector.hpp +++ b/src/qasm-simulator-cpp/src/utilities/qubit_vector.hpp @@ -175,8 +175,8 @@ class QubitVector { TensorIndex idx; // OMP - uint_t omp_threads = 1; - uint_t omp_threshold = 20; + uint_t omp_threads = 1; // Disable multithreading by default + uint_t omp_threshold = 16; // Qubit threshold for multithreading when enabled /************************ * Matrix-mult Helper functions diff --git a/src/qasm-simulator-cpp/test/CMakeLists.txt b/src/qasm-simulator-cpp/test/CMakeLists.txt old mode 100644 new mode 100755 index 997ddcf18ad4..382d681900f8 --- a/src/qasm-simulator-cpp/test/CMakeLists.txt +++ b/src/qasm-simulator-cpp/test/CMakeLists.txt @@ -12,13 +12,13 @@ set(test_list one two) foreach(test_item ${test_list}) set(test_name ${test_item}_tests) add_executable(${test_name} main.cpp ${test_item}_test.cpp ${headers}) - target_include_directories(${test_name} PRIVATE ${QISKIT_SIMULATOR_SRC_DIR}) - target_include_directories(${test_name} PRIVATE ${QISKIT_SIMULATOR_SRC_DIR}/backends) - target_include_directories(${test_name} PRIVATE ${QISKIT_SIMULATOR_SRC_DIR}/engines) - target_include_directories(${test_name} PRIVATE ${QISKIT_SIMULATOR_SRC_DIR}/utilities) + target_include_directories(${test_name} PRIVATE ${QASM_SIMULATOR_CPP_SRC_DIR}) + target_include_directories(${test_name} PRIVATE ${QASM_SIMULATOR_CPP_SRC_DIR}/backends) + target_include_directories(${test_name} PRIVATE ${QASM_SIMULATOR_CPP_SRC_DIR}/engines) + target_include_directories(${test_name} PRIVATE ${QASM_SIMULATOR_CPP_SRC_DIR}/utilities) set_target_properties(${test_name} PROPERTIES LINKER_LANGUAGE CXX) - # set_property(TARGET ${test_name} PROPERTY CXX_STANDARD 14) - target_link_libraries(${test_name} ${QISKIT_SIMULATOR_EXTERNAL_LIBRARIES}) + # set_property(TARGET ${test_name} PROPERTY CXX_STANDARD 11) + target_link_libraries(${test_name} ${QASM_SIMULATOR_CPP_EXTERNAL_LIBRARIES}) add_test(NAME ${test_name} COMMAND ${test_name}) if(NOT CMAKE_GENERATOR MATCHES "^Mingw") diff --git a/test/python/qobj/cpp_measure_opt.json b/test/python/qobj/cpp_measure_opt.json index cc66deb885a3..e0548154b020 100644 --- a/test/python/qobj/cpp_measure_opt.json +++ b/test/python/qobj/cpp_measure_opt.json @@ -1,7 +1,7 @@ { "id": "test_measure_opt", "config": { - "shots": 1000, + "shots": 2000, "seed": 1, "backend": "local_qasm_simulator_cpp" }, diff --git a/test/python/test_local_qasm_simulator_cpp.py b/test/python/test_local_qasm_simulator_cpp.py index 7a62dee32f11..2d1b7ec9c80c 100644 --- a/test/python/test_local_qasm_simulator_cpp.py +++ b/test/python/test_local_qasm_simulator_cpp.py @@ -62,7 +62,7 @@ def setUp(self): self.qobj = {'id': 'test_qobj', 'config': { 'max_credits': 3, - 'shots': 1024, + 'shots': 2000, 'backend': 'local_qiskit_simulator', 'seed': 1111 }, @@ -127,7 +127,7 @@ def test_cx_coherent_error_matrix(self): def test_run_qobj(self): result = self.backend.run(self.q_job) - shots = 1024 + shots = self.qobj['config']['shots'] threshold = 0.025 * shots counts = result.get_counts('test_circuit2') target = {'100 100': shots / 8, '011 011': shots / 8, @@ -144,7 +144,7 @@ def test_qobj_measure_opt(self): backend='local_qasm_simulator_cpp', preformatted=True) result = self.backend.run(q_job) - shots = 1000 + shots = q_job.qobj['config']['shots'] expected_data = { 'measure (opt)': { 'deterministic': True,