@@ -126,10 +126,12 @@ TEST(IBMPulseRemoteTester, checkCnotPulse) {
126
126
}
127
127
#endif
128
128
129
- // Check manipulations with frequency
130
- TEST (IBMPulseRemoteTester, checkFrequencyHandle ) {
129
+ // Check manipulations with phase and frequency
130
+ TEST (IBMPulseRemoteTester, sendPhaseFrequencyPulse ) {
131
131
xacc::set_verbose (true );
132
132
auto acc = xacc::getAccelerator (" ibm:ibmq_armonk" , {{" mode" , " pulse" }});
133
+ auto buffer = xacc::qalloc (1 );
134
+ auto provider = xacc::getService<xacc::IRProvider>(" quantum" );
133
135
std::string jjson (" {"
134
136
" \" pulse_library\" : ["
135
137
" {\" name\" : \" pulse1\" , \" samples\" : [[0,0],[0,0],[0,0]]},"
@@ -138,32 +140,50 @@ TEST(IBMPulseRemoteTester, checkFrequencyHandle) {
138
140
" ]"
139
141
" ,"
140
142
" \" cmd_def\" :["
141
- " {\" name\" :\" test_freq\" ,\" qubits\" :[0],\" sequence\" :["
142
- " {\" name\" :\" setf\" ,\" ch\" :\" d0\" ,\" t0\" :0,\" frequency\" :5}"
143
- " ,"
144
- " {\" name\" :\" shiftf\" ,\" ch\" :\" d0\" ,\" t0\" :0,\" frequency\" :-0.1}"
145
- " ,"
146
- " {\" name\" :\" setp\" ,\" ch\" :\" d0\" ,\" t0\" :0,\" phase\" :-1.57}"
143
+ " {\" name\" :\" test_phase\" ,\" qubits\" :[0],\" sequence\" :["
144
+ " {\" name\" :\" setp\" ,\" ch\" :\" d0\" ,\" t0\" :0,\" phase\" :1.57}"
147
145
" ,"
148
146
" {\" name\" :\" shiftp\" ,\" ch\" :\" d0\" ,\" t0\" :0,\" phase\" :0.1}"
149
147
" ]}"
150
148
" ,"
149
+ " {\" name\" :\" test_freq\" ,\" qubits\" :[0],\" sequence\" :["
150
+ " {\" name\" :\" setf\" ,\" ch\" :\" d0\" ,\" t0\" :0,\" frequency\" :5.1}"
151
+ " ,"
152
+ " {\" name\" :\" shiftf\" ,\" ch\" :\" d0\" ,\" t0\" :0,\" frequency\" :-0.21}"
153
+ " ]}"
154
+ " ,"
151
155
" {\" name\" :\" id2\" ,\" qubits\" :[0],\" sequence\" :[{\" name\" :\" setf\" ,\" ch\" :\" d0\" ,\" t0\" :0,\" frequency\" :5}]}"
152
156
" ] "
153
157
" }" );
154
158
155
159
acc->contributeInstructions (jjson);
156
- auto cr = xacc::getContributedService<xacc::Instruction>(" pulse::test_freq_0" );
157
- auto cr_comp =
158
- std::dynamic_pointer_cast<xacc::CompositeInstruction>(cr);
160
+ {
161
+ // ibmq_armonk does not support setp/shiftp pulse operations.
162
+ // test only contributeInstructions()
163
+ auto cr = xacc::getContributedService<xacc::Instruction>(" pulse::test_phase_0" );
164
+ auto cr_comp = std::dynamic_pointer_cast<xacc::CompositeInstruction>(cr);
159
165
160
- EXPECT_EQ (cr_comp->getInstructions ().size (), 4 );
166
+ EXPECT_EQ (cr_comp->getInstructions ().size (), 2 );
167
+ std::string checkNames[] = {" setp" , " shiftp" };
168
+ for ( int nI = 0 ; nI < 2 ; ++nI ) {
169
+ EXPECT_EQ (cr_comp->getInstruction (nI)->name (), checkNames[nI] );
170
+ }
171
+ }
161
172
162
- std::string checkNames[] = {" setf" , " shiftf" , " setp" , " shiftp" };
173
+ auto cr = xacc::getContributedService<xacc::Instruction>(" pulse::test_freq_0" );
174
+ auto cr_comp = std::dynamic_pointer_cast<xacc::CompositeInstruction>(cr);
163
175
164
- for ( int nI = 0 ; nI < 4 ; ++nI ) {
176
+ EXPECT_EQ (cr_comp->getInstructions ().size (), 2 );
177
+ std::string checkNames[] = {" setf" , " shiftf" };
178
+ for ( int nI = 0 ; nI < 2 ; ++nI ) {
165
179
EXPECT_EQ (cr_comp->getInstruction (nI)->name (), checkNames[nI] );
166
180
}
181
+
182
+ auto f = provider->createComposite (" tmp" );
183
+ auto m0 = provider->createInstruction (" Measure" , {0 });
184
+ f->addInstructions ({ cr_comp, m0 });
185
+ acc->execute (buffer, f);
186
+ buffer->print ();
167
187
}
168
188
169
189
int main (int argc, char **argv) {
0 commit comments