Skip to content

Commit 8f002a6

Browse files
author
XIN XIE
committed
Fix macOS Bazel NEON header exports
1 parent 4bf28d0 commit 8f002a6

2 files changed

Lines changed: 6 additions & 42 deletions

File tree

lib/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,13 @@ cc_library(
269269
"simulator_avx.h",
270270
"simulator_avx512.h",
271271
"simulator_basic.h",
272+
"simulator_neon.h",
272273
"simulator_sse.h",
273274
"statespace.h",
274275
"statespace_avx.h",
275276
"statespace_avx512.h",
276277
"statespace_basic.h",
278+
"statespace_neon.h",
277279
"statespace_sse.h",
278280
"umux.h",
279281
"unitary_calculator_avx.h",
@@ -316,11 +318,13 @@ cc_library(
316318
"simulator_avx.h",
317319
"simulator_avx512.h",
318320
"simulator_basic.h",
321+
"simulator_neon.h",
319322
"simulator_sse.h",
320323
"statespace.h",
321324
"statespace_avx.h",
322325
"statespace_avx512.h",
323326
"statespace_basic.h",
327+
"statespace_neon.h",
324328
"statespace_sse.h",
325329
"util.h",
326330
"util_cpu.h",

lib/simulator_neon.h

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
#include <vector>
2222

2323
#include "simulator.h"
24-
#include "simulator_basic.h"
25-
#include "statespace_basic.h"
2624
#include "statespace_neon.h"
2725

2826
namespace qsim {
@@ -36,12 +34,9 @@ class SimulatorNEON final : public SimulatorBase {
3634
using StateSpace = StateSpaceNEON<For>;
3735
using State = typename StateSpace::State;
3836
using fp_type = typename StateSpace::fp_type;
39-
using BasicStateSpace = StateSpaceBasic<For, float>;
40-
using BasicState = typename BasicStateSpace::State;
4137

4238
template <typename... ForArgs>
43-
explicit SimulatorNEON(ForArgs&&... args)
44-
: for_(args...), basic_state_space_(args...), fallback_(args...) {}
39+
explicit SimulatorNEON(ForArgs&&... args) : for_(args...) {}
4540

4641
/**
4742
* Applies a gate using NEON instructions.
@@ -109,7 +104,6 @@ class SimulatorNEON final : public SimulatorBase {
109104
default:
110105
break;
111106
}
112-
ApplyGateFallback(qs, matrix, state);
113107
}
114108

115109
/**
@@ -262,9 +256,6 @@ class SimulatorNEON final : public SimulatorBase {
262256
default:
263257
break;
264258
}
265-
auto basic_state = CreateBasicState(state);
266-
fallback_.ApplyControlledGate(qs, cqs, cvals, matrix, basic_state);
267-
CopyBasicStateToNeon(basic_state, state);
268259
}
269260

270261
std::complex<double> ExpectationValue(
@@ -320,8 +311,7 @@ class SimulatorNEON final : public SimulatorBase {
320311
default:
321312
break;
322313
}
323-
auto basic_state = CreateBasicState(state);
324-
return fallback_.ExpectationValue(qs, matrix, basic_state);
314+
return 0;
325315
}
326316

327317
static unsigned SIMDRegisterSize() { return 4; }
@@ -902,37 +892,7 @@ class SimulatorNEON final : public SimulatorBase {
902892
using Op = std::plus<std::complex<double>>;
903893
return for_.RunReduce(size, f, Op(), w, ms, xss, qs[0], state.get());
904894
}
905-
BasicState CreateBasicState(const State& state) const {
906-
auto basic_state = BasicStateSpace::Create(state.num_qubits());
907-
CopyNeonStateToBasic(state, basic_state);
908-
return basic_state;
909-
}
910-
911-
void CopyNeonStateToBasic(const State& src, BasicState& dest) const {
912-
uint64_t size = uint64_t{1} << src.num_qubits();
913-
for (uint64_t i = 0; i < size; ++i) {
914-
BasicStateSpace::SetAmpl(dest, i, StateSpace::GetAmpl(src, i));
915-
}
916-
}
917-
918-
void CopyBasicStateToNeon(const BasicState& src, State& dest) const {
919-
uint64_t size = uint64_t{1} << dest.num_qubits();
920-
for (uint64_t i = 0; i < size; ++i) {
921-
StateSpace::SetAmpl(dest, i, BasicStateSpace::GetAmpl(src, i));
922-
}
923-
}
924-
925-
void ApplyGateFallback(
926-
const std::vector<unsigned>& qs, const fp_type* matrix,
927-
State& state) const {
928-
auto basic_state = CreateBasicState(state);
929-
fallback_.ApplyGate(qs, matrix, basic_state);
930-
CopyBasicStateToNeon(basic_state, state);
931-
}
932-
933895
For for_;
934-
BasicStateSpace basic_state_space_;
935-
SimulatorBasic<For, float> fallback_;
936896
};
937897

938898
} // namespace qsim

0 commit comments

Comments
 (0)