Skip to content

Commit 3861741

Browse files
committed
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>
1 parent 35c1260 commit 3861741

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

examples/CMakeLists.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ add_qcor_compile_and_exe_test(qrt_qpu_arith_adder arithmetic/simple.cpp)
7777
add_qcor_compile_and_exe_test(qrt_qpu_arith_integer_add arithmetic/integer_add.cpp)
7878

7979
# Multi-threading tests
80-
add_test(NAME qrt_simple-objective-function-async COMMAND ${CMAKE_BINARY_DIR}/qcor -c ${CMAKE_CURRENT_SOURCE_DIR}/simple/simple-objective-function-async.cpp)
81-
add_test(NAME qrt_simple-objective-function-threaded COMMAND ${CMAKE_BINARY_DIR}/qcor -c ${CMAKE_CURRENT_SOURCE_DIR}/simple/simple-objective-function-threaded.cpp)
82-
add_test(NAME qrt_bell-threaded COMMAND ${CMAKE_BINARY_DIR}/qcor -c ${CMAKE_CURRENT_SOURCE_DIR}/simple/bell_threaded.cpp)
80+
add_qcor_compile_and_exe_test(qrt_simple-objective-function-async simple/simple-objective-function-async.cpp)
81+
add_qcor_compile_and_exe_test(qrt_simple-objective-function-threaded simple/simple-objective-function-threaded.cpp)
82+
add_qcor_compile_and_exe_test(qrt_bell-threaded simple/bell_threaded.cpp)
8383
add_qcor_compile_and_exe_test(qrt_qpu_lambda_bell_threaded qpu_lambda/lambda_test_bell_threaded.cpp)
84-
add_qcor_compile_and_exe_test(qrt_qpu_lambda_deuteron_threaded qpu_lambda/deuteron_threaded.cpp)
8584
add_qcor_compile_and_exe_test(qrt_qpu_lambda_deuteron_vqe_threaded qpu_lambda/deuteron_vqe_threaded.cpp)
8685
add_qcor_compile_and_exe_test(qrt_qpu_lambda_deuteron_vqe_objfunc_threaded qpu_lambda/deuteron_vqe_obj_func_threaded.cpp)
8786

examples/qpu_lambda/deuteron_vqe_threaded.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@ void foo() {
2525
CX(q[1], q[0]);
2626
});
2727

28-
OptFunction opt_function(
29-
[&](std::vector<double> x) { return ansatz.observe(H, qalloc(2), x[0]); },
30-
1);
31-
32-
OptFunction opt_function_vec(
28+
ObjectiveFunction opt_function_vec(
3329
[&](std::vector<double> x) {
3430
return ansatz_take_vec.observe(H, qalloc(2), x);
3531
},
3632
1);
3733

34+
// Show off optimize from ObjectiveFunction rvalue
3835
auto optimizer = createOptimizer("nlopt");
39-
auto [ground_energy, opt_params] = optimizer->optimize(opt_function);
36+
auto [ground_energy, opt_params] = optimizer->optimize(ObjectiveFunction(
37+
[&](std::vector<double> x) { return ansatz.observe(H, qalloc(2), x[0]); },
38+
1));
4039
print("Energy: ", ground_energy);
4140
qcor_expect(std::abs(ground_energy + 1.74886) < 0.1);
4241

0 commit comments

Comments
 (0)