Skip to content

Commit

Permalink
Merge pull request #784 from gadgetron/4.1
Browse files Browse the repository at this point in the history
4.1
  • Loading branch information
dchansen committed Nov 26, 2019
2 parents edc0ca2 + 03ec874 commit 00b158c
Show file tree
Hide file tree
Showing 208 changed files with 2,604 additions and 11,426 deletions.
107 changes: 33 additions & 74 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,7 @@ else ()
cmake_policy(VERSION 3.12)
endif ()

foreach (p
CMP0022
CMP0025 # CMake 3.0 Compiler id for Apple Clang is now ``AppleClang``.
CMP0042 # CMake 3.0 ``MACOSX_RPATH`` is enabled by default.
CMP0046 # CMake 3.0 Error on non-existent dependency in add_dependencies.
CMP0054 # CMake 3.1 Only interpret ``if()`` arguments as variables or keywords when unquoted.
CMP0056 # CMake 3.2 Honor link flags in ``try_compile()`` source-file signature.
CMP0058 # CMake 3.3 Ninja requires custom command byproducts to be explicit.
)
if (POLICY ${p})
cmake_policy(SET ${p} NEW)
endif ()
endforeach ()

project(GADGETRON
LANGUAGES CXX C)
project(GADGETRON LANGUAGES CXX C)

find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
Expand Down Expand Up @@ -67,7 +52,7 @@ endif ()

#VERSIONING AND INSTALL PATHS
set(GADGETRON_VERSION_MAJOR 4)
set(GADGETRON_VERSION_MINOR 0)
set(GADGETRON_VERSION_MINOR 1)
set(GADGETRON_VERSION_PATCH 0)
set(GADGETRON_VERSION_STRING ${GADGETRON_VERSION_MAJOR}.${GADGETRON_VERSION_MINOR}.${GADGETRON_VERSION_PATCH})
set(GADGETRON_SOVERSION ${GADGETRON_VERSION_MAJOR}.${GADGETRON_VERSION_MINOR})
Expand All @@ -86,7 +71,6 @@ else ()
endif ()
set(GADGETRON_INSTALL_CMAKE_PATH share/gadgetron/cmake)
set(GADGETRON_INSTALL_CONFIG_PATH share/gadgetron/config)
set(GADGETRON_INSTALL_MATLAB_PATH share/gadgetron/matlab)
set(GADGETRON_INSTALL_PYTHON_MODULE_PATH share/gadgetron/python)
set(GADGETRON_INSTALL_SCHEMA_PATH share/gadgetron/schema)
set(GADGETRON_INSTALL_INCLUDE_PATH include/gadgetron)
Expand Down Expand Up @@ -193,21 +177,16 @@ else ()
if (COMPILER_SUPPORT_WNON_VIRTUAL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=non-virtual-dtor")
endif ()

# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--enable-new-dtags")


endif ()


# whether to suppress compilation warnings
option(BUILD_SUPPRESS_WARNINGS "Build package while suppressing warnings" Off)
if (BUILD_SUPPRESS_WARNINGS)
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
elseif (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
endif ()
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
elseif (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
endif ()
endif ()

set(Boost_USE_STATIC_LIBS OFF)
Expand All @@ -216,9 +195,8 @@ set(Boost_USE_STATIC_RUNTIME OFF)
# necessary for Windows and RHEL <=6 systems
set(Boost_NO_BOOST_CMAKE ON)


if(WIN32)
add_definitions( -DHAVE_SNPRINTF) #Python decides to overwrite snprintf if this is not defined, because ofcourse it does.
add_definitions( -DHAVE_SNPRINTF) #Python decides to overwrite snprintf if this is not defined, because ofcourse it does.
endif()
# We actually only use system and thread explicitly, but they require linking in date_time and chrono
if (WIN32)
Expand Down Expand Up @@ -278,33 +256,35 @@ endif ()

find_package(GTest)


find_package(Armadillo REQUIRED )
# check whether ILP64 MKL should is used
add_library(armadillo INTERFACE)
set_property(TARGET armadillo PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ARMADILLO_INCLUDE_DIR})
add_definitions( -DARMA_DONT_USE_WRAPPER)
add_definitions(-DARMA_DONT_USE_WRAPPER)

find_package(PugiXML REQUIRED)
find_package(ISMRMRD REQUIRED)

link_directories(${ISMRMRD_LIBRARY_DIRS})
if (CUDA_FOUND AND USE_CUDA)
# bart needs cuda
find_package(BART)
find_package(BART)
endif()

find_package(FFTW3 REQUIRED COMPONENTS single double)
add_library(FFTW INTERFACE)
find_package(FFTW3 REQUIRED COMPONENTS single double)
target_link_libraries(FFTW INTERFACE ${FFTW3_LIBRARIES})
set_property(TARGET FFTW PROPERTY INTERFACE_LINK_DIRECTORIES ${FFTW3_INCLUDE_DIR})

option(USE_MKL OFF)
if (USE_MKL)
find_package(MKL REQUIRED)
add_library(BLAS INTERFACE IMPORTED)
set_property(TARGET BLAS PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MKL_INCLUDE_DIR})
set_property(TARGET BLAS PROPERTY INTERFACE_LINK_DIRECTORIES ${MKL_LIB_DIR})
set_property(TARGET BLAS PROPERTY INTERFACE_LINK_LIBRARIES ${MKL_LIBRARIES})
find_package(MKL REQUIRED)
add_library(BLAS INTERFACE IMPORTED)
set_property(TARGET BLAS PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MKL_INCLUDE_DIR})
set_property(TARGET BLAS PROPERTY INTERFACE_LINK_DIRECTORIES ${MKL_LIB_DIR})
set_property(TARGET BLAS PROPERTY INTERFACE_LINK_LIBRARIES ${MKL_LIBRARIES})




add_definitions(-DUSE_MKL)
else()
Expand All @@ -321,22 +301,16 @@ if (USE_MKL)

endif()

if (MKL_FOUND)
if ( MKL_VERSION_STRING VERSION_LESS 11.2.0 )
message(FATAL_ERROR "Gadgetron requires Intel MKL version >= 11.2.0")
endif ()
endif ()

if(EXISTS $ENV{TORCH_HOME})
find_package(Torch)
if (TORCH_FOUND)
add_definitions(-DUSE_TORCH)
message("Find Pytorch c++ library at ${TORCH_LIBRARIES}")
else()
message("Do not find Pytorch c++ library")
endif ()
find_package(Torch)
if (TORCH_FOUND)
add_definitions(-DUSE_TORCH)
message("Find Pytorch c++ library at ${TORCH_LIBRARIES}")
else()
message("Do not find Pytorch c++ library")
endif ()
else()
message("Do not find TORCH_HOME")
message("Do not find TORCH_HOME")
endif()

option(BUILD_PYTHON_SUPPORT "Build Python gadgets etc" On)
Expand Down Expand Up @@ -367,20 +341,6 @@ target_link_libraries(boost INTERFACE python)

endif()

option(BUILD_MATLAB_SUPPORT "Build of MATLAB gadgets etc" On)
if (BUILD_MATLAB_SUPPORT)
find_package(GMatlab)
if (MATLAB_FOUND)
add_definitions(-DUSE_MATLAB)
else()
set(BUILD_MATLAB_SUPPORT OFF)
endif ()
else()
# explicitly set it, just in case BUILD_MATLAB_SUPPORT was set to OFF
# after Matlab was already found.
set(MATLAB_FOUND OFF)
endif ()

message("Searching for OpenGL, GLEW, GLUT, and Qt. These libraries are only used in a single standalone application and are thus non-essential.")
if(WIN32)
message("For Windows users in particular, for ease of installation we do not reccomend installing these libraries.")
Expand All @@ -404,15 +364,14 @@ message("Adding gpertools to build.")
find_package(Gperftools REQUIRED)
endif()

#add_subdirectory(test)
add_subdirectory(test)
add_subdirectory(cmake)
add_subdirectory(chroot)


option(BUILD_DOCUMENTATION "Build Gadgetron documentation" Off)
if (BUILD_DOCUMENTATION)
add_subdirectory(doc)
option(BUILD_DOCUMENTATION "Build Gadgetron documentation." Off)
if(BUILD_DOCUMENTATION)
add_subdirectory(doc)
endif()
add_subdirectory(chroot)

# install dependencies for WIN32
if (WIN32)
Expand Down
3 changes: 0 additions & 3 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ add_subdirectory(gadgetron)
add_subdirectory(clients)
add_subdirectory(standalone)

if (MATLAB_FOUND )
add_subdirectory(matlab)
endif ()
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ class GadgetronClientConnector
id.id = GADGET_MESSAGE_CONFIG_SCRIPT;

GadgetMessageScript conf;
conf.script_length = (uint32_t)xml_string.size()+1;
conf.script_length = (uint32_t)xml_string.size();

boost::asio::write(*socket_, boost::asio::buffer(&id, sizeof(GadgetMessageIdentifier)));
boost::asio::write(*socket_, boost::asio::buffer(&conf, sizeof(GadgetMessageScript)));
Expand All @@ -1264,7 +1264,7 @@ class GadgetronClientConnector
id.id = GADGET_MESSAGE_PARAMETER_SCRIPT;

GadgetMessageScript conf;
conf.script_length = (uint32_t)xml_string.size()+1;
conf.script_length = (uint32_t)xml_string.size();

boost::asio::write(*socket_, boost::asio::buffer(&id, sizeof(GadgetMessageIdentifier)));
boost::asio::write(*socket_, boost::asio::buffer(&conf, sizeof(GadgetMessageScript)));
Expand Down
8 changes: 4 additions & 4 deletions apps/gadgetron/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ namespace Gadgetron::Server::Connection {
#if _WIN32 || !NDEBUG || GADGETRON_DISABLE_FORK

void handle(
const Gadgetron::Core::Context::Paths& paths,
const Gadgetron::Core::Context::Args& args,
const Gadgetron::Core::StreamContext::Paths& paths,
const Gadgetron::Core::StreamContext::Args& args,
std::unique_ptr<std::iostream> stream
) {
auto thread = std::thread(handle_connection, std::move(stream), paths, args);
Expand All @@ -29,8 +29,8 @@ namespace Gadgetron::Server::Connection {
#else

void handle(
const Gadgetron::Core::Context::Paths& paths,
const Gadgetron::Core::Context::Args& args,
const Gadgetron::Core::StreamContext::Paths& paths,
const Gadgetron::Core::StreamContext::Args& args,
std::unique_ptr<std::iostream> stream
) {
auto pid = fork();
Expand Down
4 changes: 2 additions & 2 deletions apps/gadgetron/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Gadgetron::Server::Connection {
void handle(
const Gadgetron::Core::Context::Paths &paths,
const Gadgetron::Core::Context::Args &args,
const Gadgetron::Core::StreamContext::Paths &paths,
const Gadgetron::Core::StreamContext::Args &args,
std::unique_ptr<std::iostream> stream
);
}
11 changes: 8 additions & 3 deletions apps/gadgetron/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ void Server::serve() {

Gadgetron::Core::Context::Paths paths{args["home"].as<path>(), args["dir"].as<path>()};

boost::asio::io_service service;
#if(BOOST_VERSION >= 107000)
boost::asio::io_context executor;
#else
boost::asio::io_service executor;
#endif
boost::asio::ip::tcp::endpoint local(boost::asio::ip::tcp::v6(), args["port"].as<unsigned short>());
boost::asio::ip::tcp::acceptor acceptor(service, local);
boost::asio::ip::tcp::acceptor acceptor(executor, local);

acceptor.set_option(boost::asio::socket_base::reuse_address(true));

while(true) {
auto socket = std::make_unique<boost::asio::ip::tcp::socket>(service);
auto socket = std::make_unique<boost::asio::ip::tcp::socket>(executor);
acceptor.accept(*socket);

GINFO_STREAM("Accepted connection from: " << socket->remote_endpoint().address());
Expand Down
18 changes: 5 additions & 13 deletions apps/gadgetron/connection/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
#include <memory>
#include <string>

#include <boost/parameter/name.hpp>
#include <boost/range/algorithm/transform.hpp>
#include <boost/range/algorithm/count_if.hpp>
#include <boost/range/algorithm/find_if.hpp>
#include <numeric>

#include "log.h"

Expand Down Expand Up @@ -399,15 +397,6 @@ namespace {
};
}

bool is_legacy_matlab_gadget(const Config::Gadget &gadget) {
return gadget.dll == "gadgetron_matlab" && gadget.classname == "MatlabBufferGadget";
}

Config::Node transform_legacy_matlab_gadget(Config::Gadget gadget) {
GDEBUG_STREAM("Legacy Matlab Gadget detected: " << gadget.name);
throw std::runtime_error("Currently not implemented.");
}

class Legacy : public Parser<LegacySource> {
public:

Expand All @@ -433,7 +422,6 @@ namespace {
const std::list<std::pair<std::function<bool(const Config::Gadget &)>,
std::function<Config::Node(Config::Gadget)>>> node_transformations{
std::make_pair(is_legacy_python_gadget, transform_legacy_python_gadget),
std::make_pair(is_legacy_matlab_gadget, transform_legacy_matlab_gadget),
std::make_pair([](auto _) { return true; }, [=](auto c) { return Config::Node(c); })
};

Expand Down Expand Up @@ -572,8 +560,13 @@ namespace {
};
}

static std::string address_or_localhost(const std::string &s) {
return s.empty() ? "localhost" : s;
}

static Config::Connect parse_connect(const pugi::xml_node &connect_node) {
return Config::Connect {
address_or_localhost(connect_node.attribute("address").value()),
connect_node.attribute("port").value()
};
}
Expand Down Expand Up @@ -627,7 +620,6 @@ namespace Gadgetron::Server::Connection {
pugi::xml_document doc{};
auto config_node = doc.append_child("configuration");
config_node.append_child("version").text().set(2);

XMLSerializer::add_readers(config.readers, config_node);
XMLSerializer::add_writers(config.writers, config_node);
XMLSerializer::add_node(config.stream, config_node);
Expand Down
2 changes: 1 addition & 1 deletion apps/gadgetron/connection/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace Gadgetron::Server::Connection {
};

struct Connect {
std::string port;
std::string address, port;
};

using Action = Core::variant<Execute, Connect>;
Expand Down
Loading

0 comments on commit 00b158c

Please sign in to comment.