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

Integrate logging feature #147

Merged
merged 18 commits into from
Nov 6, 2023
Merged
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
36 changes: 12 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ cmake_minimum_required(VERSION 3.6)
#
# Options
#
option(ION_BUILD_ALL_BB "Enable to build all building blocks" ON)
set(ION_BBS_TO_BUILD "ion-bb-core;ion-bb-dnn;ion-bb-image-io;ion-bb-image-processing;ion-bb-opencv;ion-bb-sgm" CACHE STRING "A List of building blocks to build (This overrides ION_BUILD_ALL_BB)")
if (UNIX)
set(DEFAULT_TARGET_BB "base;dnn;image-io;image-processing;opencv;sgm")
else()
set(DEFAULT_TARGET_BB "base;image-io;image-processing;opencv;sgm")
endif()
set(ION_TARGET_BB ${DEFAULT_TARGET_BB} CACHE STRING "A List of building blocks to build (This overrides ION_BUILD_ALL_BB)")
option(ION_BUILD_DOC "Build documents." OFF)
option(ION_BUILD_TEST "Enable to build tests" ON)
option(ION_BUILD_EXAMPLE "Enable to build examples" ON)
Expand All @@ -19,7 +23,7 @@ option(WITH_CUDA "Enable CUDA with buliding examples." ON)
# CMake common settings
#
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # This is required to export symbols on windows platform
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
Expand Down Expand Up @@ -54,9 +58,9 @@ endif()
#
# Build main library
#
file(GLOB ION_SRC src/*)
add_library(ion-core SHARED ${ION_SRC})
target_include_directories(ion-core PUBLIC ${PROJECT_SOURCE_DIR}/include)
file(GLOB ION_CORE_SRC LIST_DIRECTORIES false ${PROJECT_SOURCE_DIR}/src/*)
add_library(ion-core SHARED ${ION_CORE_SRC})
target_include_directories(ion-core PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src)
if (UNIX)
target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime dl pthread z)
else()
Expand All @@ -66,13 +70,7 @@ endif()
#
# ion-bb
#
include(ImportIonBB)
ion_import_building_block()

#
# Link directories
#
link_directories(${ION_BB_LINK_DIRS})
add_subdirectory(src/bb)

#
# Test
Expand Down Expand Up @@ -123,8 +121,6 @@ endif()
#
# Install
#
install(FILES cmake/ion-bb-config.cmake DESTINATION share/cmake/)

if (UNIX)
install(TARGETS ion-core DESTINATION lib)
else()
Expand Down Expand Up @@ -196,12 +192,4 @@ message(STATUS "Version: ${GIT_DESCRIBE_RESULT}")
string(STRIP "${GIT_DESCRIBE_RESULT}" ION_KIT_VERSION_S)
string(REPLACE "v" "" ION_KIT_VERSION ${ION_KIT_VERSION_S})
set(CPACK_PACKAGE_VERSION ${ION_KIT_VERSION})
include(CPack)

#
# Allow big object
#
if (MSVC)
add_definitions(/bigobj)
message(STATUS "Allow big object")
endif (MSVC)
include(CPack)
Empty file removed bin/x
Empty file.
84 changes: 0 additions & 84 deletions cmake/ImportIonBB.cmake

This file was deleted.

29 changes: 20 additions & 9 deletions cmake/IonUtil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ function(ion_compile NAME)
PUBLIC -fno-rtti # For Halide::Generator
PUBLIC -rdynamic) # For JIT compiling
endif()
target_include_directories(${NAME} PUBLIC "${PROJECT_SOURCE_DIR}/include;${ION_BB_INCLUDE_DIRS}")
target_link_libraries(${NAME} PRIVATE ion-core ${ION_BB_LIBRARIES} ${PLATFORM_LIBRARIES})
target_include_directories(${NAME} PUBLIC "${PROJECT_SOURCE_DIR}/include")
target_link_libraries(${NAME} PRIVATE ion-core ${PLATFORM_LIBRARIES})
set_target_properties(${NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY compile PIPELINE_NAME ${IEC_PIPELINE_NAME})
add_dependencies(${NAME} ion-bb)
endfunction()

function(ion_run NAME COMPILE_NAME)
Expand All @@ -50,24 +51,27 @@ function(ion_run NAME COMPILE_NAME)
add_custom_command(OUTPUT ${HEADER} ${STATIC_LIB}
COMMAND ${CMAKE_SOURCE_DIR}/script/invoke.sh $<TARGET_FILE:${COMPILE_NAME}>
HL_TARGET ${IER_TARGET_STRING}
LD_LIBRARY_PATH ${HALIDE_ROOT}/bin
LD_LIBRARY_PATH ${CMAKE_BINARY_DIR}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>
LD_LIBRARY_PATH ${Halide_DIR}/../../../bin
LD_LIBRARY_PATH ${CMAKE_BINARY_DIR}
LD_LIBRARY_PATH ${CMAKE_BINARY_DIR}/src/bb
DEPENDS ${COMPILE_NAME} ${OUTPUT_PATH}
WORKING_DIRECTORY ${OUTPUT_PATH})
else()
add_custom_command(OUTPUT ${HEADER} ${STATIC_LIB}
COMMAND ${CMAKE_SOURCE_DIR}/script/invoke.bat $<TARGET_FILE:${COMPILE_NAME}>
HL_TARGET ${IER_TARGET_STRING}
PATH ${HALIDE_ROOT}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>
PATH ${Halide_DIR}/../../../bin/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>
PATH ${CMAKE_BINARY_DIR}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>
PATH ${CMAKE_BINARY_DIR}/src/bb/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>
DEPENDS ${COMPILE_NAME} ${OUTPUT_PATH}
WORKING_DIRECTORY ${OUTPUT_PATH})
endif()

# Build run
find_package(OpenCV 4 REQUIRED)
add_executable(${NAME} ${IER_SRCS} ${HEADER})
target_include_directories(${NAME} PUBLIC "${PROJECT_SOURCE_DIR}/include;${ION_BB_INCLUDE_DIRS};${OUTPUT_PATH}")
target_link_libraries(${NAME} PRIVATE ${STATIC_LIB} Halide::Halide Halide::Runtime ${ION_BB_LIBRARIES} ${PLATFORM_LIBRARIES})
target_include_directories(${NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include ${OpenCV_INCLUDE_DIRS} ${OUTPUT_PATH})
target_link_libraries(${NAME} PRIVATE ${STATIC_LIB} ion-bb Halide::Halide Halide::Runtime ${OpenCV_LIBS} ${PLATFORM_LIBRARIES})

add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}> ${IER_RUNTIME_ARGS})
endfunction()
Expand All @@ -93,8 +97,9 @@ function(ion_jit NAME)
# For JIT compiling
target_compile_options(${NAME} PUBLIC -rdynamic)
endif()
target_include_directories(${NAME} PUBLIC "${PROJECT_SOURCE_DIR}/include;${ION_BB_INCLUDE_DIRS}")
target_link_libraries(${NAME} PRIVATE ion-core ${ION_BB_LIBRARIES} ${PLATFORM_LIBRARIES})
find_package(OpenCV 4 REQUIRED)
target_include_directories(${NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include ${ION_BB_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
target_link_libraries(${NAME} PRIVATE ion-core ${ION_BB_LIBRARIES} ${PLATFORM_LIBRARIES} ${OpenCV_LIBS})
set_target_properties(${NAME} PROPERTIES ENABLE_EXPORTS ON)
endfunction()

Expand All @@ -104,6 +109,12 @@ function(ion_register_test TEST_NAME EXEC_NAME)
set(multiValueArgs RUNTIME_ARGS)
cmake_parse_arguments(IERT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if (UNIX)
set(IERT_RUNTIME_ENVS "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src/bb:${CMAKE_BINARY_DIR}/test")
else()
set(IERT_RUNTIME_ENVS "PATH=${CMAKE_BINARY_DIR}/src/bb/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>\\\;${CMAKE_BINARY_DIR}/test/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>")
endif()

if (IERT_TARGET_STRING)
list(APPEND IERT_RUNTIME_ENVS "HL_TARGET=${IERT_TARGET_STRING}")
endif()
Expand Down
16 changes: 0 additions & 16 deletions cmake/ion-bb-config.cmake

This file was deleted.

21 changes: 14 additions & 7 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ ion_compile(dnn_compile SRCS dnn_compile.cc PIPELINE_NAME dnn)
ion_compile(demo_compile SRCS demo_compile.cc PIPELINE_NAME demo)

ion_run(producerx3 producerx3_compile SRCS producerx3_run.cc TARGET_STRING "host-profile")
ion_run(sgm sgm_compile SRCS sgm_run.cc TARGET_STRING "host-profile")
ion_run(dnn dnn_compile SRCS dnn_run.cc TARGET_STRING "host-profile")
ion_run(demo demo_compile SRCS demo_run.cc TARGET_STRING "host-profile")

if (UNIX)
ion_run(sgm sgm_compile SRCS sgm_run.cc TARGET_STRING "host-profile")
ion_run(dnn dnn_compile SRCS dnn_run.cc TARGET_STRING "host-profile")
ion_run(demo demo_compile SRCS demo_run.cc TARGET_STRING "host-profile")
endif()

if(WITH_CUDA)
ion_run(producerx3_gpu producerx3_compile SRCS producerx3_run.cc TARGET_STRING "host-cuda-cuda_capability_50-profile")
ion_run(sgm_gpu sgm_compile SRCS sgm_run.cc TARGET_STRING "host-cuda-cuda_capability_50-profile")
ion_run(dnn_gpu dnn_compile SRCS dnn_run.cc TARGET_STRING "host-cuda-cuda_capability_50-profile")
ion_run(demo_gpu demo_compile SRCS demo_run.cc TARGET_STRING "host-cuda-cuda_capability_50-profile")
if(UNIX)
ion_run(sgm_gpu sgm_compile SRCS sgm_run.cc TARGET_STRING "host-cuda-cuda_capability_50-profile")
ion_run(dnn_gpu dnn_compile SRCS dnn_run.cc TARGET_STRING "host-cuda-cuda_capability_50-profile")
ion_run(demo_gpu demo_compile SRCS demo_run.cc TARGET_STRING "host-cuda-cuda_capability_50-profile")
endif()
endif()

if(ION_ENABLE_HALIDE_FPGA_BACKEND)
Expand Down Expand Up @@ -53,4 +59,5 @@ endif()
if (MSVC)
add_definitions(/bigobj)
message(STATUS "Allow big object for example/")
endif (MSVC)
endif (MSVC)

25 changes: 9 additions & 16 deletions example/demo.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
#include <ion/ion.h>

#include "ion-bb-core/bb.h"
#include "ion-bb-dnn/bb.h"
#include "ion-bb-image-io/bb.h"
#include "ion-bb-image-processing/bb.h"
#include "ion-bb-sgm/bb.h"

#include "ion-bb-core/rt.h"
#include "ion-bb-dnn/rt.h"
#include "ion-bb-image-io/rt.h"
#include "ion-bb-image-processing/rt.h"
#include "ion-bb-sgm/rt.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace ion;

Expand All @@ -27,6 +19,7 @@ int main(int argc, char *argv[]) {

Builder b;
b.set_target(Halide::get_target_from_environment());
b.with_bb_module("ion-bb");

// ISP
Port offset_r{"offset_r", Halide::type_of<float>()};
Expand Down Expand Up @@ -128,13 +121,13 @@ int main(int argc, char *argv[]) {
gamma_correction["output"]);
Node reorder_channel = b.add("image_processing_reorder_color_channel_3d_float")(
fit_image["output"]);
Node reorder_chw2hwc = b.add("core_reorder_buffer_3d_float")
Node reorder_chw2hwc = b.add("base_reorder_buffer_3d_float")
.set_param(
Param{"dim0", "2"},
Param{"dim1", "0"},
Param{"dim2", "1"})(
reorder_channel["output"]);
Node extended = b.add("core_extend_dimension_3d_float")
Node extended = b.add("base_extend_dimension_3d_float")
.set_param(
Param{"new_dim", "3"})(
reorder_chw2hwc["output"]);
Expand All @@ -144,7 +137,7 @@ int main(int argc, char *argv[]) {

Port packed_dnn_input = dnn_inputs[0];
for (int i = 1; i < 6; i++) {
packed_dnn_input = b.add("core_concat_buffer_4d_float")
packed_dnn_input = b.add("base_concat_buffer_4d_float")
.set_param(
Param{"dim", "3"},
Param{"input0_extent", std::to_string(i)})(
Expand All @@ -156,7 +149,7 @@ int main(int argc, char *argv[]) {

Port dnn_outputs[6];
for (int i = 0; i < 6; i++) {
dnn_outputs[i] = b.add("core_extract_buffer_4d_float")
dnn_outputs[i] = b.add("base_extract_buffer_4d_float")
.set_param(
Param{"dim", "3"},
Param{"index", std::to_string(i)})(
Expand Down Expand Up @@ -191,7 +184,7 @@ int main(int argc, char *argv[]) {
horizontal_tiled_image[0],
horizontal_tiled_image[1])["output"];

Node denormalized = b.add("core_denormalize_3d_uint8")(tiled_image);
Node denormalized = b.add("base_denormalize_3d_uint8")(tiled_image);

// d435
auto d435 = b.add("image_io_d435");
Expand Down
Loading
Loading