Commit 333275d4 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

minor updates to compiler translate method


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 912ea0bc
Pipeline #105832 failed with stage
in 55 minutes and 7 seconds
......@@ -307,7 +307,7 @@ StaqCompiler::translate(std::shared_ptr<xacc::CompositeInstruction> function) {
const std::string
StaqCompiler::translate(std::shared_ptr<CompositeInstruction> program,
const HeterogeneousMap &options) {
HeterogeneousMap &options) {
if (options.stringExists("lang-type")) {
auto langType = options.getString("lang-type");
......
......@@ -32,7 +32,7 @@ public:
translate(std::shared_ptr<CompositeInstruction> function) override;
const std::string translate(std::shared_ptr<CompositeInstruction> program,
const HeterogeneousMap &options) override;
HeterogeneousMap &options) override;
const std::string name() const override { return "staq"; }
......
......@@ -43,11 +43,16 @@ public:
translate(std::shared_ptr<CompositeInstruction> program) = 0;
virtual const std::string
translate(std::shared_ptr<CompositeInstruction> program, const HeterogeneousMap& options) {
translate(std::shared_ptr<CompositeInstruction> program, HeterogeneousMap& options) {
// default just call translate
return translate(program);
}
virtual const std::string
translate(std::shared_ptr<CompositeInstruction> program, HeterogeneousMap&& options) {
// default just call translate
return translate(program,options);
}
virtual const std::shared_ptr<CompositeInstruction>
compile(std::shared_ptr<CompositeInstruction> f,
std::shared_ptr<Accelerator> acc) {
......
......@@ -25,6 +25,21 @@ public:
}
};
void test_set_ptr(xacc::HeterogeneousMap &map) {
auto simple_kernel =
xacc::getCompiler("xasm")
->compile(R"#(__qpu__ void foo(qreg q) { H(q[0]); })#")
->getComposites()[0];
map.insert("hello-world", simple_kernel);
}
TEST(HeterogeneousMapTester, checkSetValueFromFunctionRef) {
xacc::HeterogeneousMap m;
m.insert("hello-world", nullptr);
test_set_ptr(m);
std::cout << m.get<std::shared_ptr<xacc::CompositeInstruction>>("hello-world")->toString() << "\n";
}
TEST(HeterogeneousMapTester, checkSimple) {
xacc::HeterogeneousMap c;
c.insert("intkey", 1);
......
......@@ -150,6 +150,10 @@ public:
return v.count;
}
bool key_exists_any_type(const std::string key) const {
return items.count(key);
}
template <typename T> bool keyExists(const std::string key) const {
if (items.count(key)) {
// we have the key, make sure it is the right type
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment