Skip to content

Commit

Permalink
Merge pull request #1 from tobanteAudio/cuda-support
Browse files Browse the repository at this point in the history
Cuda support
  • Loading branch information
tobiashienzsch authored Sep 18, 2024
2 parents c504839 + 7534753 commit ba920f4
Show file tree
Hide file tree
Showing 104 changed files with 4,296 additions and 4,081 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true
ColumnLimit: 82
ColumnLimit: 120
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
Cpp11BracedListStyle: true
Expand Down
48 changes: 34 additions & 14 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,61 @@
Checks: >
*-,
-bugprone-*,
-bugprone-macro-parentheses,
bugprone-*,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-exception-escape,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-signed-char-misuse,
-cert-*,
cert-*,
-cert-dcl03-c,
-cert-err33-c,
-cert-err58-cpp,
-cert-oop54-cpp,
-cert-str34-c,
-clang-analyzer-*,
-clang-diagnostics-*,
clang-analyzer-*,
clang-diagnostics-*,
-concurrency-*,
concurrency-*,
-concurrency-mt-unsafe,
-cppcoreguidelines-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-pro-type-cstyle-cast,
-cppcoreguidelines-narrowing-conversions,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-owning-memory,
-hicpp-*,
-misc-*,
hicpp-*,
-hicpp-no-array-decay,
-hicpp-signed-bitwise,
-modernize-*,
misc-*,
-misc-confusable-identifiers,
-misc-include-cleaner,
-misc-use-anonymous-namespace,
modernize-*,
performance-*,
-readability-*,
-readability-identifier-naming,
-readability-const-return-type,
readability-*,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-identifier-naming,
-readability-magic-numbers,
-*-avoid-c-arrays,
-*-no-malloc,
-*-non-private-member-variables-in-classes,
-*-special-member-functions,
-*-static-assert,
-*-vararg,
WarningsAsErrors: "*"
FormatStyle: none
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2024 Tobias Hienzsch

name: REUSE Compliance Check

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
lfs: true

- name: REUSE Compliance Check
uses: fsfe/reuse-action@v4
30 changes: 25 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,32 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-yaml
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-yaml
- id: check-xml
- id: trailing-whitespace
- id: end-of-file-fixer
- id: detect-private-key
- id: check-case-conflict
# - id: check-added-large-files
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
hooks:
- id: autopep8

- repo: https://github.com/fsfe/reuse-tool
rev: v4.0.3
hooks:
- id: reuse

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.8
hooks:
- id: clang-format
types_or: [c, c++, cuda, metal]
26 changes: 20 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2024 Tobias Hienzsch

cmake_minimum_required(VERSION 3.24)
project(pffdtd VERSION 1.0.0 LANGUAGES C CXX)

option(PFFDTD_ENABLE_CUDA "Build with CUDA" OFF)
option(PFFDTD_ENABLE_SYCL_ACPP "Build with AdaptiveCpp SYCL" OFF)
option(PFFDTD_ENABLE_SYCL_ONEAPI "Build with Intel SYCL" OFF)

find_program(CCACHE ccache)
if (CCACHE)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
endif ()

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
Expand All @@ -12,8 +20,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(PFFDTD_ENABLE_ACPP_SYCL "Build with AdaptiveCpp SYCL" OFF)
option(PFFDTD_ENABLE_INTEL_SYCL "Build with Intel SYCL" OFF)
if(PFFDTD_ENABLE_CUDA)
enable_language(CUDA)
set(CMAKE_CUDA_STANDARD 20)
endif()

project(pffdtd VERSION 0.1.0 LANGUAGES C CXX)

include(FetchContent)
FetchContent_Declare(mdspan GIT_REPOSITORY "https://github.com/kokkos/mdspan" GIT_TAG "stable" GIT_SHALLOW TRUE)
Expand All @@ -24,12 +36,14 @@ find_package(fmt REQUIRED)
find_package(HDF5 REQUIRED)
find_package(OpenMP REQUIRED)

if(PFFDTD_ENABLE_ACPP_SYCL)
if(PFFDTD_ENABLE_SYCL_ACPP)
find_package(AdaptiveCpp REQUIRED)
set(PFFDTD_HAS_SYCL TRUE)
endif()

if(PFFDTD_ENABLE_INTEL_SYCL)
if(PFFDTD_ENABLE_SYCL_ONEAPI)
find_package(IntelSYCL REQUIRED)
set(PFFDTD_HAS_SYCL TRUE)
endif()

add_subdirectory(src/cpp)
Expand Down
12 changes: 6 additions & 6 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@


class PFFDTD(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"
settings = 'os', 'compiler', 'build_type', 'arch'
generators = 'CMakeToolchain', 'CMakeDeps'

def requirements(self):
self.requires("cli11/2.4.2")
self.requires("fmt/11.0.2")
self.requires('cli11/2.4.2')
self.requires('fmt/11.0.2')

if self.settings.os != "Macos":
self.requires("hdf5/1.14.4.3")
if self.settings.os != 'Macos':
self.requires('hdf5/1.14.4.3')

def config_options(self):
pass
37 changes: 37 additions & 0 deletions data/models/CTK_Church/CTK_Church.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2021 Brian Hamilton
"""This shows a simple setup with Cartesian scheme, for a single-precision GPU run (<2GB VRAM)
"""

from pffdtd.sim3d.setup import Setup3D


class CTK_Church(Setup3D):
"""Christ the King (CTK) Church
"""
model_file = 'model_export.json'
mat_folder = '../../materials'
source_index = 1
source_signal = 'impulse'
diff_source = True
materials = {
'AcousticPanel': 'ctk_acoustic_panel.h5',
'Altar': 'ctk_altar.h5',
'Carpet': 'ctk_carpet.h5',
'Ceiling': 'ctk_ceiling.h5',
'Glass': 'ctk_window.h5',
'PlushChair': 'ctk_chair.h5',
'Tile': 'ctk_tile.h5',
'Walls': 'ctk_walls.h5',
}
duration = 3.0
Tc = 20
rh = 50
fcc = False
ppw = 10.5
fmax = 800.0
save_folder = '../../sim_data/CTK_Church/cpu'
save_folder_gpu = '../../sim_data/CTK_Church/gpu'
compress = 0
draw_vox = True
draw_backend = 'polyscope'
File renamed without changes.
35 changes: 0 additions & 35 deletions data/models/CTK_Church/CTK_gpu.py

This file was deleted.

2 changes: 1 addition & 1 deletion data/models/CTK_Church/model_export.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@
"name":""
}],
"export_datetime":"2021-07-25 08:25:11 +0100"
}
}
73 changes: 73 additions & 0 deletions data/models/InfiniteBaffle/InfiniteBaffle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2024 Tobias Hienzsch
import json

from pffdtd.sim3d.setup import Setup3D


class InfiniteBaffle(Setup3D):
"""Point source on infinite baffle in an anechoic chamber
"""
fmax = 2000
ppw = 10.5
fcc = False
model_file = 'model.json'
mat_folder = '../../materials',
duration = 0.3
source_index = 1
source_signal = 'impulse'
Tc = 20
rh = 50
save_folder = '../../sim_data/InfiniteBaffle/cpu'
save_folder_gpu = '../../sim_data/InfiniteBaffle/gpu'
draw_vox = True
draw_backend = 'polyscope'
compress = 0
rot_az_el = [0, 0]
bmax = [17.15, 2.0, 17.15]
bmin = [0, 0, 0]

def generate_model(self, constants):
mul = 3.0 if self.fcc else 2.0
offset = constants.h * mul

width = self.bmax[0]
length = self.bmax[1]
height = self.bmax[2]

model = {
'mats_hash': {
'_RIGID': {
'tris': [
[0, 2, 1],
[0, 3, 2],
[1, 5, 4],
[1, 3, 5]
],
'pts': [
[0.0, length, 0.0],
[width/2, length, 0.0],
[width/2, length, height],
[0.0, length, height],
[width, length, 0.0],
[width, length, height]
],
'color': [255, 255, 255],
'sides': [0, 0, 0, 0]
}
},
'sources': [
{'name': 'S1', 'xyz': [width/2, length-offset, height/2]},
],
'receivers': [
{'name': 'R1', 'xyz': [width/2, offset, height/2 - 0.75]},
{'name': 'R2', 'xyz': [width/2, offset, height/2 - 0.25]},
{'name': 'R3', 'xyz': [width/2, offset, height/2 + 0.00]},
{'name': 'R4', 'xyz': [width/2, offset, height/2 + 0.25]},
{'name': 'R5', 'xyz': [width/2, offset, height/2 + 0.75]},
]
}

with open(self.model_file, 'w') as file:
json.dump(model, file)
print('', file=file)
27 changes: 0 additions & 27 deletions data/models/InfiniteBaffle/InfiniteBaffle_cpu.py

This file was deleted.

Loading

0 comments on commit ba920f4

Please sign in to comment.