Initial Thread-Safe Implementation
Created by: ahayashi
Add thread-safety to XACC/QCOR (Experimental). We introduce _XACC_MUTEX
macro in xacc.hpp
to turn on/off the feature (default is OFF). When the macro is ON, only a single thread can execute the following routines by using eit
her std::mutex
or std::recursive_mutex
:
-
User-facing API routines
-
createObjectiveFunction()
(qcor::__internal__::get_objective()
) createOptimizer()
-
-
Compiler-related modules
- Syntax Handler
QuantumKernel::operator()
QuantumKernel::~QuantumKernel()
- QJIT
QJIT::QJIT()
QJIT::jit_compile()
QJIT::write_cache()
- Syntax Handler
Also, regardless of the macro, the VQEObjective
class is now xacc::Cloneable
.
Add the following test files to test multi-thread execution. It is worth noting that, when the macro is OFF, these test programs are executed sequentially.
examples/simple/bell_threaded.cpp
examples/simple/simple-objective-function-async.cpp
examples/simple/simple-objective-function-threaded.cpp
examples/qpu_lambda/deuteron_threaded.cpp
examples/qpu_lambda/deuteron_vqe_threaded.cpp
examples/qpu_lambda/deuteron_vqe_obj_func_threaded.cpp
examples/qpu_lambda/lambda_test_bell_threaded.cpp