Skip to content

Commit

Permalink
[cpp] Move engines to library
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Sep 19, 2024
1 parent 0fefb46 commit 3cd6267
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 25 deletions.
10 changes: 9 additions & 1 deletion src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ target_link_libraries(pffdtd
target_sources(pffdtd
PRIVATE
pffdtd/config.hpp
pffdtd/engine_2d_native.cpp
pffdtd/engine_2d_native.hpp
pffdtd/engine_openmp.cpp
pffdtd/engine_openmp.hpp
pffdtd/exception.hpp
Expand All @@ -40,7 +42,14 @@ target_sources(pffdtd
target_compile_definitions(pffdtd PUBLIC _CRT_SECURE_NO_WARNINGS=1)

if(PFFDTD_HAS_SYCL)
target_sources(pffdtd PRIVATE pffdtd/engine_2d_sycl.cpp pffdtd/engine_2d_sycl.hpp)
add_sycl_to_target(TARGET pffdtd SOURCES pffdtd/engine_2d_sycl.cpp)
target_compile_definitions(pffdtd PUBLIC PFFDTD_HAS_SYCL=1)

if(PFFDTD_ENABLE_SYCL_ONEAPI)
set_source_files_properties(pffdtd/engine_2d_sycl.cpp PROPERTIES COMPILE_FLAGS "-fsycl-targets=nvptx64-nvidia-cuda")
target_link_libraries(pffdtd PRIVATE "-fsycl-targets=nvptx64-nvidia-cuda")
endif()
endif()

if(PFFDTD_ENABLE_CUDA)
Expand All @@ -50,7 +59,6 @@ else()
target_compile_definitions(pffdtd PUBLIC PFFDTD_HAS_CUDA=0)
endif()


if((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") OR (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC"))
target_compile_options(pffdtd PUBLIC /W3)
else ()
Expand Down
12 changes: 1 addition & 11 deletions src/cpp/main_2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,5 @@

project(pffdtd_2d)

add_executable(pffdtd_2d main.cpp engine_native.cpp)
add_executable(pffdtd_2d main.cpp)
target_link_libraries(pffdtd_2d PRIVATE CLI11::CLI11 pffdtd::pffdtd)

if(PFFDTD_HAS_SYCL)
target_sources(pffdtd_2d PRIVATE engine_sycl.cpp)
add_sycl_to_target(TARGET pffdtd_2d SOURCES engine_sycl.cpp)
endif()

if(PFFDTD_ENABLE_SYCL_ONEAPI)
set_source_files_properties(engine_sycl.cpp PROPERTIES COMPILE_FLAGS "-fsycl-targets=nvptx64-nvidia-cuda")
target_link_libraries(pffdtd_2d PRIVATE "-fsycl-targets=nvptx64-nvidia-cuda")
endif()
12 changes: 5 additions & 7 deletions src/cpp/main_2d/main.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 Tobias Hienzsch

#include "engine_native.hpp"

#if defined(PFFDTD_HAS_SYCL)
#include "engine_sycl.hpp"
#endif

#include "pffdtd/engine_2d_native.hpp"
#include "pffdtd/exception.hpp"
#include "pffdtd/hdf.hpp"
#include "pffdtd/simulation_2d.hpp"
#include "pffdtd/time.hpp"

#include <CLI/CLI.hpp>
#if defined(PFFDTD_HAS_SYCL)
#include "pffdtd/engine_2d_sycl.hpp"
#endif

#include <CLI/CLI.hpp>
#include <fmt/format.h>

#include <chrono>
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/main_3d/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// SPDX-FileCopyrightText: 2021 Brian Hamilton
// Main entry point of the CPU/GPU PFFDTD engines.

#include "pffdtd/simulation_3d.hpp"
#include "pffdtd/time.hpp"
#include "pffdtd/utility.hpp"

#ifndef PFFDTD_HAS_CUDA
#error "forgot to define PFFDTD_HAS_CUDA"
#endif

#include "pffdtd/simulation_3d.hpp"
#include "pffdtd/time.hpp"
#include "pffdtd/utility.hpp"

#if PFFDTD_HAS_CUDA
#include "pffdtd/engine_cuda.hpp"
#else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 Tobias Hienzsch

#include "engine_native.hpp"
#include "engine_2d_native.hpp"

#include <fmt/format.h>

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 Tobias Hienzsch

#include "engine_sycl.hpp"
#include "engine_2d_sycl.hpp"

#include "pffdtd/sycl.hpp"

Expand Down
File renamed without changes.

0 comments on commit 3cd6267

Please sign in to comment.