Skip to content

Hex bench experiment #3

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Running hexagon benchmark using CMakeLists.txt
Currently, the test is giving verification error.

Commands to reproduce the error:
$cmake --preset release -DHalide_TARGET=host-hvx-hvx_v65 -DCMAKE_PREFIX_PATH=<path_to_the_installed_community_halide> .
$cmake --build --preset release
$ctest --preset release -R hexagon_bench
  • Loading branch information
prasmish committed Oct 4, 2023
commit a9b36577192f25e56b845f31cf554a48c05d705f
38 changes: 2 additions & 36 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,7 @@ if (Halide_TARGET MATCHES "wasm")
return()
endif()

# add_app(HelloAndroid) # TODO(#5374): missing CMake build
# add_app(HelloAndroidCamera2) # TODO(#5374): missing CMake build
# add_app(HelloPyTorch) # TODO(#5374): missing CMake build
# add_app(HelloiOS) # TODO(#5374): missing CMake build
# add_app(auto_viz) # TODO(#5374): missing CMake build
add_app(bgu)
add_app(bilateral_grid)
add_app(blur)
add_app(c_backend)
add_app(camera_pipe)
add_app(compositing)
add_app(conv_layer)
add_app(cuda_mat_mul)
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_dma) # TODO(#5374): missing CMake build
add_app(hist)
add_app(iir_blur)
add_app(interpolate)
add_app(lens_blur)
add_app(linear_algebra)
# add_app(linear_blur) # TODO(#5374): missing CMake build
add_app(local_laplacian)
add_app(max_filter)
add_app(nl_means)
# add_app(nn_ops) # TODO(#5374): missing CMake build
# add_app(onnx) # TODO(#5374): missing CMake build
# add_app(openglcompute) # TODO(#5374): missing CMake build
add_app(resize)
# add_app(resnet_50) # TODO(#5374): missing CMake build
# add_app(simd_op_check) # TODO(#5374): missing CMake build
add_app(stencil_chain)
add_app(unsharp)
add_app(wavelet)
add_app(HelloBaremetal)
add_app(hexagon_benchmarks) # TODO(#5374): missing CMake build
# add_app(hexagon_dma) # TODO(#5374): missing CMake build
45 changes: 45 additions & 0 deletions apps/hexagon_benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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)
add_generator_and_library(sobel)

# 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 SOBEL TARGET_HAS_HVX)
else()
target_compile_definitions(process PRIVATE DILATE3X3 GAUSSIAN5X5 MEDIAN3X3 SOBEL)
endif()
target_link_libraries(process
PRIVATE
Halide::Tools
dilate3x3 gaussian5x5 median3x3 sobel)

# 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\\]")
12 changes: 6 additions & 6 deletions apps/hexagon_benchmarks/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Conv3x3a16Descriptor : public PipelineDescriptorBase {
sum = clamp<int16_t>(sum, 0, 255);
uint8_t out_xy = u8_out(x, y);
if (sum != out_xy) {
printf("Conv3x3a16: Mismatch at %d %d : %d != %d\n", x, y, out_xy, sum);
fprintf(stderr,"Conv3x3a16: Mismatch at %d %d : %d != %d\n", x, y, out_xy, sum);
abort();
}
});
Expand Down Expand Up @@ -187,7 +187,7 @@ class Dilate3x3Descriptor : public PipelineDescriptorBase {

uint8_t out_xy = u8_out(x, y);
if (max_val != out_xy) {
printf("Dilate3x3: Mismatch at %d %d : %d != %d\n", x, y, out_xy, max_val);
fprintf(stderr,"Dilate3x3: Mismatch at %d %d : %d != %d\n", x, y, out_xy, max_val);
abort();
}
});
Expand Down Expand Up @@ -256,7 +256,7 @@ class Median3x3Descriptor : public PipelineDescriptorBase {
uint8_t median_val = inp9[4];
uint8_t out_xy = u8_out(x, y);
if (median_val != out_xy) {
printf("Median3x3: Mismatch at %d %d : %d != %d\n", x, y, out_xy, median_val);
fprintf(stderr,"Median3x3: Mismatch at %d %d : %d != %d\n", x, y, out_xy, median_val);
abort();
}
});
Expand Down Expand Up @@ -327,7 +327,7 @@ class Gaussian5x5Descriptor : public PipelineDescriptorBase {
uint8_t blur_val = blur >> 8;
uint8_t out_xy = u8_out(x, y);
if (blur_val != out_xy) {
printf("Gaussian5x5: Mismatch at %d %d : %d != %d\n", x, y, out_xy, blur_val);
fprintf(stderr,"Gaussian5x5: Mismatch at %d %d : %d != %d\n", x, y, out_xy, blur_val);
abort();
}
});
Expand Down Expand Up @@ -403,7 +403,7 @@ class SobelDescriptor : public PipelineDescriptorBase {

uint8_t out_xy = u8_out(x, y);
if (sobel_val != out_xy) {
printf("Sobel: Mismatch at %d %d : %d != %d\n", x, y, out_xy, sobel_val);
fprintf(stderr,"Sobel: Mismatch at %d %d : %d != %d\n", x, y, out_xy, sobel_val);
abort();
}
});
Expand Down Expand Up @@ -487,7 +487,7 @@ class Conv3x3a32Descriptor : public PipelineDescriptorBase {
sum = clamp(sum, 0, 255);
uint8_t out_xy = u8_out(x, y);
if (sum != out_xy) {
printf("Conv3x3a32: Mismatch at %d %d : %d != %d\n", x, y, out_xy, sum);
fprintf(stderr,"Conv3x3a32: Mismatch at %d %d : %d != %d\n", x, y, out_xy, sum);
abort();
}
});
Expand Down