Skip to content
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build/
bilateral_filter
lib/
*.raw
*.o
*.prof
*.nsys-rep
*.ncu-rep
.vscode/
87 changes: 87 additions & 0 deletions 08_bilateral_filter/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
BasedOnStyle: LLVM
Language: Cpp

# Indentation
IndentWidth: 4
TabWidth: 4
UseTab: Never
ContinuationIndentWidth: 4
IndentCaseLabels: false
IndentPPDirectives: None
NamespaceIndentation: None

# Line length
ColumnLimit: 100

# Braces
BreakBeforeBraces: Attach
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
BeforeElse: false
BeforeWhile: false

# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true

# Pointer and reference alignment
DerivePointerAlignment: false
PointerAlignment: Left

# Includes
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<cuda.*>'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: '^<.*>'
Priority: 3
- Regex: '".*"'
Priority: 4
SortIncludes: true

# Spaces
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false

# Line breaks
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: true

# Others
Cpp11BracedListStyle: true
FixNamespaceComments: true
MaxEmptyLinesToKeep: 1
ReflowComments: true
SortUsingDeclarations: true
53 changes: 53 additions & 0 deletions 08_bilateral_filter/Andy1314Chen/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
CXX = g++
NVCC = nvcc
CUDA_PATH ?= /usr/local/cuda
CXXFLAGS = -std=c++17 -O3 -Wall -Wextra -I./include -I$(CUDA_PATH)/include
NVCCFLAGS = -O3 -gencode arch=compute_110,code=sm_110 -I./include

OPENCV_CFLAGS = $(shell pkg-config --cflags opencv4)
OPENCV_LIBS = $(shell pkg-config --libs opencv4)
CUDA_LIBS = -L$(CUDA_PATH)/lib64 -lcudart

# Detect OpenCV CUDA module (cudaimgproc)
HAVE_OPENCV_CUDA := $(shell pkg-config --libs opencv4 2>/dev/null | grep -q cudaimgproc && echo 1)
ifeq ($(HAVE_OPENCV_CUDA),1)
CXXFLAGS += -DHAVE_OPENCV_CUDA
$(info OpenCV CUDA modules detected: enabling cv::cuda::bilateralFilter baseline)
else
$(info OpenCV CUDA modules not found: cv::cuda baseline disabled)
endif

SRC_DIR = src
BUILD_DIR = build
BIN_DIR = .

SRCS_CPP = $(SRC_DIR)/main.cpp \
$(SRC_DIR)/image_io.cpp \
$(SRC_DIR)/bilateral_filter_cpu.cpp \
$(SRC_DIR)/bilateral_filter_opencv.cpp

SRCS_CUDA = $(SRC_DIR)/bilateral_filter_cuda.cu

OBJS_CPP = $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCS_CPP))
OBJS_CUDA = $(patsubst $(SRC_DIR)/%.cu,$(BUILD_DIR)/%.o,$(SRCS_CUDA))

TARGET = $(BIN_DIR)/bilateral_filter

.PHONY: all clean

all: $(TARGET)

$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(BUILD_DIR)
$(CXX) $(CXXFLAGS) $(OPENCV_CFLAGS) -c -o $@ $<

$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cu
@mkdir -p $(BUILD_DIR)
$(NVCC) $(NVCCFLAGS) -c -o $@ $<

$(TARGET): $(OBJS_CPP) $(OBJS_CUDA)
@mkdir -p $(BUILD_DIR)
$(NVCC) -o $@ $^ $(OPENCV_LIBS) $(CUDA_LIBS)

clean:
rm -rf $(BUILD_DIR) $(TARGET)
Loading