Skip to content

Commit

Permalink
Add CLI11
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Jul 11, 2024
1 parent 51a1eba commit 3fa3b7f
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
pip3 install --upgrade conan
- name: Install clang
if: runner.os == 'Windows'
if: runner.os != 'macOS'
uses: egor-tensin/setup-clang@v1

- name: Setup conan
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(PFFDTD_ENABLE_SYCL "Build with sycl" OFF)

find_package(CLI11 REQUIRED)
find_package(fmt REQUIRED)
find_package(HDF5 REQUIRED)
find_package(OpenCV REQUIRED COMPONENTS core videoio)
Expand Down
2 changes: 2 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[requires]
cli11/2.4.2
fmt/11.0.1
hdf5/1.14.4.3
opencv/4.10.0
Expand All @@ -24,6 +25,7 @@ opencv/*:with_openexr=False
opencv/*:with_png=False
opencv/*:with_tiff=False
opencv/*:with_webp=False
opencv/*:with_ffmpeg=True

ffmpeg/*:avdevice=False
ffmpeg/*:avcodec=True
Expand Down
4 changes: 2 additions & 2 deletions run_2d.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ engine_exe="$root_dir/$build_dir/src/cpp/main_2d/pffdtd_2d"
sim_name="Diffusor"
sim_dir="$root_dir/data/sim_data/$sim_name/cpu"

fmax=2000
fmax=1000
duration=0.06

# Delete old sim
Expand All @@ -21,4 +21,4 @@ cd "$python_dir"
python -m sim2d.fdtd --save --data_dir="$sim_dir" --duration="$duration" --fmax="$fmax"

# Run sim
DPCPP_CPU_PLACES=cores DPCPP_CPU_CU_AFFINITY=spread DPCPP_CPU_NUM_CUS=16 "$engine_exe" "$sim_dir/diffusor.h5"
DPCPP_CPU_PLACES=cores DPCPP_CPU_CU_AFFINITY=spread DPCPP_CPU_NUM_CUS=16 "$engine_exe" -s "$sim_dir/diffusor.h5"
3 changes: 2 additions & 1 deletion src/cpp/main_2d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
project(pffdtd_2d)

add_executable(pffdtd_2d)
target_link_libraries(pffdtd_2d PRIVATE pffdtd::pffdtd)
target_link_libraries(pffdtd_2d PRIVATE CLI11::CLI11 pffdtd::pffdtd)
target_compile_options(pffdtd_2d PRIVATE -Wno-deprecated-declarations)
target_sources(pffdtd_2d PRIVATE main.cpp engine.cpp)
add_sycl_to_target(TARGET pffdtd_2d SOURCES engine.cpp)
4 changes: 0 additions & 4 deletions src/cpp/main_2d/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ auto run(Simulation2D const& sim) -> std::vector<double> {
};
auto videoThread = std::thread([&video] { write(video); });

for (auto dev : sycl::device::get_devices()) {
pffdtd::summary(dev);
}

auto prop = sycl::property_list{sycl::property::queue::in_order()};
auto queue = sycl::queue{prop};
auto device = queue.get_device();
Expand Down
21 changes: 18 additions & 3 deletions src/cpp/main_2d/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "pffdtd/hdf.hpp"
#include "pffdtd/simulation_2d.hpp"

#include <CLI/CLI.hpp>

#include <fmt/format.h>
#include <fmt/os.h>

Expand All @@ -12,10 +14,23 @@
#include <stdexcept>
#include <string>

int main(int, char** argv) {
struct Arguments {
std::string simDir{};
std::string out{"out.h5"};
std::string video{"out.avi"};
};

int main(int argc, char** argv) {
auto app = CLI::App{"pffdtd-2d"};
auto args = Arguments{};
app.add_option("-s,--sim_dir", args.simDir, "Folder path");
app.add_option("-o,--out", args.out, "Filename");
app.add_option("-v,--video", args.video, "Filename");
CLI11_PARSE(app, argc, argv);

auto const start = std::chrono::steady_clock::now();

auto filePath = std::filesystem::path{argv[1]};
auto filePath = std::filesystem::path{args.simDir};
if (not std::filesystem::exists(filePath)) {
throw std::runtime_error{"invalid file: " + filePath.string()};
}
Expand All @@ -24,7 +39,7 @@ int main(int, char** argv) {
auto const out = pffdtd::run(sim);

auto dir = filePath.parent_path();
auto outfile = dir / "out.h5";
auto outfile = dir / args.out;
auto results = pffdtd::H5FWriter{outfile.string().c_str()};
results.write("out", std::span{out}, sim.out_ixy.size(), sim.Nt);

Expand Down
6 changes: 3 additions & 3 deletions src/cpp/pffdtd/sycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ inline auto summary(sycl::device dev) -> void {
fmt::println("Vendor: {}", vendor.c_str());
fmt::println("Type: {}", toString(type).c_str());
fmt::println("Max alloc size: {} MB", maxAllocSize / 1024 / 1024);
for (auto groupSize : dev.get_info<sycl::info::device::sub_group_sizes>()) {
fmt::println("Subgroup size: {}", groupSize);
}
// for (auto groupSize : dev.get_info<sycl::info::device::sub_group_sizes>()) {
// fmt::println("Subgroup size: {}", groupSize);
// }
fmt::println("");
}

Expand Down

0 comments on commit 3fa3b7f

Please sign in to comment.