Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
f5e68b73
Commit
f5e68b73
authored
Aug 08, 2017
by
Mccaskey, Alex
Browse files
Adding runtime kernels to Program
parent
bc3c58bd
Changes
5
Hide whitespace changes
Inline
Side-by-side
quantum/aqc/compiler/default/DefaultParameterSetter.cpp
View file @
f5e68b73
...
...
@@ -63,8 +63,7 @@ std::list<std::shared_ptr<DWQMI>> DefaultParameterSetter::setParameters(
for
(
auto
&
embKv
:
embedding
)
{
auto
probVert
=
embKv
.
first
;
auto
hardwareMapping
=
embKv
.
second
;
auto
newBias
=
std
::
get
<
0
>
(
problemGraph
->
getVertexProperties
(
probVert
))
/
hardwareMapping
.
size
();
auto
newBias
=
std
::
get
<
0
>
(
problemGraph
->
getVertexProperties
(
probVert
))
/
hardwareMapping
.
size
();
for
(
auto
h
:
hardwareMapping
)
{
auto
embeddedInst
=
std
::
make_shared
<
DWQMI
>
(
h
,
h
,
newBias
);
instList
.
push_back
(
embeddedInst
);
...
...
xacc/accelerator/AcceleratorBuffer.hpp
View file @
f5e68b73
...
...
@@ -117,7 +117,7 @@ public:
return
bufferId
;
}
void
resetBuffer
()
{
virtual
void
resetBuffer
()
{
measurements
.
clear
();
}
...
...
@@ -125,11 +125,11 @@ public:
bits
[
idx
].
update
(
zeroOrOne
);
}
void
appendMeasurement
(
const
boost
::
dynamic_bitset
<>&
measurement
)
{
virtual
void
appendMeasurement
(
const
boost
::
dynamic_bitset
<>&
measurement
)
{
measurements
.
push_back
(
measurement
);
}
double
getAverage
()
const
{
virtual
double
getAverage
()
const
{
//std::assert(measurements.size()>0);
std
::
stringstream
ss
;
double
aver
=
0.
;
...
...
xacc/compiler/Compiler.hpp
View file @
f5e68b73
...
...
@@ -103,6 +103,10 @@ public:
return
false
;
}
virtual
const
int
getNQubitsUsed
()
const
{
return
0
;
}
/**
* The destructor
*/
...
...
xacc/program/Kernel.hpp
View file @
f5e68b73
...
...
@@ -47,9 +47,22 @@ public:
accelerator
->
execute
(
buffer
,
function
);
}
void
operator
()(
std
::
shared_ptr
<
AcceleratorBuffer
>
buffer
,
std
::
vector
<
InstructionParameter
>
parameters
)
{
function
->
evaluateVariableParameters
(
parameters
);
accelerator
->
execute
(
buffer
,
function
);
}
void
prepend
(
const
std
::
shared_ptr
<
Function
>
prependFunction
)
{
function
->
insertInstruction
(
0
,
prependFunction
);
}
const
int
getNumberOfKernelParameters
()
{
return
function
->
nParameters
();
}
std
::
shared_ptr
<
Function
>
getIRFunction
()
{
return
function
;
}
};
}
...
...
xacc/program/Program.hpp
View file @
f5e68b73
...
...
@@ -185,6 +185,13 @@ public:
return
;
}
void
transformIR
(
std
::
shared_ptr
<
IRTransformation
>
transformation
)
{
if
(
xaccIR
)
{
xaccIR
=
transformation
->
transform
(
xaccIR
);
}
}
/**
* Return an executable version of the kernel
* referenced by the kernelName string.
...
...
@@ -224,6 +231,19 @@ public:
return
kernels
;
}
auto
getRuntimeKernels
()
->
std
::
vector
<
Kernel
<>>
{
std
::
vector
<
Kernel
<>>
kernels
;
if
(
!
xaccIR
)
{
build
();
}
for
(
auto
k
:
xaccIR
->
getKernels
())
{
kernels
.
push_back
(
Kernel
<>
(
accelerator
,
k
));
}
return
kernels
;
}
};
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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