Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cuda support #1

Merged
merged 30 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e2b9b94
[python] Reenable multiprocessing in voxelizer
tobiashienzsch Sep 14, 2024
5d5f190
[python] Add typing to air absorption functions
tobiashienzsch Sep 14, 2024
559f8a4
Improve docs
tobiashienzsch Sep 14, 2024
595fcdf
Add PTX flags to sycl build
tobiashienzsch Sep 14, 2024
fb70efa
Update InfiniteBaffle model
tobiashienzsch Sep 14, 2024
de893f1
Update ProStudio model
tobiashienzsch Sep 14, 2024
0b12cdb
[python] Add autopep8 config
tobiashienzsch Sep 14, 2024
5cc3ffb
Set Nprocs=1 in unit tests
tobiashienzsch Sep 15, 2024
7d579f2
Convert _cpu.py suffix to _setup.py
tobiashienzsch Sep 15, 2024
90853f2
Enable CUDA in CMake for sim3d
tobiashienzsch Sep 15, 2024
05944e2
Cleanup viz models
tobiashienzsch Sep 16, 2024
90bc99b
Convert InfiniteBaffle model to Setup3D subclass
tobiashienzsch Sep 16, 2024
eb47746
Convert CTK_Church, LovingRoom & Localization models to Setup3D
tobiashienzsch Sep 16, 2024
9bae141
Convert rest of models to use Setup3D subclass
tobiashienzsch Sep 16, 2024
af6c5d5
Add missing license info for InfiniteBaffle
tobiashienzsch Sep 16, 2024
fd5c909
Add pre-commit hooks for "reuse lint"
tobiashienzsch Sep 16, 2024
42c9e93
Fix line endings
tobiashienzsch Sep 16, 2024
d9247ca
Convert double quotes to single quotes
tobiashienzsch Sep 16, 2024
7d5d682
Add pre-commit hook for clang-format
tobiashienzsch Sep 16, 2024
46f7b2f
Add custom assert macro. Always enabled
tobiashienzsch Sep 16, 2024
8bdc805
[cpp] Convert MatQuad to template
tobiashienzsch Sep 17, 2024
a8afa87
[cpp] Apply clang-tidy auto fixes
tobiashienzsch Sep 17, 2024
b7b4263
[cpp] Apply clang-tidy auto fixes to CUDA code
tobiashienzsch Sep 17, 2024
b5b7c4e
[cpp] Cleanup namespaces
tobiashienzsch Sep 17, 2024
f1f9fd3
[cpp] Convert HostData & DeviceData to templates
tobiashienzsch Sep 17, 2024
4e83ec6
Add ccache to CMake
tobiashienzsch Sep 17, 2024
7becc18
Cleanup CMake options
tobiashienzsch Sep 17, 2024
96f59dc
[cpp] Add compiler warning flags
tobiashienzsch Sep 17, 2024
181dd98
[cpp] Convert SYCL 2D kernels to templates
tobiashienzsch Sep 18, 2024
7534753
[python] Improve detect_room_modes
tobiashienzsch Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
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