Call as dynamic object

This commit is contained in:
kradchen
2023-11-28 09:53:59 +08:00
parent 34d7086b47
commit 8ae5950e9f
3 changed files with 90 additions and 3 deletions

View File

@@ -9,7 +9,11 @@ set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(BUILD_SHARED_LIBS ON)
if (${BUILD_SHARED_LIBS})
set(MKL_INTERFACE_FULL intel_lp64)
set(MKL_LINK static)
endif()
find_package(Aurora REQUIRED)
find_package(Parser REQUIRED)
find_package(Req REQUIRED)
@@ -18,10 +22,26 @@ find_package(DCMTK REQUIRED)
set(DCMTK_WITH_JPEG OFF)
file(GLOB_RECURSE cpp_files ./src/*.cpp)
file(GLOB_RECURSE cu_files ./src/*.cu)
file(GLOB_RECURSE cxx_files ./src/*.cxx)
file(GLOB_RECURSE header_files ./src/*.h)
if (${BUILD_SHARED_LIBS})
set(cxx_files ./src/UR.cxx)
find_package(MKL CONFIG REQUIRED)
set(MKL_INTERFACE_FULL intel_lp64)
add_library(UR SHARED ${cpp_files} ${cxx_files} ${header_files} ${Aurora_Source})
target_compile_options(UR PUBLIC $<TARGET_PROPERTY:MKL::MKL,INTERFACE_COMPILE_OPTIONS>)
target_include_directories(UR PUBLIC $<TARGET_PROPERTY:MKL::MKL,INTERFACE_INCLUDE_DIRECTORIES>)
target_link_libraries(UR PUBLIC $<LINK_ONLY:MKL::MKL>)
target_link_libraries(UR PUBLIC OpenMP::OpenMP_CXX)
target_compile_options(UR PUBLIC "-march=native")
else()
set(cxx_files ./src/main.cxx)
add_executable(UR ${cpp_files} ${cxx_files} ${header_files} ${Aurora_Source})
target_compile_options(UR PUBLIC ${Aurora_Complie_Options} "-march=native")
endif()
target_include_directories(UR PUBLIC ./src/)
target_include_directories(UR PUBLIC ${Aurora_INCLUDE_DIRS})
target_include_directories(UR PUBLIC ${DCMTK_INCLUDE_DIRS})

67
src/UR.cxx Normal file
View File

@@ -0,0 +1,67 @@
#include "Parser.h"
#include "Parser.h"
#include "config/config.h"
#include "log/notify.h"
#include "log/notify.h"
#include <exception>
#include <iostream>
#include <vector>
#include <stdexcept>
#define EIGEN_USE_MKL_ALL
#include "src/common/fileHelper.h"
#include "startReconstructions.h"
#include "log/log.h"
extern "C" {
int ReconProcess(const char* reconID,const char* path,const char* refPath,const char* output,const char* config){
try{
int argNum = 5;
std::vector<std::string> args(argNum);
std::string outPutPath = output?output:Recon::DEFAULT_OUTPUT_PATH;
outPutPath = Recon::fixPathSlash(outPutPath);
std::string directoryPath = outPutPath;
if(!Recon::isDirectory(directoryPath))
{
printf("Output directory is not valid.");
return -4;
}
auto defaultLogger = getLogger("Main",outPutPath.data());
spdlog::set_default_logger(defaultLogger);
if(!reconID)
{
RECON_INFO("No recon id.");
return -1;
}
std::string ReconID = reconID;
if(!path)
{
RECON_INFO("No reconstruction data.");
return -2;
}
std::string configPath = Recon::fixPathSlash(config?config:Recon::DEFAULT_CONFIG_PATH);
Recon::initalizeConfig(configPath);
if( !refPath && Recon::transParams::runTransmissionReco)
{
RECON_INFO("Running transmission reconstruction, but no refrence data.");
return -3;
}
std::string dataPath = Recon::fixPathSlash(path);
std::string dataRefPath = Recon::fixPathSlash(refPath);
RECON_INFO("start");
Recon::notifyStart("");
int exitcode = Recon::startReconstructions(dataPath, dataRefPath, outPutPath);
if (exitcode == 0)
{
RECON_INFO("finish");
return exitcode;
}
else{
return exitcode;
}
}
catch(const std::exception& ex){
RECON_INFO("Recon fail by unknow{}", ex.what());
return -99;
}
}
}

View File

@@ -222,7 +222,7 @@ namespace Recon {
{
allHitMaps.push_back(buildMatrixR.hitmap);
}
#pragma omp parallel for num_threads(2)
// #pragma omp parallel for num_threads(2)
for (int i =0; i<2; i++){
if (i ==0){
if(!data.isNull())