Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
qcor
Commits
975c2531
Commit
975c2531
authored
Aug 25, 2020
by
Mccaskey, Alex
Browse files
adding jit example
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
ef8197da
Pipeline
#116058
passed with stages
in 67 minutes and 36 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
examples/qjit/bell_jit.cpp
0 → 100644
View file @
975c2531
// To use the QCOR JIT utilities
// just include the qcor_jit.hpp header
#include "qcor_jit.hpp"
int
main
()
{
// QJIT is the entry point to QCOR quantum kernel
// just in time compilation
QJIT
qjit
;
// Define a quantum kernel string dynamically
const
auto
kernel_src
=
R"#(__qpu__ void bell(qreg q) {
using qcor::openqasm;
h q[0];
cx q[0], q[1];
creg c[2];
measure q -> c;
})#"
;
// Use the QJIT instance to compile this at runtime
qjit
.
jit_compile
(
kernel_src
);
// Now, one can get the compiled kernel as a
// functor to execute, must provide the kernel
// argument types as template parameters
auto
bell_functor
=
qjit
.
get_kernel
<
qreg
>
(
"bell"
);
// Allocate some qubits and run the kernel functor
auto
q
=
qalloc
(
2
);
bell_functor
(
q
);
q
.
print
();
// Or, one can call the QJIT invoke method
// with the name of the kernel function and
// the necessary function arguments.
auto
r
=
qalloc
(
2
);
qjit
.
invoke
(
"bell"
,
r
);
r
.
print
();
// Note, if QCOR QJIT has not seen this kernel
// source code before, it will run through the
// entire JIT compile process. If you have run
// this JIT compile before, QCOR QJIT will read a
// cached representation of the kernel and load that,
// increasing JIT compile performance.
}
\ No newline at end of file
examples/qjit/qcor_jit_test.cpp
deleted
100644 → 0
View file @
ef8197da
#include "qcor.hpp"
#include "qcor_jit.hpp"
int
main
()
{
QJIT
qjit
;
qjit
.
jit_compile
(
R"#(__qpu__ void bell(qreg q) {
printf("hello world\n");
using qcor::openqasm;
h q[0];
cx q[0], q[1];
creg c[2];
measure q -> c;
})#"
);
auto
q
=
qalloc
(
2
);
qjit
.
invoke
(
"bell"
,
q
);
q
.
print
();
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment