Skip to content

Commit

Permalink
Fix a bug in aer_apply_measure in libaer and enable libaer build in…
Browse files Browse the repository at this point in the history
… Mac (#1860)

* support all platform for libaer. fix a bug in aer_apply_measure in libaer

* build libaer only in Linux and Darwin
  • Loading branch information
hhorii authored Jul 6, 2023
1 parent a052ccf commit 04a6cab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,7 @@ else() # Standalone build

install(TARGETS qasm_simulator DESTINATION bin)

# build libaer.so (currently, Linux on x86 is supportted)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(AER_RUNTIME_SOURCE "${PROJECT_SOURCE_DIR}/contrib/runtime/aer_runtime.cpp")
if(CUDA_FOUND AND AER_THRUST_BACKEND STREQUAL "CUDA")
build_cuda(aer ${AER_RUNTIME_SOURCE} FALSE)
Expand Down
4 changes: 2 additions & 2 deletions contrib/runtime/aer_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
#include "controllers/state_controller.hpp"
#include <cmath>
#include <stdio.h>

// initialize and return state
extern "C" {
Expand Down Expand Up @@ -51,8 +52,7 @@ uint_t aer_allocate_qubits(void *handler, uint_t num_qubits) {
// measure qubits
uint_t aer_apply_measure(void *handler, uint_t *qubits_, size_t num_qubits) {
AER::AerState *state = reinterpret_cast<AER::AerState *>(handler);
std::vector<uint_t> qubits;
qubits.insert(qubits.end(), &(qubits_[0]), &(qubits[num_qubits - 1]));
std::vector<uint_t> qubits(qubits_, qubits_ + num_qubits);
return state->apply_measure(qubits);
};

Expand Down

0 comments on commit 04a6cab

Please sign in to comment.