XACC
xacc_internal_compiler.hpp
1 /*******************************************************************************
2  * Copyright (c) 2020 UT-Battelle, LLC.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * and Eclipse Distribution License v1.0 which accompanies this
6  * distribution. The Eclipse Public License is available at
7  * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
8  *License is available at https://eclipse.org/org/documents/edl-v10.php
9  *
10  * Contributors:
11  * Alexander J. McCaskey - initial API and implementation
12  *******************************************************************************/
13 #ifndef XACC_XACC_INTERNAL_COMPILER_HPP_
14 #define XACC_XACC_INTERNAL_COMPILER_HPP_
15 
16 #include <vector>
17 #include <memory>
18 
19 namespace xacc {
20 class CompositeInstruction;
21 class AcceleratorBuffer;
22 class Accelerator;
23 
24 namespace internal_compiler {
25 extern std::shared_ptr<Accelerator> qpu;
26 extern std::shared_ptr<CompositeInstruction> lastCompiled;
27 extern bool __execute;
28 
29 enum OptLevel { DEFAULT, LEVEL1, LEVEL2, LEVEL3 };
30 
31 void compiler_InitializeXACC(const char *qpu_backend = "qpp");
32 void compiler_InitializeXACC(const char *qpu_backend, int shots);
33 
34 void setAccelerator(const char *qpu_backend);
35 void setAccelerator(const char *qpu_backend, int shots);
36 std::shared_ptr<Accelerator> get_qpu();
37 
38 void __set_verbose(bool verbose);
39 
40 // Map kernel source string representing a single
41 // kernel function to a single CompositeInstruction (src to IR)
42 std::shared_ptr<CompositeInstruction> compile(const char *compiler_name,
43  const char *kernel_src);
44 
45 std::shared_ptr<CompositeInstruction> getLastCompiled();
46 std::shared_ptr<CompositeInstruction> getCompiled(const char *kernel_name);
47 
48 // Run quantum compilation routines on IR
49 void optimize(std::shared_ptr<CompositeInstruction> program, const OptLevel opt = DEFAULT);
50 
51 // Execute on the specified QPU, persisting results to
52 // the provided buffer.
53 void execute(AcceleratorBuffer *buffer, std::vector<std::shared_ptr<CompositeInstruction>> programs);
54 void execute(AcceleratorBuffer *buffer, std::shared_ptr<CompositeInstruction> program,
55  double *parameters = nullptr);
56 void execute(AcceleratorBuffer **buffers, const int nBuffers,
57  std::shared_ptr<CompositeInstruction> program, double *parameters = nullptr);
58 } // namespace internal_compiler
59 } // namespace xacc
60 
61 #endif
Definition: Accelerator.hpp:25