GateQuantumActivator.cpp 3.88 KB
Newer Older
1
2
3
4
5
6
7
8
/*******************************************************************************
 * Copyright (c) 2017 UT-Battelle, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v1.0 which accompanies this
 * distribution. The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License
 * is available at https://eclipse.org/org/documents/edl-v10.php
9
10
 *
 * Contributors:
11
12
 *   Alexander J. McCaskey - initial API and implementation
 *******************************************************************************/
13
14
15
#include "QFT.hpp"
#include "InverseQFT.hpp"
#include "KernelReplacementPreprocessor.hpp"
16
#include "ReadoutErrorIRPreprocessor.hpp"
17
#include "QubitMapIRPreprocessor.hpp"
18
19
20
21
#include "cppmicroservices/BundleActivator.h"
#include "cppmicroservices/BundleContext.h"
#include "cppmicroservices/ServiceProperties.h"

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "GateInstructionService.hpp"
#include "Hadamard.hpp"
#include "CNOT.hpp"
#include "X.hpp"
#include "Y.hpp"
#include "Z.hpp"
#include "ConditionalFunction.hpp"
#include "Rz.hpp"
#include "Rx.hpp"
#include "Ry.hpp"
#include "CPhase.hpp"
#include "Swap.hpp"
#include "Measure.hpp"
#include "Identity.hpp"
#include "CZ.hpp"

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <memory>
#include <set>

using namespace cppmicroservices;

namespace {

/**
 */
class US_ABI_LOCAL GateQuantumActivator: public BundleActivator {

public:

	GateQuantumActivator() {
	}

	/**
	 */
	void Start(BundleContext context) {
		auto qft = std::make_shared<xacc::quantum::QFT>();
		auto iqft = std::make_shared<xacc::quantum::InverseQFT>();
		auto kp =
				std::make_shared<xacc::quantum::KernelReplacementPreprocessor>();
61
62

		auto readout = std::make_shared<xacc::quantum::ReadoutErrorIRPreprocessor>();
63
		auto qbitmap = std::make_shared<xacc::quantum::QubitMapIRPreprocessor>();
64

65
66
67
		auto giservice = std::make_shared<xacc::quantum::GateInstructionService>();

		context.RegisterService<xacc::InstructionService>(giservice);
68
		context.RegisterService<xacc::Preprocessor>(kp);
69
70
		context.RegisterService<xacc::IRGenerator>(iqft);
		context.RegisterService<xacc::IRGenerator>(qft);
71
72

		context.RegisterService<xacc::IRPreprocessor>(readout);
73
74
		context.RegisterService<xacc::IRPreprocessor>(qbitmap);

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
		auto h = std::make_shared<xacc::quantum::Hadamard>();
		auto cn = std::make_shared<xacc::quantum::CNOT>();
		auto cp = std::make_shared<xacc::quantum::CPhase>();
		auto cz = std::make_shared<xacc::quantum::CZ>();
		auto id = std::make_shared<xacc::quantum::Identity>();
		auto m = std::make_shared<xacc::quantum::Measure>();
		auto rx = std::make_shared<xacc::quantum::Rx>();
		auto ry = std::make_shared<xacc::quantum::Ry>();
		auto rz = std::make_shared<xacc::quantum::Rz>();
		auto x = std::make_shared<xacc::quantum::X>();
		auto y = std::make_shared<xacc::quantum::Y>();
		auto z = std::make_shared<xacc::quantum::Z>();
		auto sw = std::make_shared<xacc::quantum::Swap>();

		context.RegisterService<xacc::quantum::GateInstruction>(h);
		context.RegisterService<xacc::quantum::GateInstruction>(cn);
		context.RegisterService<xacc::quantum::GateInstruction>(cp);
		context.RegisterService<xacc::quantum::GateInstruction>(cz);
		context.RegisterService<xacc::quantum::GateInstruction>(id);
		context.RegisterService<xacc::quantum::GateInstruction>(m);
		context.RegisterService<xacc::quantum::GateInstruction>(rx);
		context.RegisterService<xacc::quantum::GateInstruction>(ry);
		context.RegisterService<xacc::quantum::GateInstruction>(rz);
		context.RegisterService<xacc::quantum::GateInstruction>(x);
		context.RegisterService<xacc::quantum::GateInstruction>(y);
		context.RegisterService<xacc::quantum::GateInstruction>(z);
		context.RegisterService<xacc::quantum::GateInstruction>(sw);

103
104
105
106
107
108
109
110
111
112
113
114
	}

	/**
	 */
	void Stop(BundleContext /*context*/) {
	}

};

}

CPPMICROSERVICES_EXPORT_BUNDLE_ACTIVATOR(GateQuantumActivator)