Skip to content

Commit

Permalink
[cpp] Cleanup file names
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Jul 14, 2024
1 parent adb5968 commit c117eee
Show file tree
Hide file tree
Showing 15 changed files with 358 additions and 458 deletions.
8 changes: 8 additions & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ project(pffdtd)
add_library(pffdtd)
add_library(pffdtd::pffdtd ALIAS pffdtd)
target_include_directories(pffdtd PUBLIC ${PROJECT_SOURCE_DIR})
target_compile_definitions(pffdtd PUBLIC PRECISION=2)
target_link_libraries(pffdtd PUBLIC fmt::fmt HDF5::HDF5 opencv_videoio)
target_sources(pffdtd
PRIVATE
pffdtd/config.hpp
pffdtd/exception.hpp
pffdtd/hdf.hpp
pffdtd/progress.cpp
pffdtd/progress.hpp
pffdtd/simulation_2d.cpp
pffdtd/simulation_2d.hpp
pffdtd/simulation_3d.cpp
pffdtd/simulation_3d.hpp
pffdtd/sycl.hpp
pffdtd/utility.cpp
pffdtd/utility.hpp
pffdtd/video.cpp
pffdtd/video.hpp
)
12 changes: 3 additions & 9 deletions src/cpp/main_3d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
project(pffdtd_3d)

add_executable(pffdtd_3d)
target_compile_definitions(pffdtd_3d PRIVATE PRECISION=2 USING_CUDA=0)
target_compile_definitions(pffdtd_3d PRIVATE USING_CUDA=0)
target_sources(pffdtd_3d
PRIVATE
cpu_engine.cpp
cpu_engine.hpp
fdtd_common.cpp
fdtd_common.hpp
fdtd_data.cpp
fdtd_data.hpp
helper_funcs.cpp
helper_funcs.hpp
engine_cpu.cpp
engine_cpu.hpp
main.cpp
)

Expand Down
77 changes: 0 additions & 77 deletions src/cpp/main_3d/Makefile

This file was deleted.

85 changes: 43 additions & 42 deletions src/cpp/main_3d/cpu_engine.cpp → src/cpp/main_3d/engine_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,57 @@
//
// Copyright 2021 Brian Hamilton.
//
// File name: cpu_engine.h
// File name: engine_cpu.hpp
//
// Description: CPU-based implementation of FDTD engine, with OpenMP
//
///////////////////////////////////////////////////////////////////////////////

#include "cpu_engine.hpp"
#include "engine_cpu.hpp"

#include "pffdtd/progress.hpp"
#include "pffdtd/utility.hpp"

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

#include <vector>

#include <assert.h> //for assert
#include <math.h> //NAN
#include <omp.h>
#include <stdbool.h> //for bool
#include <stdint.h>
#include <stdlib.h> //for malloc

double runSim(Simulation3D* sd) {
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <vector>

auto runSim(Simulation3D& sd) -> double {
// keep local ints, scalars
int64_t Ns = sd->Ns;
int64_t Nr = sd->Nr;
int64_t Nt = sd->Nt;
int64_t Npts = sd->Npts;
int64_t Nx = sd->Nx;
int64_t Ny = sd->Ny;
int64_t Nz = sd->Nz;
int64_t Nb = sd->Nb;
int64_t Nbl = sd->Nbl;
int64_t Nba = sd->Nba;
int8_t* Mb = sd->Mb;
int64_t Ns = sd.Ns;
int64_t Nr = sd.Nr;
int64_t Nt = sd.Nt;
int64_t Npts = sd.Npts;
int64_t Nx = sd.Nx;
int64_t Ny = sd.Ny;
int64_t Nz = sd.Nz;
int64_t Nb = sd.Nb;
int64_t Nbl = sd.Nbl;
int64_t Nba = sd.Nba;
int8_t* Mb = sd.Mb;

// keep local copies of pointers (style choice)
int64_t* bn_ixyz = sd->bn_ixyz;
int64_t* bnl_ixyz = sd->bnl_ixyz;
int64_t* bna_ixyz = sd->bna_ixyz;
int64_t* in_ixyz = sd->in_ixyz;
int64_t* out_ixyz = sd->out_ixyz;
uint16_t* adj_bn = sd->adj_bn;
uint8_t* bn_mask = sd->bn_mask;
int8_t* mat_bnl = sd->mat_bnl;
int8_t* Q_bna = sd->Q_bna;
double* in_sigs = sd->in_sigs;
double* u_out = sd->u_out;
int8_t fcc_flag = sd->fcc_flag;
Real* ssaf_bnl = sd->ssaf_bnl;
Real* mat_beta = sd->mat_beta;
MatQuad* mat_quads = sd->mat_quads;
int64_t* bn_ixyz = sd.bn_ixyz;
int64_t* bnl_ixyz = sd.bnl_ixyz;
int64_t* bna_ixyz = sd.bna_ixyz;
int64_t* in_ixyz = sd.in_ixyz;
int64_t* out_ixyz = sd.out_ixyz;
uint16_t* adj_bn = sd.adj_bn;
uint8_t* bn_mask = sd.bn_mask;
int8_t* mat_bnl = sd.mat_bnl;
int8_t* Q_bna = sd.Q_bna;
double* in_sigs = sd.in_sigs;
double* u_out = sd.u_out;
int8_t fcc_flag = sd.fcc_flag;
Real* ssaf_bnl = sd.ssaf_bnl;
Real* mat_beta = sd.mat_beta;
MatQuad* mat_quads = sd.mat_quads;

// allocate memory
auto u0_buf = std::vector<Real>(static_cast<size_t>(Npts));
Expand All @@ -77,11 +78,11 @@ double runSim(Simulation3D* sd) {
Real* gh1 = gh1_buf.data();

// sim coefficients
Real lo2 = sd->lo2;
Real sl2 = sd->sl2;
Real l = sd->l;
Real a1 = sd->a1;
Real a2 = sd->a2;
Real lo2 = sd.lo2;
Real sl2 = sd.sl2;
Real l = sd.l;
Real a1 = sd.a1;
Real a2 = sd.a2;

// can control outside with OMP_NUM_THREADS env variable
int num_workers = omp_get_max_threads();
Expand Down Expand Up @@ -316,7 +317,7 @@ double runSim(Simulation3D* sd) {
time_elapsed = current_time - start_time;
time_elapsed_sample = current_time - sample_start_time;
// print progress (can be removed or changed)
print_progress(
pffdtd::print_progress(
n,
Nt,
Npts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
//
// Copyright 2021 Brian Hamilton.
//
// File name: cpu_engine.h
// File name: engine_cpu.hpp
//
// Description: CPU-based implementation of FDTD engine, with OpenMP
//
///////////////////////////////////////////////////////////////////////////////

#pragma once

#include "fdtd_common.hpp"
#include "fdtd_data.hpp"
#include "helper_funcs.hpp"
#include "pffdtd/config.hpp"
#include "pffdtd/simulation_3d.hpp"

double runSim(Simulation3D* sd);
#include <cstdint>

auto runSim(Simulation3D& sd) -> double;
double process_bnl_pts_fd(
Real* u0b,
Real const* u2b,
Expand Down
Loading

0 comments on commit c117eee

Please sign in to comment.