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

Add 3D filters #22

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Language: Cpp
BasedOnStyle: LLVM
IndentWidth: 4
AccessModifierOffset: -4
ContinuationIndentWidth: 8
ConstructorInitializerIndentWidth: 8
ColumnLimit: 88
BinPackArguments: false
BinPackParameters: false
PackConstructorInitializers: NextLine
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{cpp,h,yaml,yml}]
indent_size = 2
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
__pycache__/
*.egg-info/
/.benchmarks/
/.pytest_cache/
/build/
/.ruff_cache/
/dist/
/src/**/*.so
/out/

__pycache__/
*.egg-info/
*.so
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "benchmark"]
path = deps/benchmark
url = https://github.com/google/benchmark.git
[submodule "highway"]
path = deps/highway
url = https://github.com/google/highway.git
Expand Down
57 changes: 23 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,46 +1,35 @@
cmake_minimum_required(VERSION 3.19...3.25)
cmake_minimum_required(VERSION 3.20)
project(fastfilters2 LANGUAGES CXX)

set(CMAKE_BUILD_TYPE Release)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
function(set_cxx_standard target standard)
set_target_properties(${target} PROPERTIES
CXX_STANDARD ${standard}
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF)
endfunction()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
function(enable_cxx_warnings target)
target_compile_options(${target} PRIVATE
$<$<CXX_COMPILER_ID:AppleClang,Clang,GNU>:-Wall -Wextra>
$<$<CXX_COMPILER_ID:MSVC>:/W4>)
endfunction()

option(FASTFILTERS2_BENCHMARK "Build benchmarks")

set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "")
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "")
set(BUILD_TESTING OFF CACHE BOOL "")
set(HWY_ENABLE_CONTRIB OFF CACHE BOOL "")
set(HWY_ENABLE_EXAMPLES OFF CACHE BOOL "")
set(HWY_ENABLE_INSTALL OFF CACHE BOOL "")
set(HWY_ENABLE_TESTS OFF CACHE BOOL "")

if(${FASTFILTERS2_BENCHMARK})
add_subdirectory(deps/benchmark)
endif()
add_subdirectory(deps/highway)
add_subdirectory(deps/pybind11)
add_subdirectory(deps/highway)

add_library(fastfilters2 cpp/fastfilters2.cpp)
target_link_libraries(fastfilters2 PRIVATE hwy)
target_include_directories(fastfilters2 PUBLIC cpp)
target_include_directories(fastfilters2 PRIVATE cpp)
set_target_properties(fastfilters2 PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_cxx_standard(fastfilters2 17)
enable_cxx_warnings(fastfilters2)

pybind11_add_module(_core cpp/_core.cpp)
pybind11_add_module(_core cpp/module.cpp)
target_link_libraries(_core PRIVATE fastfilters2)
install(TARGETS _core DESTINATION fastfilters2)

if(FASTFILTERS2_BENCHMARK)
add_executable(bm cpp/benchmark.cpp)
target_link_libraries(bm PRIVATE fastfilters2 benchmark::benchmark)
add_custom_target(
runbm
"$<TARGET_FILE:bm>"
DEPENDS bm
WORKING_DIRECTORY ${bm_BINARY_DIR}
VERBATIM
USES_TERMINAL
COMMAND_EXPAND_LISTS
)
endif()
set_target_properties(_core PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/fastfilters2)
set_cxx_standard(_core 17)
enable_cxx_warnings(_core)
20 changes: 7 additions & 13 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
{
"version": 3,
"version": 2,
"configurePresets": [
{
"name": "dev",
"name": "main",
"generator": "Ninja",
"binaryDir": "build",
"installDir": "src",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"FASTFILTERS2_BENCHMARK": "ON"
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
}
}
],
"buildPresets": [
{
"name": "dev.bm",
"configurePreset": "dev",
"targets": ["runbm"]
},
{
"name": "dev.install",
"configurePreset": "dev",
"targets": ["install"]
"name": "main",
"configurePreset": "main"
}
]
}
50 changes: 32 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,53 @@

> SIMD-accelerated 2D and 3D image features

## Local development
## Development

### Setup

The following commands use [Mambaforge][mambaforge] for installing build dependencies.
You should also have a working, modern C++ compiler toolchain installed in your system.
C++17 compiler and the corresponding toolchain should be available in system path.

```sh
# Create and activate a local development environment.
mamba create --name ff2dev --yes python pip cmake ninja numpy
conda activate ff2dev
mamba create --name ff2 --channel conda-forge --channel ilastik-forge --yes cmake ninja python pip fastfilters pytest pytest-benchmark
mamba activate ff2

# Configure cmake.
cmake --preset main

# Install this package in editable mode:
# all changes in Python source code are picked up automatically.
# Install this package in editable mode.
# All changes in Python source code are picked up automatically.
pip install --editable .

# Configure CMake build.
cmake --preset dev
# Build extension module.
# Should run this when C++ source changes.
# The module is automatically placed in the correct path.
cmake --build --preset main

# Build and run benchmarks: this needs to be run when C++ source files change.
cmake --build --preset dev.bm
# Run tests.
pytest --benchmark-skip

# Build and install Python module: this needs to be run when C++ source files change.
cmake --build --preset dev.install
# Run benchmarks.
pytest --benchmark-only --benchmark-group-by=param:name,param:shape,param:scale -k benchmark_filter
```

## Guides

### Add a new submodule dependency

```sh
git submodule add --name REPO https://github.com/OWNER/REPO.git deps/REPO
git -C deps/REPO switch --detach TAG
git add .
git commit --message
git submodule add --name REPO_NAME REPO_URL deps/REPO_NAME
git -C deps/REPO_NAME switch --detach REPO_TAG
git add deps/REPO_NAME
git commit
```

### Update submodule dependency

```sh
git -C deps/REPO_NAME fetch
git -C deps/REPO_NAME switch --detach REPO_TAG
git add deps/REPO_NAME
git commit
```

[mambaforge]: https://github.com/conda-forge/miniforge#mambaforge
61 changes: 0 additions & 61 deletions cpp/_core.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions cpp/benchmark.cpp

This file was deleted.

Loading