Skip to content

Commit

Permalink
Add hexagon_benchmarks app for CMake builds (halide#8069)
Browse files Browse the repository at this point in the history
* Add hexagon_benchmarks app for CMake builds

* Removed unnecessary -lc++abi flag from GCC build
  • Loading branch information
prasmish authored and ardier committed Mar 3, 2024
1 parent ab172b2 commit e63aeff
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ add_app(depthwise_separable_conv)
add_app(fft)
add_app(hannk)
add_app(harris)
# add_app(hexagon_benchmarks) # TODO(#5374): missing CMake build
add_app(hexagon_benchmarks)
# add_app(hexagon_dma) # TODO(#5374): missing CMake build
add_app(hist)
add_app(iir_blur)
Expand Down
44 changes: 44 additions & 0 deletions apps/hexagon_benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 3.22)
project(hexagon_benchmarks)

enable_testing()

# Set up language settings
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# Find Halide
find_package(Halide REQUIRED)

macro(add_generator_and_library FILTER_NAME)
set(GENERATOR_EXE ${FILTER_NAME}.generator)
set(GENERATOR_SRC ${FILTER_NAME}_generator.cpp)
add_halide_generator(${GENERATOR_EXE} SOURCES ${GENERATOR_SRC})
add_halide_library(${FILTER_NAME} FROM ${GENERATOR_EXE})
endmacro()

add_generator_and_library(dilate3x3)
add_generator_and_library(gaussian5x5)
add_generator_and_library(median3x3)

# Main executable
add_executable(process process.cpp)
target_compile_options(process PRIVATE $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-O2>)
if (Halide_TARGET MATCHES "hvx")
target_compile_definitions(process PRIVATE DILATE3X3 GAUSSIAN5X5 MEDIAN3X3 TARGET_HAS_HVX)
else()
target_compile_definitions(process PRIVATE DILATE3X3 GAUSSIAN5X5 MEDIAN3X3)
endif()
target_link_libraries(process
PRIVATE
Halide::Tools
dilate3x3 gaussian5x5 median3x3)

# Test that the app actually works!
add_test(NAME hexagon_benchmarks COMMAND process -n 1)
set_tests_properties(hexagon_benchmarks PROPERTIES
LABELS hexagon_benchmarks
PASS_REGULAR_EXPRESSION "Success!"
SKIP_REGULAR_EXPRESSION "\\[SKIP\\]")
7 changes: 5 additions & 2 deletions apps/hexagon_benchmarks/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <stdio.h>
#include <stdlib.h>

#ifdef TARGET_HAS_HVX
#include "HalideRuntimeHexagonHost.h"
#endif

#include "halide_benchmark.h"
#include "process.h"

Expand Down Expand Up @@ -39,11 +43,10 @@ int main(int argc, char **argv) {
Dilate3x3Descriptor dilate3x3_pipeine(W, H);
Median3x3Descriptor median3x3_pipeline(W, H);
Gaussian5x5Descriptor gaussian5x5_pipeline(W, H);
SobelDescriptor sobel_pipeline(W, H);
Conv3x3a32Descriptor conv3x3a32_pipeline(W, H);

std::vector<PipelineDescriptorBase *> pipelines = {&conv3x3a16_pipeline, &dilate3x3_pipeine, &median3x3_pipeline,
&gaussian5x5_pipeline, &sobel_pipeline, &conv3x3a32_pipeline};
&gaussian5x5_pipeline, &conv3x3a32_pipeline};

for (PipelineDescriptorBase *p : pipelines) {
if (!p->defined()) {
Expand Down

0 comments on commit e63aeff

Please sign in to comment.