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
a8c72e95
Commit
a8c72e95
authored
Jul 12, 2017
by
Mccaskey, Alex
Browse files
Setting DWKernel to take a name
parent
6eecbec4
Changes
5
Hide whitespace changes
Inline
Side-by-side
impls/dwave/DWQMICompiler.cpp
View file @
a8c72e95
...
...
@@ -46,7 +46,6 @@ std::shared_ptr<IR> DWQMICompiler::compile(const std::string& src,
auto
runtimeOptions
=
RuntimeOptions
::
instance
();
auto
hardwareGraph
=
acc
->
getAcceleratorConnectivity
();
auto
dwKernel
=
std
::
make_shared
<
DWKernel
>
();
std
::
set
<
int
>
qubits
;
std
::
vector
<
std
::
shared_ptr
<
DWQMI
>>
instructions
;
int
nHardwareVerts
=
hardwareGraph
->
order
();
...
...
@@ -61,8 +60,14 @@ std::shared_ptr<IR> DWQMICompiler::compile(const std::string& src,
// brackets are, and then get the text between them.
// First off, split the string into lines
std
::
vector
<
std
::
string
>
lines
;
std
::
vector
<
std
::
string
>
lines
,
fLineSpaces
;
boost
::
split
(
lines
,
src
,
boost
::
is_any_of
(
"
\n
"
));
auto
functionLine
=
lines
[
0
];
boost
::
split
(
fLineSpaces
,
functionLine
,
boost
::
is_any_of
(
" "
));
auto
fName
=
fLineSpaces
[
1
];
boost
::
trim
(
fName
);
fName
=
fName
.
substr
(
0
,
fName
.
find_first_of
(
"("
));
auto
dwKernel
=
std
::
make_shared
<
DWKernel
>
(
fName
);
auto
firstCodeLine
=
lines
.
begin
()
+
1
;
auto
lastCodeLine
=
lines
.
end
()
-
1
;
std
::
vector
<
std
::
string
>
qmiStrVec
(
firstCodeLine
,
lastCodeLine
);
...
...
impls/dwave/tests/DWQMICompilerTester.cpp
View file @
a8c72e95
...
...
@@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(checkSimpleCompile) {
auto
ir
=
compiler
->
compile
(
simpleQMI
,
acc
);
auto
qmi
=
ir
->
getKernel
(
"dw
-k
ernel"
)
->
toString
(
""
);
auto
qmi
=
ir
->
getKernel
(
"dw
aveK
ernel"
)
->
toString
(
""
);
const
std
::
string
expectedQMI
=
"0 0 0.49
\n
"
"4 4 0.49
\n
"
...
...
@@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(checkShor15OneToOneMapping) {
auto
ir
=
compiler
->
compile
(
shor15QMI
,
acc
);
auto
qmi
=
ir
->
getKernel
(
"
dw-kernel
"
)
->
toString
(
""
);
auto
qmi
=
ir
->
getKernel
(
"
shor15
"
)
->
toString
(
""
);
std
::
cout
<<
qmi
<<
"
\n
"
;
...
...
quantum/aqc/ir/DWGraph.hpp
View file @
a8c72e95
...
...
@@ -9,6 +9,7 @@
#define QUANTUM_AQC_IR_DWGRAPH_HPP_
#include
"Graph.hpp"
#include
"Accelerator.hpp"
namespace
xacc
{
...
...
@@ -94,10 +95,10 @@ public:
virtual
~
CompleteGraph
()
{}
};
class
Chimera
:
public
DWGraph
{
class
Chimera
Graph
:
public
DWGraph
{
public:
Chimera
(
int
gridSize
)
:
DWGraph
(
8
*
gridSize
*
gridSize
)
{
Chimera
Graph
(
int
gridSize
)
:
DWGraph
(
8
*
gridSize
*
gridSize
)
{
// We are going to assign a tuple of ints to each vertex
std
::
map
<
std
::
tuple
<
int
,
int
,
int
,
int
>
,
int
>
vertexTuples
;
int
i
,
j
,
k
,
l
,
v
=
0
;
...
...
@@ -156,7 +157,7 @@ public:
}
}
virtual
~
Chimera
()
{}
virtual
~
Chimera
Graph
()
{}
};
}
...
...
quantum/aqc/ir/DWKernel.hpp
View file @
a8c72e95
...
...
@@ -49,6 +49,8 @@ protected:
std
::
list
<
InstPtr
>
instructions
;
std
::
string
name
;
public:
/**
...
...
@@ -57,7 +59,7 @@ public:
* @param id
* @param name
*/
DWKernel
()
{
DWKernel
(
std
::
string
kernelName
)
:
name
(
kernelName
)
{
}
virtual
const
int
nInstructions
()
{
...
...
@@ -112,7 +114,7 @@ public:
* @return
*/
virtual
const
std
::
string
getName
()
{
return
"dw-kernel"
;
return
name
;
}
/**
...
...
quantum/aqc/ir/tests/DWKernelTester.cpp
View file @
a8c72e95
...
...
@@ -43,13 +43,13 @@ BOOST_AUTO_TEST_CASE(checkDWKernelConstruction) {
auto
qmi2
=
std
::
make_shared
<
DWQMI
>
(
0
);
auto
qmi3
=
std
::
make_shared
<
DWQMI
>
(
22
,
3.3
);
DWKernel
kernel
;
DWKernel
kernel
(
"foo"
)
;
kernel
.
addInstruction
(
qmi
);
kernel
.
addInstruction
(
qmi2
);
kernel
.
addInstruction
(
qmi3
);
BOOST_VERIFY
(
kernel
.
nInstructions
()
==
3
);
BOOST_VERIFY
(
kernel
.
getName
()
==
"
dw-kernel
"
);
BOOST_VERIFY
(
kernel
.
getName
()
==
"
foo
"
);
BOOST_VERIFY
(
kernel
.
getInstruction
(
0
)
==
qmi
);
BOOST_VERIFY
(
kernel
.
getInstruction
(
1
)
==
qmi2
);
BOOST_VERIFY
(
kernel
.
getInstruction
(
2
)
==
qmi3
);
...
...
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