Commit 18a4c4c0 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

cleanup and remove some include headers on heterogeneous.hpp


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 7428a31e
......@@ -174,7 +174,7 @@ PauliOperator::PauliOperator(std::map<int, std::string> operators,
std::complex<double> PauliOperator::coefficient() {
if (terms.size() > 1) {
xacc::error("Cannot call PauliOperator::coefficient on operator with more "
"than 1 term.");
"than 1 term. " + toString());
}
return terms.begin()->second.coeff();
}
......
......@@ -20,6 +20,7 @@
#include <cassert>
#include <ctime>
#include <regex>
#include <fstream>
#include "InstructionIterator.hpp"
......
......@@ -21,6 +21,7 @@
#include "xacc_service.hpp"
#include "NoiseModel.hpp"
#include <random>
#include <fstream>
using namespace pybind11::literals;
......
......@@ -21,6 +21,7 @@
#include <random>
#include "json.hpp"
#include "xacc_config.hpp"
#include <fstream>
namespace {
Eigen::MatrixXcd X { Eigen::MatrixXcd::Zero(2, 2)};
......
......@@ -4,6 +4,7 @@
#include "xacc.hpp"
#include <algorithm>
#include <fstream>
#include "AnnealingProgram.hpp"
namespace xacc {
......
......@@ -5,6 +5,7 @@
#include <Eigen/Dense>
#include "CommonGates.hpp"
#include "Cloneable.hpp"
#include <fstream>
namespace {
constexpr double NUM_TOL = 1e-9;
......
......@@ -41,6 +41,7 @@ add_library(xacc SHARED
accelerator/AcceleratorBuffer.cpp
utils/Utils.cpp
utils/CLIParser.cpp
utils/heterogeneous.cpp
service/ServiceRegistry.cpp
service/xacc_service.cpp
accelerator/remote/RemoteAccelerator.cpp)
......
......@@ -14,6 +14,7 @@
#include "Identifiable.hpp"
#include "heterogeneous.hpp"
#include <cassert>
#include <complex>
namespace xacc {
namespace quantum {
......
......@@ -16,6 +16,8 @@
#include "Identifiable.hpp"
#include "heterogeneous.hpp"
#include "Utils.hpp"
namespace xacc {
// Forward declare:
class CompositeInstruction;
......
......@@ -283,6 +283,8 @@ void execute(AcceleratorBuffer **buffers, const int nBuffers,
}
}
std::cout << "HELLO WORLD EXEC: " << global_reg_size << "\n";
std::cout << program->toString() << "\n";
// Now execute using the global merged register
execute(tmp.get(), program, parameters);
......
......@@ -16,6 +16,8 @@
#include "Graph.hpp"
#include "heterogeneous.hpp"
#include <memory>
#include <sstream>
#include "Utils.hpp"
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/exterior_property.hpp>
......
......@@ -15,6 +15,8 @@
#include "Graph.hpp"
#include <memory>
#include <sstream>
#include "Utils.hpp"
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/exterior_property.hpp>
......
......@@ -16,8 +16,6 @@
#include <functional>
#include <vector>
#include "AcceleratorBuffer.hpp"
#include "CompositeInstruction.hpp"
#include "Identifiable.hpp"
#include "heterogeneous.hpp"
......
#include "heterogeneous.hpp"
#include "Utils.hpp"
namespace xacc {
void emit_error(const std::string&& s) {
XACCLogger::instance()->error(s);
print_backtrace();
}
} // namespace xacc
\ No newline at end of file
......@@ -15,20 +15,13 @@
#include <initializer_list>
#include <map>
#include <stdexcept>
#include <vector>
#include <unordered_map>
#include <functional>
#include <iostream>
#include <experimental/type_traits>
#include <cstring>
// mpark variant
#include "variant.hpp"
#include "Utils.hpp"
#include <complex>
#include <any>
#include <sstream>
// If this is a GNU compiler
#if defined(__GNUC__) || defined(__GNUG__)
......@@ -88,6 +81,7 @@ template <typename T> bool isType(std::any in_any) {
#endif
namespace xacc {
void emit_error(const std::string&& s);
class HeterogeneousMap;
......@@ -139,8 +133,8 @@ public:
}
template <typename... Ts> void print(std::ostream &os) const {
_internal_print_visitor<Ts...> v(os);
visit(v);
// _internal_print_visitor<Ts...> v(os);
// visit(v);
}
template <class T> void insert(const std::string key, const T &_t) {
......@@ -164,7 +158,7 @@ public:
}
}
#endif
XACCLogger::instance()->error(
emit_error(
"HeterogeneousMap::get() error - Invalid type or key (" + key + ").");
}
return T();
......@@ -190,9 +184,9 @@ public:
} else if (keyExists<std::string>(key)) {
return get<std::string>(key);
} else {
XACCLogger::instance()->error("No string-like value at provided key (" +
emit_error("No string-like value at provided key (" +
key + ").");
print_backtrace();
// print_backtrace();
}
return "";
}
......@@ -221,9 +215,9 @@ public:
} else if (keyExists<std::shared_ptr<T>>(key)) {
return get<std::shared_ptr<T>>(key).get();
} else {
XACCLogger::instance()->error("No pointer-like value at provided key (" +
emit_error("No pointer-like value at provided key (" +
key + ").");
print_backtrace();
// print_backtrace();
}
return nullptr;
}
......@@ -281,18 +275,18 @@ private:
void operator()(const std::string &key, const T &t) { count++; }
};
template <typename... Ts>
class _internal_print_visitor : public visitor_base<Ts...> {
private:
std::ostream &ss;
// template <typename... Ts>
// class _internal_print_visitor : public visitor_base<Ts...> {
// private:
// std::ostream &ss;
public:
_internal_print_visitor(std::ostream &s) : ss(s) {}
// public:
// _internal_print_visitor(std::ostream &s) : ss(s) {}
template <typename T> void operator()(const std::string &key, const T &t) {
ss << key << ": " << t << "\n";
}
};
// template <typename T> void operator()(const std::string &key, const T &t) {
// ss << key << ": " << t << "\n";
// }
// };
template <class T, class HEAD, class... TAIL> struct try_visit {
template <class U> static void apply(T &visitor, U &&element) {
......@@ -324,9 +318,9 @@ template const bool HeterogeneousMap::get<bool>(const std::string key) const;
template const int HeterogeneousMap::get<int>(const std::string key) const;
template const double
HeterogeneousMap::get<double>(const std::string key) const;
template const std::vector<std::complex<double>>
HeterogeneousMap::get<std::vector<std::complex<double>>>(
const std::string key) const;
// template const std::vector<std::complex<double>>
// HeterogeneousMap::get<std::vector<std::complex<double>>>(
// const std::string key) const;
template const std::vector<double>
HeterogeneousMap::get<std::vector<double>>(const std::string key) const;
template const std::vector<double>
......@@ -377,8 +371,8 @@ public:
std::stringstream s;
s << "InstructionParameter::this->toString() = " << toString() << "\n";
s << "This InstructionParameter type id is " << this->which() << "\n";
XACCLogger::instance()->error("Cannot cast Variant: " + s.str());
print_backtrace();
emit_error("Cannot cast Variant: " + s.str());
// print_backtrace();
exit(0);
}
return T();
......
......@@ -17,6 +17,7 @@
#include <memory>
#include <signal.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include "xacc_config.hpp"
#include "cxxopts.hpp"
......@@ -807,6 +808,13 @@ void unload_external_language_plugins() {
}
} // namespace external
void write_string_to_file_and_close(std::string file_Name, std::string s) {
std::ofstream out(file_Name);
out << s;
out.close();
return;
}
void Finalize() {
XACCLogger::instance()->dumpQueue();
if (xaccFrameworkInitialized) {
......
......@@ -26,7 +26,7 @@
#include <memory>
#include <sys/types.h>
#include <sys/stat.h>
#include <fstream>
#include <iosfwd>
namespace xacc {
......@@ -165,6 +165,8 @@ std::shared_ptr<Optimizer> getOptimizer(const std::string name,
std::shared_ptr<Optimizer> getOptimizer(const std::string name,
const HeterogeneousMap &&opts);
void write_string_to_file_and_close(std::string file_Name, std::string s);
bool hasCache(const std::string fileName, const std::string subdirectory = "");
HeterogeneousMap getCache(const std::string fileName,
......@@ -189,7 +191,7 @@ void appendCache(const std::string fileName, const std::string key, T &&param,
appendCache(fileName, existingCache, subdirectory);
} else {
std::ofstream out(rootPathStr + "/" + fileName);
// std::ofstream out(rootPathStr + "/" + fileName);
std::stringstream s;
AcceleratorBuffer b;
b.useAsCache();
......@@ -203,11 +205,13 @@ void appendCache(const std::string fileName, const std::string key, T &&param,
b.print(s);
out << s.str();
out.close();
// out << s.str();
// out.close();
write_string_to_file_and_close(rootPathStr+"/"+fileName, s.str());
}
}
template <typename T>
void appendCache(const std::string fileName, const std::string key, T &param,
const std::string subdirectory = "") {
......@@ -226,7 +230,7 @@ void appendCache(const std::string fileName, const std::string key, T &param,
appendCache(fileName, existingCache, subdirectory);
} else {
std::ofstream out(rootPathStr + "/" + fileName);
// std::ofstream out(rootPathStr + "/" + fileName);
std::stringstream s;
AcceleratorBuffer b;
b.useAsCache();
......@@ -240,8 +244,9 @@ void appendCache(const std::string fileName, const std::string key, T &param,
b.print(s);
out << s.str();
out.close();
// out << s.str();
// out.close();
write_string_to_file_and_close(rootPathStr+"/"+fileName, s.str());
}
}
......
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