Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Thread-Safe Implementation #157

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Commits on Jul 21, 2021

  1. Initial Thread-Safe Implementation

    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 either `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()`
    
    Also, regardless of the macro, the `VQEObjective` class is now `xacc::Cloneable`.
    
    Add the following test files to test multi-thread execution
    
    - `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`
    
    Signed-off-by: Akihiro Hayashi <ahayashi@gatech.edu>
    ahayashi committed Jul 21, 2021
    Configuration menu
    Copy the full SHA
    d64adfb View commit details
    Browse the repository at this point in the history
  2. Add _QCOR_MUTEX, which is defined when XACC is configured with XACC_M…

    …ULTI_THREADED
    
    Signed-off-by: Akihiro Hayashi <ahayashi@gatech.edu>
    ahayashi committed Jul 21, 2021
    Configuration menu
    Copy the full SHA
    35c1260 View commit details
    Browse the repository at this point in the history
  3. Use add_qcor_compile_and_exe_test for the multi-threading examples.

    Remove deuteron_threaded.cpp from ctest
    
    Signed-off-by: Akihiro Hayashi <ahayashi@gatech.edu>
    ahayashi committed Jul 21, 2021
    Configuration menu
    Copy the full SHA
    3861741 View commit details
    Browse the repository at this point in the history