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
f29fd47e
Commit
f29fd47e
authored
Jan 23, 2018
by
Mccaskey, Alex
Browse files
Implemented new XACCLogger and api functions for using it (#22)
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
429fd55b
Changes
22
Hide whitespace changes
Inline
Side-by-side
quantum/aqc/compiler/CMakeLists.txt
View file @
f29fd47e
...
...
@@ -12,5 +12,5 @@
# *******************************************************************************/
# Gather tests
file
(
GLOB test_files tests/*.cpp
)
add_tests
(
"
${
test_files
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"
${
LIBRARY_NAME
}
;
${
Boost_LIBRARIES
}
;dl;pthread;xacc-quantum-aqc"
)
add_tests
(
"
${
test_files
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"
${
LIBRARY_NAME
}
;
${
Boost_LIBRARIES
}
;dl;pthread;xacc-quantum-aqc
;xacc
"
)
quantum/aqc/compiler/default/TrivialEmbeddingAlgorithm.cpp
View file @
f29fd47e
...
...
@@ -31,12 +31,12 @@ Embedding TrivialEmbeddingAlgorithm::embed(
if
(
i
<
j
&&
i
!=
j
&&
(
problem
->
edgeExists
(
i
,
j
)
&&
!
hdware
->
edgeExists
(
i
,
j
)))
{
if
(
failHard
)
{
XACC
E
rror
(
XACC
Logger
::
instance
()
->
e
rror
(
"Trivial Embedding not possible, there is no hardware edge corresponding to ("
+
std
::
to_string
(
i
)
+
", "
+
std
::
to_string
(
j
)
+
") problem edge."
);
}
else
{
XACC
I
nfo
(
"This embedding failed, but user requested to not fail hard. Returning empty embedding."
);
XACC
Logger
::
instance
()
->
i
nfo
(
"This embedding failed, but user requested to not fail hard. Returning empty embedding."
);
xaccEmbedding
.
clear
();
return
xaccEmbedding
;
}
...
...
quantum/aqc/ir/CMakeLists.txt
View file @
f29fd47e
...
...
@@ -12,5 +12,5 @@
# *******************************************************************************/
# Gather tests
file
(
GLOB test_files tests/*.cpp
)
add_tests
(
"
${
test_files
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"
${
Boost_LIBRARIES
}
"
)
add_tests
(
"
${
test_files
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"
${
Boost_LIBRARIES
}
;xacc
"
)
quantum/aqc/ir/DWIR.hpp
View file @
f29fd47e
...
...
@@ -67,7 +67,7 @@ public:
return
f
;
}
}
XACC
E
rror
(
"Invalid kernel name - "
+
name
);
XACC
Logger
::
instance
()
->
e
rror
(
"Invalid kernel name - "
+
name
);
}
virtual
std
::
vector
<
std
::
shared_ptr
<
Function
>>
getKernels
()
{
...
...
quantum/aqc/ir/DWKernel.hpp
View file @
f29fd47e
...
...
@@ -51,7 +51,7 @@ public:
if
(
instructions
.
size
()
>
idx
)
{
return
*
std
::
next
(
instructions
.
begin
(),
idx
);
}
else
{
XACC
E
rror
(
"Invalid instruction index."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Invalid instruction index."
);
}
}
...
...
@@ -142,19 +142,19 @@ public:
}
virtual
InstructionParameter
getParameter
(
const
int
idx
)
const
{
XACC
E
rror
(
"DWKernel does not contain runtime parameters."
);
XACC
Logger
::
instance
()
->
e
rror
(
"DWKernel does not contain runtime parameters."
);
}
virtual
void
setParameter
(
const
int
idx
,
InstructionParameter
&
p
)
{
XACC
E
rror
(
"DWKernel does not contain runtime parameters."
);
XACC
Logger
::
instance
()
->
e
rror
(
"DWKernel does not contain runtime parameters."
);
}
virtual
std
::
vector
<
InstructionParameter
>
getParameters
()
{
XACC
E
rror
(
"DWKernel does not contain runtime parameters."
);
XACC
Logger
::
instance
()
->
e
rror
(
"DWKernel does not contain runtime parameters."
);
}
virtual
void
addParameter
(
InstructionParameter
instParam
)
{
XACC
E
rror
(
"DWKernel does not contain runtime parameters."
);
XACC
Logger
::
instance
()
->
e
rror
(
"DWKernel does not contain runtime parameters."
);
}
virtual
bool
isParameterized
()
{
...
...
@@ -166,7 +166,7 @@ public:
}
virtual
void
evaluateVariableParameters
(
std
::
vector
<
InstructionParameter
>
parameters
)
{
XACC
E
rror
(
"DWKernel does not contain runtime parameters."
);
XACC
Logger
::
instance
()
->
e
rror
(
"DWKernel does not contain runtime parameters."
);
}
...
...
quantum/gate/compiler/KernelReplacementPreprocessor.cpp
View file @
f29fd47e
...
...
@@ -25,7 +25,7 @@ const std::string KernelReplacementPreprocessor::process(const std::string& sour
std
::
shared_ptr
<
Compiler
>
compiler
,
std
::
shared_ptr
<
Accelerator
>
accelerator
)
{
XACC
I
nfo
(
"Running Kernel Replacement Preprocessor.
\n
"
);
XACC
Logger
::
instance
()
->
i
nfo
(
"Running Kernel Replacement Preprocessor.
\n
"
);
// Find any occurrences of xacc::FUNCTION
// Get the first occurrence
...
...
quantum/gate/ir/CMakeLists.txt
View file @
f29fd47e
...
...
@@ -13,5 +13,5 @@
# Gather tests
file
(
GLOB test_files tests/*.cpp
)
add_tests
(
"
${
test_files
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"
${
LIBRARY_NAME
}
;
${
Boost_LIBRARIES
}
;xacc-quantum-gate"
)
add_tests
(
"
${
test_files
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"
${
LIBRARY_NAME
}
;
${
Boost_LIBRARIES
}
;xacc
;xacc
-quantum-gate"
)
quantum/gate/ir/GateFunction.hpp
View file @
f29fd47e
...
...
@@ -72,7 +72,7 @@ public:
if
(
instructions
.
size
()
>
idx
)
{
return
*
std
::
next
(
instructions
.
begin
(),
idx
);
}
else
{
XACC
E
rror
(
"Invalid instruction index."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Invalid instruction index."
);
}
}
...
...
@@ -142,7 +142,7 @@ public:
virtual
InstructionParameter
getParameter
(
const
int
idx
)
const
{
if
(
idx
+
1
>
parameters
.
size
())
{
XACC
E
rror
(
"Invalid Parameter requested."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Invalid Parameter requested."
);
}
return
parameters
[
idx
];
...
...
@@ -150,7 +150,7 @@ public:
virtual
void
setParameter
(
const
int
idx
,
InstructionParameter
&
p
)
{
if
(
idx
+
1
>
parameters
.
size
())
{
XACC
E
rror
(
"Invalid Parameter requested."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Invalid Parameter requested."
);
}
parameters
[
idx
]
=
p
;
...
...
quantum/gate/ir/GateInstruction.hpp
View file @
f29fd47e
...
...
@@ -130,7 +130,7 @@ public:
virtual
InstructionParameter
getParameter
(
const
int
idx
)
const
{
if
(
idx
+
1
>
parameters
.
size
())
{
XACC
E
rror
(
"Invalid Parameter requested from Parameterized Gate Instruction."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Invalid Parameter requested from Parameterized Gate Instruction."
);
}
return
parameters
[
idx
];
...
...
@@ -138,7 +138,7 @@ public:
virtual
void
setParameter
(
const
int
idx
,
InstructionParameter
&
p
)
{
if
(
idx
+
1
>
parameters
.
size
())
{
XACC
E
rror
(
"Invalid Parameter requested from Parameterized Gate Instruction."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Invalid Parameter requested from Parameterized Gate Instruction."
);
}
parameters
[
idx
]
=
p
;
...
...
quantum/gate/ir/GateQIR.hpp
View file @
f29fd47e
...
...
@@ -97,7 +97,7 @@ public:
return
f
;
}
}
XACC
E
rror
(
"Invalid kernel name."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Invalid kernel name."
);
}
virtual
bool
kernelExists
(
const
std
::
string
&
name
)
{
...
...
quantum/gate/utils/CMakeLists.txt
View file @
f29fd47e
...
...
@@ -14,6 +14,6 @@ include_directories(${CMAKE_SOURCE_DIR}/tpls/eigen)
# Gather tests
file
(
GLOB test_files tests/*.cpp
)
add_tests
(
"
${
test_files
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"
${
Boost_LIBRARIES
}
;xacc-quantum-gate"
)
add_tests
(
"
${
test_files
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"
${
Boost_LIBRARIES
}
;xacc
;xacc
-quantum-gate"
)
quantum/gate/utils/Registry.hpp
View file @
f29fd47e
...
...
@@ -55,14 +55,14 @@ public:
bool
add
(
const
std
::
string
&
id
,
CreatorFunctionPtr
f
)
{
if
(
registry
.
find
(
id
)
!=
registry
.
end
())
{
XACC
I
nfo
(
id
+
" already exists in Registry. Ignoring and retaining previous Registry entry"
);
XACC
Logger
::
instance
()
->
i
nfo
(
id
+
" already exists in Registry. Ignoring and retaining previous Registry entry"
);
return
true
;
}
if
(
RuntimeOptions
::
instance
()
->
exists
(
"verbose-registry"
))
XACC
I
nfo
(
"Registry adding "
+
id
);
if
(
RuntimeOptions
::
instance
()
->
exists
(
"verbose-registry"
))
XACC
Logger
::
instance
()
->
i
nfo
(
"Registry adding "
+
id
);
bool
s
=
registry
.
emplace
(
std
::
make_pair
(
id
,
f
)).
second
;
if
(
!
s
)
{
XACC
E
rror
(
"Could not add "
+
id
+
" to the Registry."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Could not add "
+
id
+
" to the Registry."
);
}
else
{
return
s
;
}
...
...
@@ -81,14 +81,14 @@ public:
bool
add
(
const
std
::
string
&
id
,
CreatorFunctionPtr
f
,
std
::
shared_ptr
<
options_description
>
options
)
{
if
(
registry
.
find
(
id
)
!=
registry
.
end
())
{
XACC
I
nfo
(
id
+
" already exists in Registry. Ignoring and retaining previous Registry entry"
);
XACC
Logger
::
instance
()
->
i
nfo
(
id
+
" already exists in Registry. Ignoring and retaining previous Registry entry"
);
return
true
;
}
if
(
RuntimeOptions
::
instance
()
->
exists
(
"verbose-registry"
))
XACC
I
nfo
(
"Registry adding "
+
id
);
if
(
RuntimeOptions
::
instance
()
->
exists
(
"verbose-registry"
))
XACC
Logger
::
instance
()
->
i
nfo
(
"Registry adding "
+
id
);
bool
s
=
registry
.
emplace
(
std
::
make_pair
(
id
,
f
)).
second
;
bool
s2
=
registryOptions
.
insert
(
std
::
make_pair
(
id
,
std
::
move
(
options
))).
second
;
if
(
!
s
||
!
s2
)
{
XACC
E
rror
(
"Could not add "
+
id
+
" to the Registry."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Could not add "
+
id
+
" to the Registry."
);
}
else
{
return
true
;
}
...
...
@@ -98,19 +98,19 @@ public:
std
::
shared_ptr
<
options_description
>
options
,
std
::
function
<
bool
(
variables_map
&
)
>
optionsHandler
)
{
if
(
registry
.
find
(
id
)
!=
registry
.
end
())
{
XACC
I
nfo
(
XACC
Logger
::
instance
()
->
i
nfo
(
id
+
" already exists in Registry. Ignoring and retaining previous Registry entry"
);
return
true
;
}
if
(
RuntimeOptions
::
instance
()
->
exists
(
"verbose-registry"
))
XACC
I
nfo
(
"Registry adding "
+
id
);
XACC
Logger
::
instance
()
->
i
nfo
(
"Registry adding "
+
id
);
bool
s
=
registry
.
emplace
(
std
::
make_pair
(
id
,
f
)).
second
;
bool
s2
=
registryOptions
.
insert
(
std
::
make_pair
(
id
,
std
::
move
(
options
))).
second
;
bool
s3
=
registryOptionHandlers
.
insert
(
std
::
make_pair
(
id
,
std
::
move
(
optionsHandler
))).
second
;
if
(
!
s
||
!
s2
)
{
XACC
E
rror
(
"Could not add "
+
id
+
" to the Registry."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Could not add "
+
id
+
" to the Registry."
);
}
else
{
return
true
;
}
...
...
@@ -128,7 +128,7 @@ public:
if
(
search
!=
registry
.
end
())
{
return
registry
[
id
]
->
operator
()(
args
...);
}
else
{
XACC
E
rror
(
"Invalid Registry map id string - "
+
id
);
XACC
Logger
::
instance
()
->
e
rror
(
"Invalid Registry map id string - "
+
id
);
}
}
...
...
quantum/gate/utils/SimulatedQubits.hpp
View file @
f29fd47e
...
...
@@ -165,7 +165,7 @@ public:
for
(
int
i
=
0
;
i
<
bufferState
.
size
();
i
++
)
{
XACC
I
nfo
(
XACC
Logger
::
instance
()
->
i
nfo
(
bitStrings
[
i
]
+
" -> ("
+
std
::
to_string
(
std
::
real
(
bufferState
(
i
)))
+
", "
+
std
::
to_string
(
std
::
imag
(
bufferState
(
i
)))
+
")"
);
...
...
xacc/CMakeLists.txt
View file @
f29fd47e
...
...
@@ -72,7 +72,7 @@ target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} ${CppUsLib})
file
(
GLOB test_files utils/tests/*Tester.cpp accelerator/tests/*Tester.cpp
)
# Add the tests
add_tests
(
"
${
test_files
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/utils"
"
${
Boost_LIBRARIES
}
"
)
add_tests
(
"
${
test_files
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/utils"
"
${
Boost_LIBRARIES
}
;xacc
"
)
install
(
FILES
${
HEADERS
}
DESTINATION include/xacc
)
install
(
TARGETS
${
LIBRARY_NAME
}
DESTINATION lib
)
xacc/XACC.cpp
View file @
f29fd47e
...
...
@@ -17,6 +17,7 @@ namespace xacc {
bool
xaccFrameworkInitialized
=
false
;
std
::
shared_ptr
<
CLIParser
>
xaccCLParser
=
std
::
make_shared
<
CLIParser
>
();
int
argc
=
0
;
char
**
argv
=
NULL
;
...
...
@@ -50,30 +51,22 @@ void Initialize(int arc, char** arv) {
argc
=
arc
;
argv
=
arv
;
// Create the iniitial xacc-console
std
::
shared_ptr
<
spdlog
::
logger
>
tmpInitConsole
;
if
(
!
spdlog
::
get
(
"xacc-console"
))
{
tmpInitConsole
=
spdlog
::
stdout_logger_mt
(
"xacc-console"
);
}
else
{
tmpInitConsole
=
spdlog
::
get
(
"xacc-console"
);
}
XACCInfo
(
"[xacc] Initializing XACC Framework."
);
// Get reference to the service registry
auto
serviceRegistry
=
xacc
::
ServiceRegistry
::
instance
();
// Parse any user-supplied command line options
xaccCLParser
->
parse
(
argc
,
argv
);
info
(
"[xacc] Initializing XACC Framework."
);
// Check that we have some
auto
s
=
serviceRegistry
->
getServices
<
Compiler
>
().
size
();
auto
a
=
serviceRegistry
->
getServices
<
Accelerator
>
().
size
();
XACCI
nfo
(
i
nfo
(
"[xacc::plugins] XACC has "
+
std
::
to_string
(
s
)
+
" Compiler"
+
((
s
==
1
||
s
==
0
)
?
""
:
"s"
)
+
" available."
);
XACCI
nfo
(
i
nfo
(
"[xacc::plugins] XACC has "
+
std
::
to_string
(
a
)
+
" Accelerator"
+
((
s
==
0
||
s
==
1
)
?
""
:
"s"
)
+
" available."
);
...
...
@@ -84,6 +77,19 @@ void Initialize(int arc, char** arv) {
xacc
::
xaccFrameworkInitialized
=
true
;
}
void
info
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
)
{
XACCLogger
::
instance
()
->
info
(
msg
,
predicate
);
}
void
debug
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
)
{
XACCLogger
::
instance
()
->
debug
(
msg
,
predicate
);
}
void
error
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
)
{
XACCLogger
::
instance
()
->
error
(
msg
,
predicate
);
}
void
addCommandLineOption
(
const
std
::
string
&
optionName
,
const
std
::
string
&
optionDescription
)
{
xaccCLParser
->
addStringOption
(
optionName
,
optionDescription
);
...
...
@@ -103,7 +109,7 @@ bool optionExists(const std::string& optionKey) {
const
std
::
string
getOption
(
const
std
::
string
&
optionKey
)
{
if
(
!
optionExists
(
optionKey
))
{
XACCE
rror
(
"Invalid runtime option - "
+
optionKey
);
e
rror
(
"Invalid runtime option - "
+
optionKey
);
}
return
(
*
RuntimeOptions
::
instance
())[
optionKey
];
}
...
...
@@ -126,12 +132,12 @@ void setAccelerator(const std::string& acceleratorName) {
std
::
shared_ptr
<
Accelerator
>
getAccelerator
()
{
if
(
!
xacc
::
xaccFrameworkInitialized
)
{
XACCE
rror
(
e
rror
(
"XACC not initialized before use. Please execute "
"xacc::Initialize() before using API."
);
}
if
(
!
optionExists
(
"accelerator"
))
{
XACCE
rror
(
"Invalid use of XACC API. getAccelerator() with no string argument "
e
rror
(
"Invalid use of XACC API. getAccelerator() with no string argument "
"requires that you set --accelerator at the command line."
);
}
auto
acc
=
ServiceRegistry
::
instance
()
->
getService
<
Accelerator
>
(
getOption
(
"accelerator"
));
...
...
@@ -139,7 +145,7 @@ std::shared_ptr<Accelerator> getAccelerator() {
acc
->
initialize
();
return
acc
;
}
else
{
XACCE
rror
(
e
rror
(
"Invalid Accelerator. Could not find "
+
getOption
(
"accelerator"
)
+
" in Accelerator Registry."
);
}
...
...
@@ -147,7 +153,7 @@ std::shared_ptr<Accelerator> getAccelerator() {
std
::
shared_ptr
<
Accelerator
>
getAccelerator
(
const
std
::
string
&
name
)
{
if
(
!
xacc
::
xaccFrameworkInitialized
)
{
XACCE
rror
(
e
rror
(
"XACC not initialized before use. Please execute "
"xacc::Initialize() before using API."
);
}
...
...
@@ -156,7 +162,7 @@ std::shared_ptr<Accelerator> getAccelerator(const std::string& name) {
acc
->
initialize
();
return
acc
;
}
else
{
XACCE
rror
(
e
rror
(
"Invalid Accelerator. Could not find "
+
name
+
" in Accelerator Registry."
);
}
...
...
@@ -169,7 +175,7 @@ bool hasAccelerator(const std::string& name) {
std
::
shared_ptr
<
Compiler
>
getCompiler
(
const
std
::
string
&
name
)
{
if
(
!
xacc
::
xaccFrameworkInitialized
)
{
XACCE
rror
(
e
rror
(
"XACC not initialized before use. Please execute "
"xacc::Initialize() before using API."
);
}
...
...
@@ -177,7 +183,7 @@ std::shared_ptr<Compiler> getCompiler(const std::string& name) {
if
(
c
)
{
return
c
;
}
else
{
XACCE
rror
(
e
rror
(
"Invalid Compiler. Could not find "
+
name
+
" in Service Registry."
);
}
...
...
@@ -185,20 +191,20 @@ std::shared_ptr<Compiler> getCompiler(const std::string& name) {
std
::
shared_ptr
<
Compiler
>
getCompiler
()
{
if
(
!
xacc
::
xaccFrameworkInitialized
)
{
XACCE
rror
(
e
rror
(
"XACC not initialized before use. Please execute "
"xacc::Initialize() before using API."
);
}
auto
options
=
RuntimeOptions
::
instance
();
if
(
!
optionExists
(
"compiler"
))
{
XACCE
rror
(
"Invalid use of XACC API. getCompiler() with no string argument "
e
rror
(
"Invalid use of XACC API. getCompiler() with no string argument "
"requires that you set --compiler at the command line."
);
}
auto
compiler
=
ServiceRegistry
::
instance
()
->
getService
<
Compiler
>
(
getOption
(
"compiler"
));
if
(
compiler
)
{
return
compiler
;
}
else
{
XACCE
rror
(
e
rror
(
"Invalid Compiler. Could not find "
+
(
*
options
)[
"compiler"
]
+
" in Compiler Registry."
);
}
...
...
@@ -211,7 +217,7 @@ bool hasCompiler(const std::string& name) {
std
::
shared_ptr
<
IRTransformation
>
getIRTransformations
(
const
std
::
string
&
name
)
{
if
(
!
xacc
::
xaccFrameworkInitialized
)
{
XACCE
rror
(
e
rror
(
"XACC not initialized before use. Please execute "
"xacc::Initialize() before using API."
);
}
...
...
@@ -219,7 +225,7 @@ std::shared_ptr<IRTransformation> getIRTransformations(
if
(
t
)
{
return
t
;
}
else
{
XACCE
rror
(
e
rror
(
"Invalid IRTransformation. Could not find "
+
name
+
" in Service Registry."
);
}
...
...
@@ -268,11 +274,12 @@ const std::string translateWithVisitor(const std::string& originalSource, const
* be called after using the XACC API.
*/
void
Finalize
()
{
XACCI
nfo
(
""
);
XACCI
nfo
(
"[xacc::plugins] Cleaning up Plugin Registry."
);
i
nfo
(
""
);
i
nfo
(
"[xacc::plugins] Cleaning up Plugin Registry."
);
xacc
::
ServiceRegistry
::
instance
()
->
destroy
();
// XACCLogger::instance()->destroy();
xacc
::
xaccFrameworkInitialized
=
false
;
XACCI
nfo
(
"[xacc] Finalizing XACC Framework."
);
i
nfo
(
"[xacc] Finalizing XACC Framework."
);
}
}
xacc/XACC.hpp
View file @
f29fd47e
...
...
@@ -66,6 +66,11 @@ void addCommandLineOption(const std::string& optionName,
void
addCommandLineOptions
(
const
std
::
string
&
category
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
options
);
void
addCommandLineOptions
(
std
::
shared_ptr
<
options_description
>
options
);
void
info
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
=
std
::
function
<
bool
(
void
)
>
([]()
{
return
true
;}));
void
debug
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
=
std
::
function
<
bool
(
void
)
>
([]()
{
return
true
;}));
void
error
(
const
std
::
string
&
msg
,
MessagePredicate
predicate
=
std
::
function
<
bool
(
void
)
>
([]()
{
return
true
;}));
/**
* Return true if the option exists.
*
...
...
xacc/program/Program.cpp
View file @
f29fd47e
...
...
@@ -47,7 +47,7 @@ void Program::build() {
// Make sure we got a valid
if
(
!
compiler
)
{
XACC
E
rror
(
"Invalid Compiler.
\n
"
);
XACC
Logger
::
instance
()
->
e
rror
(
"Invalid Compiler.
\n
"
);
}
// Before compiling, run preprocessors
...
...
@@ -61,14 +61,14 @@ void Program::build() {
src
=
preprocessor
->
process
(
src
,
compiler
,
accelerator
);
}
XACC
I
nfo
(
"Executing "
+
compiler
->
getName
()
+
" compiler."
);
XACC
Logger
::
instance
()
->
i
nfo
(
"Executing "
+
compiler
->
getName
()
+
" compiler."
);
// Execute the compilation
xaccIR
=
compiler
->
compile
(
src
,
accelerator
);
// Validate the compilation
if
(
!
xaccIR
)
{
XACC
E
rror
(
"Bad source string or something.
\n
"
);
XACC
Logger
::
instance
()
->
e
rror
(
"Bad source string or something.
\n
"
);
}
// Execute hardware dependent IR Transformations
...
...
xacc/utils/CLIParser.hpp
View file @
f29fd47e
...
...
@@ -55,7 +55,9 @@ public:
(
"persist-ir"
,
value
<
std
::
string
>
(),
"Persist generated IR to provided file name."
)
(
"load"
,
value
<
std
::
string
>
(),
"Load a XACC plugin at the given path"
)
(
"list-compilers"
,
"List all available XACC Compilers"
)
(
"list-accelerators"
,
"List all available XACC Accelerators"
);
(
"list-accelerators"
,
"List all available XACC Accelerators"
)
(
"no-color"
,
"Turn off colored logger output (blue for INFO, red for ERROR, etc.)."
)
(
"use-cout"
,
"Use std::cout for logs instead of SPDLOG Logger."
);
}
void
addOptionsDescription
(
std
::
shared_ptr
<
options_description
>
options
)
{
...
...
@@ -80,7 +82,7 @@ public:
store
(
parse_command_line
(
argc
,
argv
,
*
xaccOptions
.
get
()),
clArgs
);
if
(
clArgs
.
count
(
"help"
))
{
std
::
cout
<<
*
xaccOptions
.
get
()
<<
"
\n
"
;
XACC
I
nfo
(
XACC
Logger
::
instance
()
->
i
nfo
(
"
\n
[xacc] XACC Finalizing
\n
[xacc::compiler] Cleaning up Compiler Registry."
"
\n
[xacc::accelerator] Cleaning up Accelerator Registry."
);
exit
(
0
);
...
...
@@ -96,24 +98,24 @@ public:
bool
listTypes
=
false
;
if
(
clArgs
.
count
(
"list-compilers"
))
{
auto
ids
=
ServiceRegistry
::
instance
()
->
getRegisteredIds
<
Compiler
>
();
XACC
I
nfo
(
"Available XACC Compilers:"
);
XACC
Logger
::
instance
()
->
i
nfo
(
"Available XACC Compilers:"
);
for
(
auto
i
:
ids
)
{
XACC
I
nfo
(
"
\t
"
+
i
);
XACC
Logger
::
instance
()
->
i
nfo
(
"
\t
"
+
i
);
}
listTypes
=
true
;
}
if
(
clArgs
.
count
(
"list-accelerators"
))
{
auto
ids
=
ServiceRegistry
::
instance
()
->
getRegisteredIds
<
Accelerator
>
();
XACC
I
nfo
(
"Available XACC Accelerators:"
);
XACC
Logger
::
instance
()
->
i
nfo
(
"Available XACC Accelerators:"
);
for
(
auto
i
:
ids
)
{
XACC
I
nfo
(
"
\t
"
+
i
);
XACC
Logger
::
instance
()
->
i
nfo
(
"
\t
"
+
i
);
}
listTypes
=
true
;
}
if
(
listTypes
)
{
XACC
I
nfo
(
XACC
Logger
::
instance
()
->
i
nfo
(
"
\n
[xacc] XACC Finalizing
\n
[xacc::compiler] Cleaning up Compiler Registry."
"
\n
[xacc::accelerator] Cleaning up Accelerator Registry."
);
exit
(
0
);
...
...
@@ -121,7 +123,7 @@ public:
auto
exitRequested
=
ServiceRegistry
::
instance
()
->
handleOptions
(
clArgs
);
if
(
exitRequested
)
{
XACC
I
nfo
(
XACC
Logger
::
instance
()
->
i
nfo
(
"
\n
[xacc] XACC Finalizing
\n
[xacc::compiler] Cleaning up Compiler Registry."
"
\n
[xacc::accelerator] Cleaning up Accelerator Registry."
);
exit
(
0
);
...
...
xacc/utils/Graph.hpp
View file @
f29fd47e
...
...
@@ -216,7 +216,7 @@ public:
auto
edgeBoolPair
=
add_edge
(
vertex
(
srcIndex
,
*
_graph
.
get
()),
vertex
(
tgtIndex
,
*
_graph
.
get
()),
*
_graph
.
get
());
if
(
!
edgeBoolPair
.
second
)
{
XACC
E
rror
(
"Failed to add an edge between "
+
std
::
to_string
(
srcIndex
)
+
" and "
+
std
::
to_string
(
tgtIndex
));
XACC
Logger
::
instance
()
->
e
rror
(
"Failed to add an edge between "
+
std
::
to_string
(
srcIndex
)
+
" and "
+
std
::
to_string
(
tgtIndex
));
}
boost
::
put
(
boost
::
edge_weight_t
(),
*
_graph
.
get
(),
edgeBoolPair
.
first
,
edgeWeight
);
...
...
@@ -487,7 +487,7 @@ public:
*/
virtual
void
read
(
std
::
istream
&
stream
)
{
stream
.
fail
();
XACC
E
rror
(
"Reading must be implemented by subclasses."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Reading must be implemented by subclasses."
);
}
void
computeShortestPath
(
int
startIndex
,
...
...
xacc/utils/ServiceRegistry.hpp
View file @
f29fd47e
...
...
@@ -70,12 +70,12 @@ protected:
// GetBundleContext() later.
framework
.
Init
();
}
catch
(
const
std
::
exception
&
e
)
{
XACC
E
rror
(
std
::
string
(
e
.
what
())
+
" - Could not initialize XACC Framework"
);
XACC
Logger
::
instance
()
->
e
rror
(
std
::
string
(
e
.
what
())
+
" - Could not initialize XACC Framework"
);
}
context
=
framework
.
GetBundleContext
();
if
(
!
context
)
{
XACC
E
rror
(
"Invalid XACC Framework plugin context."
);
XACC
Logger
::
instance
()
->
e
rror
(
"Invalid XACC Framework plugin context."
);
}
boost
::
filesystem
::
path
xaccPluginPath
(
...
...
@@ -93,7 +93,7 @@ protected:
}
}
}
else
{
XACC
I
nfo
(
"There are no plugins. Install plugins to begin working with XACC."
);
XACC
Logger
::
instance
()
->
i
nfo
(
"There are no plugins. Install plugins to begin working with XACC."
);
}
boost
::
filesystem
::
path
xaccLibPath
(
...
...
@@ -127,7 +127,7 @@ protected:
}
}
catch
(
const
std
::
exception
&
e
)
{
XACC
E
rror
(
"Failure to start XACC plugins. "
+
std
::
string
(
e
.
what
()));
XACC
Logger
::
instance
()
->
e
rror
(
"Failure to start XACC plugins. "
+
std
::
string
(
e
.
what
()));
}
}
...
...
@@ -170,7 +170,7 @@ public:
}
}
}
XACC
E
rror
(
"Could not find service with name "
+
name
+
". "
XACC
Logger
::
instance
()
->
e
rror
(
"Could not find service with name "
+
name
+
". "
"Perhaps the service is not Identifiable."
);
}
...
...
Prev
1
2
Next
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