XACC
messages.hpp
1 /*******************************************************************************
2  * Copyright (c) 2019 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 QUANTUM_GATE_ACCELERATORS_QCS_MESSAGES_HPP_
14 #define QUANTUM_GATE_ACCELERATORS_QCS_MESSAGES_HPP_
15 
16 #include <msgpack.hpp>
17 #include <vector>
18 namespace xacc {
19 namespace qcs {
20 
22 protected:
23  int num_shots = 1024;
24  std::string quil;
25  std::string _type = "BinaryExecutableRequest";
26 public:
27  BinaryExecutableRequest() = default;
28  BinaryExecutableRequest(int s, std::string q) : quil(q), num_shots(s) {}
29  BinaryExecutableRequest(const BinaryExecutableRequest& r) :quil(r.quil), num_shots(r.num_shots) {}
30  MSGPACK_DEFINE_MAP(quil, num_shots, _type);
31 };
32 
34 protected:
35  bool wait = true;
36  std::vector<std::string> args;
37  public:
38  GetBuffersRequest(std::string id) : args({id}) {}
39  MSGPACK_DEFINE_MAP(wait, MSGPACK_NVP("*args", args));
40 };
41 
42 struct QType {
43  std::vector<int> shape;
44  std::string dtype;
45  std::vector<char> data;
46  MSGPACK_DEFINE_MAP(shape, dtype, data);
47 };
48 
50 public:
51  std::string id = "";
52  std::string jsonrpc = "2.0";
53  std::map<std::string, QType> result;
54  std::vector<int> warnings = {};
55  std::string _type = "RPCReply";
56  MSGPACK_DEFINE_MAP(id, jsonrpc, warnings, _type, result);
57 };
58 
60 protected:
61  std::string id;
62  std::string jsonrpc = "2.0";
63  std::string method = "get_buffers";
64  GetBuffersRequest& params;
65  std::string _type = "RPCRequest";
66 
67 public:
68  RPCRequestGetBuffers(std::string i, GetBuffersRequest &p) : params(p), id(i) {}
69  MSGPACK_DEFINE_MAP(method, id, jsonrpc, params, _type);
70 };
71 
73 protected:
74  std::vector<BinaryExecutableRequest> args;
75 
76 public:
78  args.push_back(a);
79  }
80  MSGPACK_DEFINE_MAP(MSGPACK_NVP("*args", args));
81 };
82 
84 protected:
85  std::string id;
86  std::string jsonrpc = "2.0";
87  std::string method = "native_quil_to_binary";
88  BinaryExecutableParams& params;
89  std::string _type = "RPCRequest";
90 
91 public:
92  RPCRequestBinaryExecutable(std::string i, BinaryExecutableParams &p) :params(p), id(i) {}
93  MSGPACK_DEFINE_MAP(method, id, jsonrpc, params, _type);
94 };
95 
96 class QPURequest {
97  protected:
98  std::string program;
99  std::string id;
100  std::map<std::string,std::string> patch_values;
101  std::string _type = "QPURequest";
102 
103  public:
104  QPURequest(std::string p, std::string i) : program(p), id(i) {}
105  MSGPACK_DEFINE_MAP(id, program, _type, patch_values);
106 };
107 
109 protected:
110  QPURequest& request;
111  std::string user = "";
112  int priority = 1;
113 public:
114  QPURequestParams(QPURequest &a, std::string& uid) : request(a), user(uid) {}
115  MSGPACK_DEFINE_MAP(MSGPACK_NVP("request", request), user, priority);
116 };
117 
119 protected:
120  std::string id;
121  std::string jsonrpc = "2.0";
122  std::string method = "execute_qpu_request";
123  QPURequestParams& params;
124  std::string _type = "RPCRequest";
125  msgpack::type::nil_t client_key;
126 // double client_tim/eout;
127 
128 public:
129  RPCRequestQPURequest(std::string i, QPURequestParams &p) : params(p), id(i) {}
130  MSGPACK_DEFINE_MAP(method, id, jsonrpc, params, _type, client_key);
131 };
132 
133 }
134 }
135 #endif
Definition: messages.hpp:21
Definition: messages.hpp:96
Definition: messages.hpp:118
Definition: Accelerator.hpp:25
Definition: messages.hpp:49
Definition: messages.hpp:59
Definition: messages.hpp:72
Definition: messages.hpp:42
Definition: messages.hpp:33
Definition: messages.hpp:108
Definition: messages.hpp:83