Commit 4d266c7c authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh

Fixed exatn initialization order.

parent 536821e5
set(LIBRARY_NAME exatn)
add_library(${LIBRARY_NAME} SHARED exatn_service.cpp ServiceRegistry.cpp num_server.cpp)
add_library(${LIBRARY_NAME} SHARED exatn.cpp exatn_service.cpp ServiceRegistry.cpp num_server.cpp)
add_dependencies(${LIBRARY_NAME} exatensor-build)
......
#include "exatn.hpp"
namespace exatn {
void initialize() {
if(!exatnFrameworkInitialized){
serviceRegistry->initialize();
numericalServer = std::make_shared<NumServer>();
exatnFrameworkInitialized = true;
}
return;
}
bool isInitialized() {
return exatnFrameworkInitialized;
}
void finalize() {
exatnFrameworkInitialized = false;
numericalServer.reset();
return;
}
} // namespace exatn
......@@ -4,4 +4,17 @@
#include "exatn_service.hpp"
#include "exatn_numerics.hpp"
namespace exatn {
/** Initializes ExaTN **/
void initialize();
/** Returns whether or not ExaTN has been initialized **/
bool isInitialized();
/** Finalizes ExaTN **/
void finalize();
} //namespace exatn
#endif //EXATN_HPP_
......@@ -6,22 +6,4 @@ bool exatnFrameworkInitialized = false;
std::shared_ptr<ServiceRegistry> serviceRegistry = std::make_shared<ServiceRegistry>();
void initialize() {
if(!exatnFrameworkInitialized) {
serviceRegistry->initialize();
exatnFrameworkInitialized = true;
}
}
bool isInitialized() {
return exatnFrameworkInitialized;
}
void finalize() {
exatnFrameworkInitialized = false;
}
} // namespace exatn
......@@ -11,10 +11,6 @@ namespace exatn {
extern bool exatnFrameworkInitialized;
extern std::shared_ptr<ServiceRegistry> serviceRegistry;
void initialize();
bool isInitialized();
void finalize();
template <typename Service>
std::shared_ptr<Service> getService(const std::string &serviceName) {
if (!exatn::exatnFrameworkInitialized) {
......
/** ExaTN::Numerics: Numerical server
REVISION: 2019/08/04
REVISION: 2019/08/26
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
#include "num_server.hpp"
#include "assert.h"
#include <cassert>
namespace exatn{
std::shared_ptr<NumServer> numericalServer = std::make_shared<NumServer>();
/** Numerical server (singleton) **/
std::shared_ptr<NumServer> numericalServer {nullptr}; //initialized by exatn::initialize()
NumServer::NumServer():
tensor_rt_(std::make_shared<runtime::TensorRuntime>())
......
/** ExaTN::Numerics: Numerical server
REVISION: 2019/08/04
REVISION: 2019/08/26
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -19,8 +19,8 @@ Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
means ensuring that the tensor-result (output tensor) has been fully computed.
**/
#ifndef EXATN_NUMERICS_NUM_SERVER_HPP_
#define EXATN_NUMERICS_NUM_SERVER_HPP_
#ifndef EXATN_NUM_SERVER_HPP_
#define EXATN_NUM_SERVER_HPP_
#include "tensor_basic.hpp"
#include "space_register.hpp"
......@@ -147,8 +147,9 @@ private:
std::shared_ptr<runtime::TensorRuntime> tensor_rt_; //tensor runtime (for actual execution of tensor operations)
};
/** Numerical service singleton (numerical server) **/
extern std::shared_ptr<NumServer> numericalServer;
} //namespace exatn
#endif //EXATN_NUMERICS_NUM_SERVER_HPP_
#endif //EXATN_NUM_SERVER_HPP_
......@@ -18,7 +18,7 @@ using namespace exatn;
TEST(DirectedGraphTester, checkConstruction) {
// Implement this when we have TensorOperation
//`Implement this when we have TensorOperation
}
int main(int argc, char **argv) {
......
......@@ -11,8 +11,7 @@
* Alexander J. McCaskey - initial API and implementation
*******************************************************************************/
#include <gtest/gtest.h>
#include "exatn_service.hpp"
#include "tensor_runtime.hpp"
#include "exatn.hpp"
TEST(TensorRuntimeTester, checkSimple) {
......
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