Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engine Addition: NuSQUIDS #47

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
57 changes: 51 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ DefineEnabledRequiredSwitch(UseCUDAProb3Linear 0)
DefineEnabledRequiredSwitch(UseProb3ppLinear 0)
DefineEnabledRequiredSwitch(UseProbGPULinear 0)
DefineEnabledRequiredSwitch(UseNuFASTLinear 0)
DefineEnabledRequiredSwitch(UseNuSQUIDSLinear 0)

# KS: NuFastLinear by default
if(UseCUDAProb3 EQUAL 0 AND
UseCUDAProb3Linear EQUAL 0 AND
UseProb3ppLinear EQUAL 0 AND
UseProbGPULinear EQUAL 0 AND
UseNuFASTLinear EQUAL 0)
set(UseNuFASTLinear 1)
if(UseCUDAProb3 EQUAL 0 AND
UseCUDAProb3Linear EQUAL 0 AND
UseProb3ppLinear EQUAL 0 AND
UseProbGPULinear EQUAL 0 AND
UseNuFASTLinear EQUAL 0 AND
UseNuSQUIDSLinear EQUAL 0)
set(UseNuFASTLinear 1)
endif()

LIST(APPEND ALL_Engines
Expand All @@ -71,6 +73,7 @@ LIST(APPEND ALL_Engines
Prob3ppLinear
ProbGPULinear
NuFASTLinear
NuSQUIDSLinear
)
cmessage(STATUS "NuOscillator Features: ")
foreach(f ${ALL_Engines})
Expand Down Expand Up @@ -252,6 +255,48 @@ if(${UseNuFASTLinear} EQUAL 1)
target_compile_definitions(NuOscillatorCompilerOptions INTERFACE UseNuFASTLinear=1)
endif()

if(${UseNuSQUIDSLinear} EQUAL 1)
find_package(GSL REQUIRED)
find_package(HDF5 REQUIRED)

include(ExternalProject)

ExternalProject_Add(SQUIDS
GIT_REPOSITORY https://github.com/jsalvado/SQuIDS.git
GIT_TAG master
BINARY_DIR = <SOURCE_DIR>
CONFIGURE_HANDLED_BY_BUILD true
CONFIGURE_COMMAND <SOURCE_DIR>/configure --with-gsl=${GSL_ROOT_DIR} --prefix=<INSTALL_DIR>
BUILD_COMMAND make
INSTALL_COMMAND make install
)

SET(SQUIDS_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/SQUIDS-prefix/include)
SET(SQUIDS_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/SQUIDS-prefix/lib)

add_library(SQUIDS::SQUIDS SHARED IMPORTED)
set_target_properties(SQUIDS::SQUIDS PROPERTIES IMPORTED_LOCATION ${SQUIDS_LIB_DIR}/libSQuIDS.so)

ExternalProject_Add(NUSQUIDS
GIT_REPOSITORY https://github.com/arguelles/nuSQuIDS.git
GIT_TAG master
BINARY_DIR = <SOURCE_DIR>
Comment on lines +280 to +283
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nuSQuIDS is actually being developed. Is it worth to use tag etc. instead of master?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tagging system being used by NuSQUIDS is not clear.. the tags are much older than recent developments, some of which are required for the planned quantum decoherence studies planned. It might be worth pulling an individual git commit hash if that's possible.

CONFIGURE_HANDLED_BY_BUILD true
CONFIGURE_COMMAND <SOURCE_DIR>/configure --with-gsl=${GSL_ROOT_DIR} --with-hdf5=${HDF5_INCLUDE_DIRS}/../ --with-squids=${CMAKE_CURRENT_BINARY_DIR}/SQUIDS-prefix --prefix=<INSTALL_DIR>
BUILD_COMMAND make examples
INSTALL_COMMAND make install
)

SET(NUSQUIDS_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/NUSQUIDS-prefix/src/NUSQUIDS/)
SET(NUSQUIDS_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/NUSQUIDS-prefix/include/)
SET(NUSQUIDS_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/NUSQUIDS-prefix/lib/)

add_library(NUSQUIDS::NUSQUIDS SHARED IMPORTED)
set_target_properties(NUSQUIDS::NUSQUIDS PROPERTIES IMPORTED_LOCATION ${NUSQUIDS_LIB_DIR}/libnuSQuIDS.so)

target_compile_definitions(NuOscillatorCompilerOptions INTERFACE UseNuSQUIDSLinear=1)
endif()

if(${UseGPU} EQUAL 1)
target_compile_definitions(NuOscillatorCompilerOptions INTERFACE UseGPU=1)
else()
Expand Down
22 changes: 22 additions & 0 deletions Configs/Binned_NuSQUIDSLinear.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
General:
Verbosity: "NONE"
CosineZIgnored: false
CalculationType: "Binned"

Binned:
FileName: "./Inputs/ExampleAtmosphericBinning.root"
EnergyAxisHistName: "EnergyAxisBinning"
CosineZAxisHistName: "CosineZAxisBinning"

OscProbCalcerSetup:
ImplementationName: "NuSQUIDSLinear"
OscChannelMapping:
- Entry: "Electron:Electron"
- Entry: "Electron:Muon"
- Entry: "Electron:Tau"
- Entry: "Muon:Electron"
- Entry: "Muon:Muon"
- Entry: "Muon:Tau"
- Entry: "Tau:Electron"
- Entry: "Tau:Muon"
- Entry: "Tau:Tau"
15 changes: 15 additions & 0 deletions Configs/OscProbCalcerConfigs/NuSQUIDSLinear.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
General:
Verbosity: "NONE"

OscProbCalcerSetup:
ImplementationName: "NuSQUIDSLinear"
OscChannelMapping:
- Entry: "Electron:Electron"
- Entry: "Electron:Muon"
- Entry: "Electron:Tau"
- Entry: "Muon:Electron"
- Entry: "Muon:Muon"
- Entry: "Muon:Tau"
- Entry: "Tau:Electron"
- Entry: "Tau:Muon"
- Entry: "Tau:Tau"
17 changes: 17 additions & 0 deletions Configs/Unbinned_NuSQUIDSLinear.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
General:
Verbosity: "NONE"
CosineZIgnored: false
CalculationType: "Unbinned"

OscProbCalcerSetup:
ImplementationName: "NuSQUIDSLinear"
OscChannelMapping:
- Entry: "Electron:Electron"
- Entry: "Electron:Muon"
- Entry: "Electron:Tau"
- Entry: "Muon:Electron"
- Entry: "Muon:Muon"
- Entry: "Muon:Tau"
- Entry: "Tau:Electron"
- Entry: "Tau:Muon"
- Entry: "Tau:Tau"
4 changes: 4 additions & 0 deletions Constants/OscillatorConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ inline std::vector<std::string> ReturnKnownConfigs() {

#if UseNuFASTLinear == 1
ConfigNames.push_back("./Configs/Binned_NuFASTLinear.yaml");
#endif

#if UseNuSQUIDSLinear == 1
ConfigNames.push_back("./Configs/Binned_NuSQUIDSLinear.yaml");
#endif

return ConfigNames;
Expand Down
2 changes: 1 addition & 1 deletion Docs/DockerFiles/Alma9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN git checkout ${NUOSCILLATOR_VERSION}

RUN mkdir -p ${NuOscillator_INSTALL_DIR}
WORKDIR ${NuOscillator_INSTALL_DIR}
RUN cmake -DUseGPU=0 -DUseMultithreading=1 -DUseDoubles=1 -DUseCUDAProb3=0 -DUseCUDAProb3Linear=1 -DUseProb3ppLinear=1 -DUseNuFASTLinear=1 -DUseProbGPULinear=0 ${NuOscillator_WORK_DIR}
RUN cmake -DUseGPU=0 -DUseMultithreading=1 -DUseDoubles=1 -DUseCUDAProb3=0 -DUseCUDAProb3Linear=1 -DUseProb3ppLinear=1 -DUseNuFASTLinear=1 -DUseProbGPULinear=0 -DUseNuSQUIDSLinear=1 ${NuOscillator_WORK_DIR}
RUN make VERBOSE=1 && make install

# KS: Need to set them here, otherwise container using this container will not be able to find NuOscillator
Expand Down
94 changes: 55 additions & 39 deletions OscProbCalcer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,88 @@ add_library(OscProbCalcer SHARED OscProbCalcerBase.cpp OscProbCalcerFactory.cpp)
target_link_libraries(OscProbCalcer yaml-cpp NuOscillatorCompilerOptions)

target_include_directories(OscProbCalcer PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:include>
)

install(TARGETS yaml-cpp
EXPORT NuOscillator-targets
LIBRARY DESTINATION lib/
PUBLIC_HEADER DESTINATION include/yaml-cpp
)
EXPORT NuOscillator-targets
LIBRARY DESTINATION lib/
PUBLIC_HEADER DESTINATION include/yaml-cpp
)

install(DIRECTORY ${yaml-cpp_SOURCE_DIR}/include/
DESTINATION include/
DESTINATION include/
)

if(${UseCUDAProb3} EQUAL 1)
target_sources(OscProbCalcer PRIVATE OscProbCalcer_CUDAProb3.cpp)
if(${UseGPU} EQUAL 1)
set_source_files_properties(OscProbCalcer_CUDAProb3.cpp PROPERTIES LANGUAGE CUDA)
endif()
target_include_directories(OscProbCalcer PRIVATE ${CUDAProb3_SOURCE_DIR})
list(APPEND HEADERS OscProbCalcer_CUDAProb3.h)
target_sources(OscProbCalcer PRIVATE OscProbCalcer_CUDAProb3.cpp)
if(${UseGPU} EQUAL 1)
set_source_files_properties(OscProbCalcer_CUDAProb3.cpp PROPERTIES LANGUAGE CUDA)
endif()
target_include_directories(OscProbCalcer PRIVATE ${CUDAProb3_SOURCE_DIR})
list(APPEND HEADERS OscProbCalcer_CUDAProb3.h)
endif()

if(${UseCUDAProb3Linear} EQUAL 1)
target_link_libraries(OscProbCalcer CUDAProb3Beam)
target_sources(OscProbCalcer PRIVATE OscProbCalcer_CUDAProb3Linear.cpp)
if(${UseGPU} EQUAL 1)
set_source_files_properties(OscProbCalcer_CUDAProb3Linear.cpp PROPERTIES LANGUAGE CUDA)
target_include_directories(OscProbCalcer PRIVATE ${CUDAProb3_SOURCE_DIR})
endif()
list(APPEND HEADERS OscProbCalcer_CUDAProb3Linear.h)
target_link_libraries(OscProbCalcer CUDAProb3Beam)
target_sources(OscProbCalcer PRIVATE OscProbCalcer_CUDAProb3Linear.cpp)
if(${UseGPU} EQUAL 1)
set_source_files_properties(OscProbCalcer_CUDAProb3Linear.cpp PROPERTIES LANGUAGE CUDA)
target_include_directories(OscProbCalcer PRIVATE ${CUDAProb3_SOURCE_DIR})
endif()
list(APPEND HEADERS OscProbCalcer_CUDAProb3Linear.h)
endif()

if(${UseProbGPULinear} EQUAL 1)
target_link_libraries(OscProbCalcer ProbGPU)
set_property(TARGET ProbGPU PROPERTY CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES})
target_sources(OscProbCalcer PRIVATE OscProbCalcer_ProbGPULinear.cpp)
list(APPEND HEADERS OscProbCalcer_ProbGPULinear.h)
target_link_libraries(OscProbCalcer ProbGPU)
set_property(TARGET ProbGPU PROPERTY CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES})
target_sources(OscProbCalcer PRIVATE OscProbCalcer_ProbGPULinear.cpp)
list(APPEND HEADERS OscProbCalcer_ProbGPULinear.h)
endif()

if(${UseProb3ppLinear} EQUAL 1)
target_link_libraries(OscProbCalcer Prob3plusplus)
target_sources(OscProbCalcer PRIVATE OscProbCalcer_Prob3ppLinear.cpp)
list(APPEND HEADERS OscProbCalcer_Prob3ppLinear.h)
target_link_libraries(OscProbCalcer Prob3plusplus)
target_sources(OscProbCalcer PRIVATE OscProbCalcer_Prob3ppLinear.cpp)
list(APPEND HEADERS OscProbCalcer_Prob3ppLinear.h)
endif()

if(${UseNuFASTLinear} EQUAL 1)
include_directories(${NuFAST_SOURCE_DIR})
target_sources(OscProbCalcer PRIVATE OscProbCalcer_NuFASTLinear.cpp)
list(APPEND HEADERS OscProbCalcer_NuFASTLinear.h)
include_directories(${NuFAST_SOURCE_DIR})
target_sources(OscProbCalcer PRIVATE OscProbCalcer_NuFASTLinear.cpp)
list(APPEND HEADERS OscProbCalcer_NuFASTLinear.h)
endif()

if(${UseNuSQUIDSLinear} EQUAL 1)
include_directories(${SQUIDS_INC_DIR})
include_directories(${NUSQUIDS_INC_DIR})
include_directories(${NUSQUIDS_SRC_DIR})

set(NUSQUIDSEXAMPLES nuSQUIDSDecoh.o)

target_link_libraries(OscProbCalcer GSL::gsl GSL::gslcblas HDF5::HDF5 SQUIDS::SQUIDS NUSQUIDS::NUSQUIDS)
foreach(VAR ${NUSQUIDSEXAMPLES})
target_link_libraries(OscProbCalcer ${NUSQUIDS_SRC_DIR}/build/${VAR})
endforeach(VAR)
target_sources(OscProbCalcer PRIVATE OscProbCalcer_NuSQUIDSLinear.cpp)
list(APPEND HEADERS OscProbCalcer_NuSQUIDSLinear.h)

endif()

if (${UseGPU} EQUAL 1)
set_target_properties(OscProbCalcer PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
LINKER_LANGUAGE CUDA
EXPORT_NAME OscProbCalcer)
set_target_properties(OscProbCalcer PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
LINKER_LANGUAGE CUDA
EXPORT_NAME OscProbCalcer)
endif()

set_target_properties(OscProbCalcer PROPERTIES
PUBLIC_HEADER "${HEADERS}"
EXPORT_NAME OscProbCalcer)
PUBLIC_HEADER "${HEADERS}"
EXPORT_NAME OscProbCalcer)

install(TARGETS OscProbCalcer
EXPORT NuOscillator-targets
LIBRARY DESTINATION lib/
PUBLIC_HEADER DESTINATION include/OscProbCalcer)
EXPORT NuOscillator-targets
LIBRARY DESTINATION lib/
PUBLIC_HEADER DESTINATION include/OscProbCalcer)

add_library(OscProbCalcer::OscProbCalcer ALIAS OscProbCalcer)
15 changes: 15 additions & 0 deletions OscProbCalcer/OscProbCalcerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "OscProbCalcer/OscProbCalcer_NuFASTLinear.h"
#endif

#if UseNuSQUIDSLinear==1
#include "OscProbCalcer/OscProbCalcer_NuSQUIDSLinear.h"
#endif

#include <iostream>

OscProbCalcerFactory::OscProbCalcerFactory() {
Expand Down Expand Up @@ -94,6 +98,17 @@ OscProbCalcerBase* OscProbCalcerFactory::CreateOscProbCalcer(YAML::Node OscProbC
throw;
#endif
}

else if (OscProbCalcerImplementationToCreate == "NuSQUIDSLinear") {
#if UseNuSQUIDSLinear==1
OscProbCalcerNuSQUIDSLinear* NuSQUIDSLinear = new OscProbCalcerNuSQUIDSLinear(OscProbCalcerConfig);
Calcer = (OscProbCalcerBase*)NuSQUIDSLinear;
if (Verbose >= NuOscillator::INFO) {std::cout << "Initalised OscProbCalcer Implementation:" << Calcer->ReturnImplementationName() << " in OscProbCalcerFactory object" << std::endl;}
#else
std::cerr << "OscProbCalcerFactory was requsted to create " << OscProbCalcerImplementationToCreate << " OscProbCalcer but Use" << OscProbCalcerImplementationToCreate << " is undefined. Indicates problem in setup" << std::endl;
throw;
#endif
}

else {
std::cerr << "OscProbCalcerFactory was requsted to create " << OscProbCalcerImplementationToCreate << " OscProbCalcer but this is not implemented within " << __FILE__ << std::endl;
Expand Down
Loading
Loading