Commit 393dd5e1 authored by Philipp Fensch's avatar Philipp Fensch
Browse files

Added dependent option WITH_CUDA; now links with cuda-libraries

parent 99b2ea30
cmake_minimum_required(VERSION 3.5)
project(DPsim CXX CUDA)
project(DPsim CXX)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(TOPLEVEL_PROJECT ON)
else()
set(TOPLEVEL_PROJECT OFF)
set(TOPLEVEL_PROJECT OFF)
endif()
# Enable C++11 support
......@@ -71,6 +71,7 @@ find_package(PythonLibs 3.6)
find_package(Sundials)
find_package(OpenMP)
find_package(CUDA)
find_package(GSL)
find_package(VILLASnode)
......@@ -89,7 +90,6 @@ include(CMakeDependentOption)
option(BUILD_SHARED_LIBS "Build shared library" OFF)
option(BUILD_EXAMPLES "Build C++ examples" ON )
option(COMPARE_REFERENCE "Download reference results and compare" OFF)
option(WITH_CUDA "Enable CUDA-based parallelisation" ON )
cmake_dependent_option(WITH_GSL "Enable GSL" ON "GSL_FOUND" OFF)
cmake_dependent_option(WITH_SUNDIALS "Enable sundials solver suite" ON "Sundials_FOUND" OFF)
......@@ -98,6 +98,11 @@ cmake_dependent_option(WITH_RT "Enable real-time features" ON "Linux_FOUND
cmake_dependent_option(WITH_PYTHON "Enable Python support" OFF "Python_FOUND" OFF)
cmake_dependent_option(WITH_CIM "Enable support for parsing CIM files" ON "CIMpp_FOUND" OFF)
cmake_dependent_option(WITH_OPENMP "Enable OpenMP-based parallelisation" ON "OPENMP_FOUND" OFF)
cmake_dependent_option(WITH_CUDA "Enable CUDA-based parallelisation" ON "CUDA_FOUND" OFF)
if(WITH_CUDA)
enable_language(CUDA)
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Include/dpsim/Config.h.in
......
......@@ -38,6 +38,7 @@
#cmakedefine WITH_PYTHON
#cmakedefine WITH_SUNDIALS
#cmakedefine WITH_OPENMP
#cmakedefine WITH_CUDA
#cmakedefine HAVE_TIMERFD
#cmakedefine HAVE_PIPE
......
......@@ -62,7 +62,7 @@ if(WITH_CUDA)
)
list(APPEND INCLUDE_DIRS ${CUDA_INCLUDE_DIRS} ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
list(APPEND LIBRARIES ${CUDA_LIBRARIES} ${CUDA_cusolver_LIBRARY})
endif()
if(WITH_OPENMP)
......
......@@ -27,7 +27,7 @@
#include <dpsim/Simulation.h>
#include <dpsim/Utils.h>
#include <cps/Utils.h>
#include <dpsim/MNASolver.h>
#include <dpsim/MNASolverGpu.h>
#include <dpsim/PFSolverPowerPolar.h>
#include <dpsim/DiakopticsSolver.h>
......@@ -143,8 +143,13 @@ void Simulation::createSolvers(
solver = std::make_shared<DiakopticsSolver<VarType>>(mName,
subnets[net], tearComponents, mTimeStep, mLogLevel);
} else {
#ifdef WITH_CUDA
solver = std::make_shared<MnaSolverGpu<VarType>>(
mName + copySuffix, mDomain, mLogLevel);
#else
solver = std::make_shared<MnaSolver<VarType>>(
mName + copySuffix, mDomain, mLogLevel);
#endif /* WITH_CUDA */
solver->setTimeStep(mTimeStep);
solver->doSteadyStateInitialization(mSteadyStateInit);
solver->doFrequencyParallelization(mHarmParallel);
......@@ -157,6 +162,7 @@ void Simulation::createSolvers(
solver = std::make_shared<DAESolver>(mName + copySuffix, subnets[net], mTimeStep, 0.0);
break;
#endif /* WITH_SUNDIALS */
default:
throw UnsupportedSolverException();
}
......
Supports Markdown
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