From ef49c51ef2c0e7967c37d505dc7755156de55327 Mon Sep 17 00:00:00 2001 From: Takuro Iizuka Date: Thu, 26 Oct 2023 18:02:00 -0700 Subject: [PATCH 01/17] WIP --- CMakeLists.txt | 19 +- cmake/ImportIonBB.cmake | 84 ---- cmake/IonUtil.cmake | 9 +- cmake/ion-bb-config.cmake | 16 - example/CMakeLists.txt | 2 +- example/demo.cc | 15 +- example/demo_compile.cc | 7 +- example/demo_run.cc | 6 - example/dnn.cc | 11 +- example/dnn_compile.cc | 5 +- example/dnn_run.cc | 4 - example/gender_count.cc | 9 +- example/imx219_isp_display.cc | 9 +- example/io.cc | 7 +- example/isp.cc | 9 +- example/isp_and_sgm.cc | 11 +- example/producerx3_compile.cc | 3 +- example/realsense.cc | 4 +- example/sgm_compile.cc | 7 +- example/sgm_run.cc | 6 - example/u3v.cc | 25 +- example/v4l2.cc | 3 +- include/ion-bb-core/Dockerfile | 19 - include/ion-bb-internal/Dockerfile | 15 - include/ion-bb-internal/README.md | 2 - include/ion-bb-internal/bb.h | 118 ----- include/ion-bb-internal/config.cmake | 4 - include/ion-bb-internal/rt.h | 4 - include/ion-bb-sgm/config.cmake | 0 src/bb/CMakeLists.txt | 52 +++ .../ion-bb-core => src/bb/base}/README.en.md | 0 .../ion-bb-core => src/bb/base}/README.ja.md | 0 {include/ion-bb-core => src/bb/base}/bb.h | 426 +++++++++--------- .../ion-bb-core => src/bb/base}/httplib.h | 0 {include/ion-bb-core => src/bb/base}/rt.h | 50 +- .../bb/base}/thirdparty_notice.txt | 0 src/bb/bb.cc | 66 +++ {include/ion-bb-dnn => src/bb/dnn}/Dockerfile | 0 {include/ion-bb-dnn => src/bb/dnn}/LICENSE | 0 {include/ion-bb-dnn => src/bb/dnn}/Makefile | 0 .../bb/dnn}/NvInferRuntime.h | 0 .../bb/dnn}/NvInferRuntimeCommon.h | 0 .../bb/dnn}/NvInferVersion.h | 0 .../ion-bb-dnn => src/bb/dnn}/README.en.md | 0 .../ion-bb-dnn => src/bb/dnn}/README.ja.md | 0 {include/ion-bb-dnn => src/bb/dnn}/README.md | 0 {include/ion-bb-dnn => src/bb/dnn}/bb.h | 0 .../ion-bb-dnn => src/bb/dnn}/config.cmake | 0 .../ion-bb-dnn => src/bb/dnn}/edgetpu_c.h | 0 {include/ion-bb-dnn => src/bb/dnn}/httplib.h | 0 {include/ion-bb-dnn => src/bb/dnn}/json.hpp | 0 {include/ion-bb-dnn => src/bb/dnn}/n2cube.h | 0 .../ion-bb-dnn => src/bb/dnn}/onnxruntime_c.h | 0 {include/ion-bb-dnn => src/bb/dnn}/picosha2.h | 0 {include/ion-bb-dnn => src/bb/dnn}/rt.h | 4 - {include/ion-bb-dnn => src/bb/dnn}/rt_dnndk.h | 0 {include/ion-bb-dnn => src/bb/dnn}/rt_json.h | 0 .../ion-bb-dnn => src/bb/dnn}/rt_opencv.h | 0 {include/ion-bb-dnn => src/bb/dnn}/rt_ort.h | 0 {include/ion-bb-dnn => src/bb/dnn}/rt_ssd.h | 0 {include/ion-bb-dnn => src/bb/dnn}/rt_tfl.h | 0 {include/ion-bb-dnn => src/bb/dnn}/rt_trt.h | 0 {include/ion-bb-dnn => src/bb/dnn}/rt_util.h | 0 {include/ion-bb-dnn => src/bb/dnn}/rt_yolo.h | 0 {include/ion-bb-dnn => src/bb/dnn}/sole.hpp | 0 .../bb/dnn}/tensorflowlite_c.h | 0 .../bb/dnn}/tensorflowlite_types.h | 0 .../bb/dnn}/thirdparty_notice.txt | 0 .../ion-bb-fpga => src/bb/fpga}/Dockerfile | 0 .../ion-bb-fpga => src/bb/fpga}/README.en.md | 0 .../ion-bb-fpga => src/bb/fpga}/README.ja.md | 0 {include/ion-bb-fpga => src/bb/fpga}/bb.h | 0 .../ion-bb-fpga => src/bb/fpga}/config.cmake | 0 {include/ion-bb-fpga => src/bb/fpga}/rt.h | 0 .../bb/image-io}/Dockerfile | 0 .../bb/image-io}/README.en.md | 0 .../bb/image-io}/README.ja.md | 0 .../ion-bb-image-io => src/bb/image-io}/bb.h | 0 .../bb/image-io}/config.cmake | 0 .../gendc_separator/ComponentHeader.h | 0 .../gendc_separator/ContainerHeader.h | 0 .../bb/image-io}/gendc_separator/Descriptor.h | 0 .../bb/image-io}/gendc_separator/PartHeader.h | 0 .../bb/image-io}/gendc_separator/tools.h | 0 .../bb/image-io}/ghc/filesystem.hpp | 0 .../bb/image-io}/ghc/fs_fwd.hpp | 0 .../bb/image-io}/ghc/fs_impl.hpp | 0 .../bb/image-io}/ghc/fs_std.hpp | 0 .../bb/image-io}/ghc/fs_std_fwd.hpp | 0 .../bb/image-io}/ghc/fs_std_impl.hpp | 0 .../bb/image-io}/httplib.h | 0 .../bb/image-io}/nlohmann/json.hpp | 0 .../bb/image-io}/nlohmann/json_fwd.hpp | 0 .../ion-bb-image-io => src/bb/image-io}/rt.h | 4 - .../bb/image-io}/rt_common.h | 0 .../bb/image-io}/rt_display.h | 0 .../bb/image-io}/rt_file.h | 0 .../bb/image-io}/rt_realsense.h | 0 .../bb/image-io}/rt_u3v.h | 0 .../bb/image-io}/rt_v4l2.h | 0 .../bb/image-io}/sole.hpp | 0 .../bb/image-io}/thirdparty_notice.txt | 0 .../bb/image-io}/zip_file.hpp | 0 .../bb/image-processing}/Dockerfile | 0 .../bb/image-processing}/README.en.md | 0 .../bb/image-processing}/README.ja.md | 0 .../bb/image-processing}/bb.h | 0 .../bb/image-processing}/config.cmake | 0 .../bb/image-processing}/rt.h | 0 {include/ion-bb-opencv => src/bb/opencv}/bb.h | 0 .../bb/opencv}/config.cmake | 0 {include/ion-bb-opencv => src/bb/opencv}/rt.h | 4 - {include/ion-bb-sgm => src/bb/sgm}/Dockerfile | 0 .../ion-bb-sgm => src/bb/sgm}/README.en.md | 0 .../ion-bb-sgm => src/bb/sgm}/README.ja.md | 0 {include/ion-bb-sgm => src/bb/sgm}/bb.h | 0 .../bb/sgm}/config.cmake | 0 {include/ion-bb-sgm => src/bb/sgm}/rt.h | 0 src/{ => core}/builder.cc | 0 src/{ => core}/c_ion.cc | 0 src/{ => core}/dynamic_module.h | 6 +- src/{ => core}/generator.cc | 0 src/{ => core}/metadata.cc | 0 src/{ => core}/metadata.h | 0 src/{ => core}/node.cc | 0 src/{ => core}/param.cc | 0 src/{ => core}/port.cc | 0 src/{ => core}/sole.hpp | 0 src/{ => core}/util.cc | 0 test/direct-extern.cc | 7 +- test/metadata.cc | 13 - 131 files changed, 404 insertions(+), 661 deletions(-) delete mode 100644 cmake/ImportIonBB.cmake delete mode 100644 cmake/ion-bb-config.cmake delete mode 100644 include/ion-bb-core/Dockerfile delete mode 100644 include/ion-bb-internal/Dockerfile delete mode 100644 include/ion-bb-internal/README.md delete mode 100644 include/ion-bb-internal/bb.h delete mode 100644 include/ion-bb-internal/config.cmake delete mode 100644 include/ion-bb-internal/rt.h delete mode 100644 include/ion-bb-sgm/config.cmake create mode 100644 src/bb/CMakeLists.txt rename {include/ion-bb-core => src/bb/base}/README.en.md (100%) rename {include/ion-bb-core => src/bb/base}/README.ja.md (100%) rename {include/ion-bb-core => src/bb/base}/bb.h (78%) rename {include/ion-bb-core => src/bb/base}/httplib.h (100%) rename {include/ion-bb-core => src/bb/base}/rt.h (83%) rename {include/ion-bb-core => src/bb/base}/thirdparty_notice.txt (100%) create mode 100644 src/bb/bb.cc rename {include/ion-bb-dnn => src/bb/dnn}/Dockerfile (100%) rename {include/ion-bb-dnn => src/bb/dnn}/LICENSE (100%) rename {include/ion-bb-dnn => src/bb/dnn}/Makefile (100%) rename {include/ion-bb-dnn => src/bb/dnn}/NvInferRuntime.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/NvInferRuntimeCommon.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/NvInferVersion.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/README.en.md (100%) rename {include/ion-bb-dnn => src/bb/dnn}/README.ja.md (100%) rename {include/ion-bb-dnn => src/bb/dnn}/README.md (100%) rename {include/ion-bb-dnn => src/bb/dnn}/bb.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/config.cmake (100%) rename {include/ion-bb-dnn => src/bb/dnn}/edgetpu_c.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/httplib.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/json.hpp (100%) rename {include/ion-bb-dnn => src/bb/dnn}/n2cube.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/onnxruntime_c.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/picosha2.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/rt.h (99%) rename {include/ion-bb-dnn => src/bb/dnn}/rt_dnndk.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/rt_json.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/rt_opencv.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/rt_ort.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/rt_ssd.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/rt_tfl.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/rt_trt.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/rt_util.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/rt_yolo.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/sole.hpp (100%) rename {include/ion-bb-dnn => src/bb/dnn}/tensorflowlite_c.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/tensorflowlite_types.h (100%) rename {include/ion-bb-dnn => src/bb/dnn}/thirdparty_notice.txt (100%) rename {include/ion-bb-fpga => src/bb/fpga}/Dockerfile (100%) rename {include/ion-bb-fpga => src/bb/fpga}/README.en.md (100%) rename {include/ion-bb-fpga => src/bb/fpga}/README.ja.md (100%) rename {include/ion-bb-fpga => src/bb/fpga}/bb.h (100%) rename {include/ion-bb-fpga => src/bb/fpga}/config.cmake (100%) rename {include/ion-bb-fpga => src/bb/fpga}/rt.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/Dockerfile (100%) rename {include/ion-bb-image-io => src/bb/image-io}/README.en.md (100%) rename {include/ion-bb-image-io => src/bb/image-io}/README.ja.md (100%) rename {include/ion-bb-image-io => src/bb/image-io}/bb.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/config.cmake (100%) rename {include/ion-bb-image-io => src/bb/image-io}/gendc_separator/ComponentHeader.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/gendc_separator/ContainerHeader.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/gendc_separator/Descriptor.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/gendc_separator/PartHeader.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/gendc_separator/tools.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/ghc/filesystem.hpp (100%) rename {include/ion-bb-image-io => src/bb/image-io}/ghc/fs_fwd.hpp (100%) rename {include/ion-bb-image-io => src/bb/image-io}/ghc/fs_impl.hpp (100%) rename {include/ion-bb-image-io => src/bb/image-io}/ghc/fs_std.hpp (100%) rename {include/ion-bb-image-io => src/bb/image-io}/ghc/fs_std_fwd.hpp (100%) rename {include/ion-bb-image-io => src/bb/image-io}/ghc/fs_std_impl.hpp (100%) rename {include/ion-bb-image-io => src/bb/image-io}/httplib.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/nlohmann/json.hpp (100%) rename {include/ion-bb-image-io => src/bb/image-io}/nlohmann/json_fwd.hpp (100%) rename {include/ion-bb-image-io => src/bb/image-io}/rt.h (90%) rename {include/ion-bb-image-io => src/bb/image-io}/rt_common.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/rt_display.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/rt_file.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/rt_realsense.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/rt_u3v.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/rt_v4l2.h (100%) rename {include/ion-bb-image-io => src/bb/image-io}/sole.hpp (100%) rename {include/ion-bb-image-io => src/bb/image-io}/thirdparty_notice.txt (100%) rename {include/ion-bb-image-io => src/bb/image-io}/zip_file.hpp (100%) rename {include/ion-bb-image-processing => src/bb/image-processing}/Dockerfile (100%) rename {include/ion-bb-image-processing => src/bb/image-processing}/README.en.md (100%) rename {include/ion-bb-image-processing => src/bb/image-processing}/README.ja.md (100%) rename {include/ion-bb-image-processing => src/bb/image-processing}/bb.h (100%) rename {include/ion-bb-core => src/bb/image-processing}/config.cmake (100%) rename {include/ion-bb-image-processing => src/bb/image-processing}/rt.h (100%) rename {include/ion-bb-opencv => src/bb/opencv}/bb.h (100%) rename {include/ion-bb-opencv => src/bb/opencv}/config.cmake (100%) rename {include/ion-bb-opencv => src/bb/opencv}/rt.h (96%) rename {include/ion-bb-sgm => src/bb/sgm}/Dockerfile (100%) rename {include/ion-bb-sgm => src/bb/sgm}/README.en.md (100%) rename {include/ion-bb-sgm => src/bb/sgm}/README.ja.md (100%) rename {include/ion-bb-sgm => src/bb/sgm}/bb.h (100%) rename {include/ion-bb-image-processing => src/bb/sgm}/config.cmake (100%) rename {include/ion-bb-sgm => src/bb/sgm}/rt.h (100%) rename src/{ => core}/builder.cc (100%) rename src/{ => core}/c_ion.cc (100%) rename src/{ => core}/dynamic_module.h (93%) rename src/{ => core}/generator.cc (100%) rename src/{ => core}/metadata.cc (100%) rename src/{ => core}/metadata.h (100%) rename src/{ => core}/node.cc (100%) rename src/{ => core}/param.cc (100%) rename src/{ => core}/port.cc (100%) rename src/{ => core}/sole.hpp (100%) rename src/{ => core}/util.cc (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b79a927..a538c5ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,7 @@ 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)") +set(ION_TARGET_BB "base;dnn;image-io;image-processing;opencv;sgm" 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) @@ -19,7 +18,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}) @@ -54,8 +53,8 @@ endif() # # Build main library # -file(GLOB ION_SRC src/*) -add_library(ion-core SHARED ${ION_SRC}) +file(GLOB ION_CORE_SRC ${PROJECT_SOURCE_DIR}/src/core/*) +add_library(ion-core SHARED ${ION_CORE_SRC}) target_include_directories(ion-core PUBLIC ${PROJECT_SOURCE_DIR}/include) if (UNIX) target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime dl pthread z) @@ -66,13 +65,7 @@ endif() # # ion-bb # -include(ImportIonBB) -ion_import_building_block() - -# -# Link directories -# -link_directories(${ION_BB_LINK_DIRS}) +add_subdirectory(src/bb) # # Test @@ -204,4 +197,4 @@ include(CPack) if (MSVC) add_definitions(/bigobj) message(STATUS "Allow big object") -endif (MSVC) \ No newline at end of file +endif (MSVC) diff --git a/cmake/ImportIonBB.cmake b/cmake/ImportIonBB.cmake deleted file mode 100644 index fca1f189..00000000 --- a/cmake/ImportIonBB.cmake +++ /dev/null @@ -1,84 +0,0 @@ -macro(ion_import_building_block) - cmake_policy(SET CMP0057 NEW) - - if(NOT ION_BBS_TO_BUILD STREQUAL "") - set(ION_BUILD_ALL_BB OFF) - endif() - - set(ION_BBS) - set(ION_BB_INCLUDE_DIRS) - set(ION_BB_LINK_DIRS) - set(ION_BB_LIBRARIES) - - file(REMOVE ${CMAKE_BINARY_DIR}/ion-bb.cc) - file(APPEND ${CMAKE_BINARY_DIR}/ion-bb.cc "#define ION_ENABLE_JIT_EXTERN\n") - - file(GLOB childs ${CMAKE_CURRENT_SOURCE_DIR}/include/ion-bb-*) - foreach(child ${childs}) - if(IS_DIRECTORY ${child}) - get_filename_component(BB_NAME ${child} NAME) - set(IS_TARGET_BB FALSE) - if(${BB_NAME} IN_LIST ION_BBS_TO_BUILD) - set(IS_TARGET_BB TRUE) - endif() - - if(${ION_BUILD_ALL_BB} OR ${IS_TARGET_BB}) - set(INCLUDE_DIRS) - set(LINK_DIRS) - set(LIBRARIES) - include(${child}/config.cmake) - list(APPEND ION_BBS ${BB_NAME}) - list(APPEND ION_BB_INCLUDE_DIRS ${INCLUDE_DIRS}) - list(APPEND ION_BB_LINK_DIRS ${LINK_DIRS}) - list(APPEND ION_BB_LIBRARIES ${LIBRARIES}) - - file(APPEND ${CMAKE_BINARY_DIR}/ion-bb.cc "#include \"${child}/bb.h\"\n") - file(APPEND ${CMAKE_BINARY_DIR}/ion-bb.cc "#include \"${child}/rt.h\"\n") - - install(DIRECTORY ${child} - DESTINATION ./include - PATTERN ".git" EXCLUDE) - endif() - endif() - endforeach() - - file(APPEND ${CMAKE_BINARY_DIR}/ion-bb.cc "extern \"C\" void register_externs(std::map& externs) {\n") - foreach(child ${childs}) - if(IS_DIRECTORY ${child}) - get_filename_component(BB_NAME ${child} NAME) - set(IS_TARGET_BB FALSE) - if(${BB_NAME} IN_LIST ION_BBS_TO_BUILD) - set(IS_TARGET_BB TRUE) - endif() - - if(${ION_BUILD_ALL_BB} OR ${IS_TARGET_BB}) - string(REPLACE "ion-bb-" "ion::bb::" ns ${BB_NAME}) - string(REPLACE "-" "_" ns ${ns}) - file(APPEND ${CMAKE_BINARY_DIR}/ion-bb.cc " for (auto kv : ${ns}::extern_functions) {\n") - file(APPEND ${CMAKE_BINARY_DIR}/ion-bb.cc " externs.insert({kv.first, Halide::JITExtern(kv.second)});\n") - file(APPEND ${CMAKE_BINARY_DIR}/ion-bb.cc " }\n") - endif() - endif() - endforeach() - file(APPEND ${CMAKE_BINARY_DIR}/ion-bb.cc "}\n") - - message(STATUS "Found BBs: ${ION_BBS}") - message(STATUS " Include directories: ${ION_BB_INCLUDE_DIRS}") - message(STATUS " Link directories: ${ION_BB_LINK_DIRS}") - message(STATUS " Dependent Libaries: ${ION_BB_LIBRARIES}") - - add_library(ion-bb SHARED ${CMAKE_BINARY_DIR}/ion-bb.cc) - target_include_directories(ion-bb PUBLIC ${PROJECT_SOURCE_DIR}/include ${ION_BB_INCLUDE_DIRS}) - target_link_libraries(ion-bb PUBLIC ion-core ${ION_BB_LIBRARIES}) - if(UNIX) - target_compile_options(ion-bb - PUBLIC -fno-rtti # For Halide::Generator - PUBLIC -rdynamic) # For JIT compiling - endif() - if (UNIX) - install(TARGETS ion-bb DESTINATION lib) - else() - install(FILES ${CMAKE_BINARY_DIR}/$<$:Release>$<$:Debug>/ion-bb.dll DESTINATION bin) - install(FILES ${CMAKE_BINARY_DIR}/$<$:Release>$<$:Debug>/ion-bb.lib DESTINATION lib) - endif() -endmacro() diff --git a/cmake/IonUtil.cmake b/cmake/IonUtil.cmake index 7cc26f0d..7e696f8c 100644 --- a/cmake/IonUtil.cmake +++ b/cmake/IonUtil.cmake @@ -22,8 +22,8 @@ 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}) endfunction() @@ -93,8 +93,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() diff --git a/cmake/ion-bb-config.cmake b/cmake/ion-bb-config.cmake deleted file mode 100644 index 80ec05f0..00000000 --- a/cmake/ion-bb-config.cmake +++ /dev/null @@ -1,16 +0,0 @@ -set(ION_BB_INCLUDE_DIRS) -set(ION_BB_LINK_DIRS) -set(ION_BB_LIBRARIES) - -file(GLOB childs ${CMAKE_CURRENT_LIST_DIR}/ion-bb-*) -foreach(child ${childs}) - if(IS_DIRECTORY ${child}) - set(INCLUDE_DIRS) - set(LINK_DIRS) - set(LIBRARIES) - include(${child}/config.cmake) - list(APPEND ION_BB_INCLUDE_DIRS ${INCLUDE_DIRS}) - list(APPEND ION_BB_LINK_DIRS ${LINK_DIRS}) - list(APPEND ION_BB_LIBRARIES ${LIBRARIES}) - endif() -endforeach() diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index fd27e05e..0ed85fd8 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -53,4 +53,4 @@ endif() if (MSVC) add_definitions(/bigobj) message(STATUS "Allow big object for example/") -endif (MSVC) \ No newline at end of file +endif (MSVC) diff --git a/example/demo.cc b/example/demo.cc index 62cf94ac..b884f1db 100644 --- a/example/demo.cc +++ b/example/demo.cc @@ -1,16 +1,8 @@ #include -#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 +#include +#include using namespace ion; @@ -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()}; diff --git a/example/demo_compile.cc b/example/demo_compile.cc index 93705668..c048cd7c 100644 --- a/example/demo_compile.cc +++ b/example/demo_compile.cc @@ -1,11 +1,5 @@ #include -#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" - using namespace ion; int main(int argc, char *argv[]) { @@ -21,6 +15,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()}; diff --git a/example/demo_run.cc b/example/demo_run.cc index 97f1c39d..c0014221 100644 --- a/example/demo_run.cc +++ b/example/demo_run.cc @@ -1,11 +1,5 @@ #include "demo.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 #include diff --git a/example/dnn.cc b/example/dnn.cc index b0c13d29..68f7a275 100644 --- a/example/dnn.cc +++ b/example/dnn.cc @@ -1,13 +1,9 @@ #include #include -#include "ion-bb-core/bb.h" -#include "ion-bb-dnn/bb.h" -#include "ion-bb-image-io/bb.h" - -#include "ion-bb-core/rt.h" -#include "ion-bb-dnn/rt.h" -#include "ion-bb-image-io/rt.h" +#include +#include +#include using namespace ion; @@ -19,6 +15,7 @@ int main(int argc, char *argv[]) { Builder b; b.set_target(Halide::get_target_from_environment()); + b.with_bb_module("ion-bb"); Node n; n = b.add("image_io_color_data_loader").set_param(Param{"url", "http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}, Param{"width", std::to_string(width)}, Param{"height", std::to_string(height)}); diff --git a/example/dnn_compile.cc b/example/dnn_compile.cc index 05b78024..61a03e0c 100644 --- a/example/dnn_compile.cc +++ b/example/dnn_compile.cc @@ -1,10 +1,6 @@ #include #include -#include "ion-bb-core/bb.h" -#include "ion-bb-dnn/bb.h" -#include "ion-bb-image-io/bb.h" - using namespace ion; int main(int argc, char *argv[]) { @@ -14,6 +10,7 @@ int main(int argc, char *argv[]) { Builder b; b.set_target(Halide::get_target_from_environment()); + b.with_bb_module("ion-bb"); Node n; n = b.add("image_io_color_data_loader").set_param(Param{"url", "http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}, Param{"width", std::to_string(input_width)}, Param{"height", std::to_string(input_height)}); diff --git a/example/dnn_run.cc b/example/dnn_run.cc index 300b814d..9eed39a9 100644 --- a/example/dnn_run.cc +++ b/example/dnn_run.cc @@ -1,9 +1,5 @@ #include "dnn.h" -#include "ion-bb-core/rt.h" -#include "ion-bb-dnn/rt.h" -#include "ion-bb-image-io/rt.h" - #include #include diff --git a/example/gender_count.cc b/example/gender_count.cc index acf60f66..bd3dc9c6 100644 --- a/example/gender_count.cc +++ b/example/gender_count.cc @@ -2,14 +2,6 @@ #include #include -#include "ion-bb-core/bb.h" -#include "ion-bb-dnn/bb.h" -#include "ion-bb-image-io/bb.h" - -#include "ion-bb-core/rt.h" -#include "ion-bb-dnn/rt.h" -#include "ion-bb-image-io/rt.h" - using namespace ion; using json = nlohmann::json; @@ -28,6 +20,7 @@ int main(int argc, char *argv[]) { Builder b; b.set_target(Halide::get_target_from_environment()); + b.with_bb_module("ion-bb"); Node n; n = b.add("image_io_camera").set_param(wparam, hparam); diff --git a/example/imx219_isp_display.cc b/example/imx219_isp_display.cc index a2ff8f99..f538cc43 100644 --- a/example/imx219_isp_display.cc +++ b/example/imx219_isp_display.cc @@ -6,14 +6,6 @@ #include -#include "ion-bb-core/bb.h" -#include "ion-bb-image-io/bb.h" -#include "ion-bb-image-processing/bb.h" - -#include "ion-bb-core/rt.h" -#include "ion-bb-image-io/rt.h" -#include "ion-bb-image-processing/rt.h" - #include "util.h" using namespace ion; @@ -29,6 +21,7 @@ int main(int argc, char *argv[]) { Builder b; b.set_target(Halide::Target{get_target_from_cmdline(argc, argv)}); + b.with_bb_module("ion-bb"); constexpr int32_t num = 2; Node n; diff --git a/example/io.cc b/example/io.cc index 3a017b8b..8ce650dd 100644 --- a/example/io.cc +++ b/example/io.cc @@ -1,8 +1,8 @@ -#include +#include #include +#include -#include "ion-bb-image-io/bb.h" -#include "ion-bb-image-io/rt.h" +#include using namespace ion; @@ -13,6 +13,7 @@ int main(int argc, char *argv[]) { Builder b; b.set_target(Halide::get_target_from_environment()); + b.with_bb_module("ion-bb"); Node n; n = b.add("image_io_grayscale_data_loader").set_param(Param{"width", std::to_string(width)}, Param{"height", std::to_string(height)}, Param{"url", "http://ion-kit.s3.us-west-2.amazonaws.com/models/20210623_genesis_bayer_image_raw.zip"}, Param{"dynamic_range", "255"}); diff --git a/example/isp.cc b/example/isp.cc index b404e927..a862c539 100644 --- a/example/isp.cc +++ b/example/isp.cc @@ -12,14 +12,6 @@ #include #include -#include "ion-bb-core/bb.h" -#include "ion-bb-image-io/bb.h" -#include "ion-bb-image-processing/bb.h" - -#include "ion-bb-core/rt.h" -#include "ion-bb-image-io/rt.h" -#include "ion-bb-image-processing/rt.h" - using namespace ion; void save_image(Halide::Buffer buffer, std::string filename) { @@ -48,6 +40,7 @@ int main(int argc, char *argv[]) { Builder b; b.set_target(Halide::get_target_from_environment()); + b.with_bb_module("ion-bb"); // Parameters for IMX219 Port input{"input", Halide::type_of(), 2}; diff --git a/example/isp_and_sgm.cc b/example/isp_and_sgm.cc index 95213f5f..b43fccce 100644 --- a/example/isp_and_sgm.cc +++ b/example/isp_and_sgm.cc @@ -8,16 +8,6 @@ #include #include -#include "ion-bb-core/bb.h" -#include "ion-bb-image-processing/bb.h" -#include "ion-bb-image-io/bb.h" -#include "ion-bb-sgm/bb.h" - -#include "ion-bb-core/rt.h" -#include "ion-bb-image-processing/rt.h" -#include "ion-bb-image-io/rt.h" -#include "ion-bb-sgm/rt.h" - using namespace ion; int main(int argc, char *argv[]) { @@ -148,6 +138,7 @@ int main(int argc, char *argv[]) { Builder b; b.set_target(Halide::get_target_from_environment()); + b.with_bb_module("ion-bb"); // ISP Nodes Node loader, normalize; diff --git a/example/producerx3_compile.cc b/example/producerx3_compile.cc index 0be52c15..f0934a2b 100644 --- a/example/producerx3_compile.cc +++ b/example/producerx3_compile.cc @@ -1,7 +1,5 @@ #include -#include "ion-bb-core/bb.h" - #include using namespace ion; @@ -11,6 +9,7 @@ int main() { Port input{"input", Halide::type_of()}; Builder b; b.set_target(Halide::get_target_from_environment()); + b.with_bb_module("ion-bb"); Node n = b.add("core_scalar_to_func_uint8")(input); n = b.add("core_extend_dimension_0d_uint8")(n["output"]); diff --git a/example/realsense.cc b/example/realsense.cc index c2c88ca6..40987135 100644 --- a/example/realsense.cc +++ b/example/realsense.cc @@ -10,9 +10,6 @@ #include #include -#include "ion-bb-image-io/bb.h" -#include "ion-bb-image-io/rt.h" - #include "util.h" using namespace ion; @@ -20,6 +17,7 @@ using namespace ion; int main(int argc, char *argv[]) { Builder b; b.set_target(Halide::Target{get_target_from_cmdline(argc, argv)}); + b.with_bb_module("ion-bb"); Node n = b.add("image_io_d435"); diff --git a/example/sgm_compile.cc b/example/sgm_compile.cc index e454b740..31a972f1 100644 --- a/example/sgm_compile.cc +++ b/example/sgm_compile.cc @@ -1,11 +1,5 @@ #include -#include "ion-bb-core/bb.h" -#include "ion-bb-image-io/bb.h" -#include "ion-bb-image-processing/bb.h" -#include "ion-bb-internal/bb.h" -#include "ion-bb-sgm/bb.h" - using namespace ion; int main() { @@ -19,6 +13,7 @@ int main() { Builder b; b.set_target(Halide::get_target_from_environment()); + b.with_bb_module("ion-bb"); Node ln = b.add("image_io_color_data_loader").set_param(Param{"url", "http://ion-kit.s3.us-west-2.amazonaws.com/images/aloe_left.jpg"}, Param{"width", std::to_string(input_width)}, Param{"height", std::to_string(input_height)}); ln = b.add("core_normalize_3d_uint8")(ln["output"]); diff --git a/example/sgm_run.cc b/example/sgm_run.cc index 4e5b4c87..ae509603 100644 --- a/example/sgm_run.cc +++ b/example/sgm_run.cc @@ -1,11 +1,5 @@ #include "sgm.h" -#include "ion-bb-core/rt.h" -#include "ion-bb-image-io/rt.h" -#include "ion-bb-image-processing/rt.h" -#include "ion-bb-internal/rt.h" -#include "ion-bb-sgm/rt.h" - #include #include diff --git a/example/u3v.cc b/example/u3v.cc index 6d0df236..a22b3ef8 100644 --- a/example/u3v.cc +++ b/example/u3v.cc @@ -1,6 +1,7 @@ #include #include #include +#include // to display #include @@ -9,14 +10,6 @@ // ion #include -#include "ion-bb-core/bb.h" -#include "ion-bb-core/rt.h" -#include "ion-bb-image-io/bb.h" -#include "ion-bb-image-io/rt.h" -#include "ion-bb-image-processing/bb.h" -#include "ion-bb-image-processing/rt.h" - -#include "ion-bb-image-io/ghc/filesystem.hpp" #define FEATURE_GAIN_KEY "Gain" #define FEATURE_EXPOSURE_KEY "Exposure" @@ -165,7 +158,7 @@ void display_and_save(int32_t width, int32_t height, std::string directory_path, cv::destroyAllWindows(); } -void open_and_check(int32_t& width, int32_t& height, const ghc::filesystem::path output_directory, uint32_t& file_idx, std::ifstream& ifs, bool *finished) { +void open_and_check(int32_t& width, int32_t& height, const filesystem::path output_directory, uint32_t& file_idx, std::ifstream& ifs, bool *finished) { auto file_path = output_directory / ("raw-" + ::std::to_string(file_idx++) + ".bin"); ifs = ::std::ifstream(file_path, ::std::ios::binary); @@ -185,7 +178,7 @@ void open_and_check(int32_t& width, int32_t& height, const ghc::filesystem::path ifs.seekg(512, ::std::ios_base::beg); } -bool load_header_file(ghc::filesystem::path output_directory, rawHeader header_info) +bool load_header_file(std::filesystem::path output_directory, rawHeader header_info) { std::ifstream ifs; int width_, height_; @@ -253,11 +246,11 @@ int main() { int32_t height = 1080; float fps = 60.0f; - ghc::filesystem::path test_directory = "u3v_framerate_test"; + std::filesystem::path test_directory = "u3v_framerate_test"; std::string output_directory_prefix = "u3v_framerate_test"; - if(! ghc::filesystem::is_directory(test_directory)){ - bool ret = ghc::filesystem::create_directory(test_directory); + if(! std::filesystem::is_directory(test_directory)){ + bool ret = std::filesystem::create_directory(test_directory); } rawHeader header_info = { @@ -268,9 +261,9 @@ int main() { int num_run = 50; for (int i = 0; i < num_run; ++i){ - ghc::filesystem::path output_directory = test_directory / (output_directory_prefix + std::to_string(i)); - if(! ghc::filesystem::is_directory(output_directory)){ - bool ret = ghc::filesystem::create_directory(output_directory); + std::filesystem::path output_directory = test_directory / (output_directory_prefix + std::to_string(i)); + if(! std::filesystem::is_directory(output_directory)){ + bool ret = std::filesystem::create_directory(output_directory); } display_and_save(width, height, output_directory.string(), header_info, i == num_run - 1); bool ret = load_header_file(output_directory, header_info); diff --git a/example/v4l2.cc b/example/v4l2.cc index 03d7b21a..e9c8f115 100644 --- a/example/v4l2.cc +++ b/example/v4l2.cc @@ -10,8 +10,6 @@ #include #include -#include "ion-bb-image-io/bb.h" -#include "ion-bb-image-io/rt.h" #include "util.h" @@ -64,6 +62,7 @@ void save_image(Halide::Buffer buffer, std::string filename) { int main(int argc, char *argv[]) { Builder b; b.set_target(Halide::Target{get_target_from_cmdline(argc, argv)}); + b.with_bb_module("ion-bb"); const int32_t width = 640; const int32_t height = 480; diff --git a/include/ion-bb-core/Dockerfile b/include/ion-bb-core/Dockerfile deleted file mode 100644 index 1de569da..00000000 --- a/include/ion-bb-core/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -# Build command: -# $ docker buildx build --platform linux/amd64,linux/arm64 --push -t localhost:5000/ion-bb-demo . - -FROM ubuntu:18.04 -ARG TARGETPLATFORM - -# -# Basic package -# -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y \ - curl - -# -# Halide -# -RUN cd /usr/include \ - && curl -fsSL -O https://ion-kit.s3.us-west-2.amazonaws.com/dependencies/Halide-Headers-v12.0.1-9a99bee06/HalideRuntime.h \ - -O https://ion-kit.s3.us-west-2.amazonaws.com/dependencies/Halide-Headers-v12.0.1-9a99bee06/HalideBuffer.h diff --git a/include/ion-bb-internal/Dockerfile b/include/ion-bb-internal/Dockerfile deleted file mode 100644 index d9e7f9cb..00000000 --- a/include/ion-bb-internal/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# Build command: -# $ docker buildx build --platform linux/amd64,linux/arm64 --push -t localhost:5000/ion-bb-internal . - -FROM ubuntu:18.04 - -# -# Basic package -# -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y \ - build-essential \ - cmake \ - g++ \ - gcc \ - make diff --git a/include/ion-bb-internal/README.md b/include/ion-bb-internal/README.md deleted file mode 100644 index aa85e190..00000000 --- a/include/ion-bb-internal/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# ion-bb-internal - diff --git a/include/ion-bb-internal/bb.h b/include/ion-bb-internal/bb.h deleted file mode 100644 index 4230dbd4..00000000 --- a/include/ion-bb-internal/bb.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef ION_BB_INTERNAL_BB_H -#define ION_BB_INTERNAL_BB_H - -#include "ion/ion.h" - -namespace ion { -namespace bb { -namespace internal { - -class Schedule : public ion::BuildingBlock { -public: - GeneratorParam output_name{"output_name", ""}; - GeneratorParam compute_level{"compute_level", ""}; // "compute_inline" or "compute_root" - GeneratorParam concurrency{"concurrency", ""}; // comma separated string - - GeneratorInput input{"input"}; - GeneratorOutput output{"output"}; - - void generate() { - using namespace Halide; - if (static_cast(compute_level) == "compute_inline") { - output = input; - } else if (static_cast(compute_level) == "compute_root") { - Func f(static_cast(output_name)); - f(_) = input(_); - f.compute_root(); - if (get_target().has_gpu_feature()) { - if (f.args().size() == 0) { - // NOP - } else if (f.args().size() == 1) { - Var i = f.args()[0]; - Var block, thread; - f.split(i, block, thread, 64); - f.gpu_blocks(block).gpu_threads(thread); - } else { - Var x = f.args()[0]; - Var y = f.args()[1]; - for (int i=2; i { -public: - GeneratorParam output_name{"output_name", ""}; - GeneratorParam compute_level{"compute_level", ""}; - - GeneratorInput input{"input"}; - GeneratorOutput output{"output"}; - GeneratorOutput output_for_preview{"output_for_preview"}; - - void generate() { - using namespace Halide; - { - // Internal connection is always separated with input. - Func f(static_cast(output_name) + "_"); - f(_) = input(_); - f.compute_root(); - output = f; - } - - { - if (static_cast(compute_level) == "compute_inline") { - output_for_preview = input; - } else if (static_cast(compute_level) == "compute_root") { - Func f(static_cast(output_name)); - f(_) = input(_); - f.compute_root(); - output_for_preview = f; - } else { - throw std::runtime_error("Unreachable"); - } - } - } -}; - -} // internal -} // bb -} // ion - -ION_REGISTER_BUILDING_BLOCK(ion::bb::internal::ScheduleForPreview, internal_schedule_for_preview); - -// #include "bb_sgm.h" - -#endif diff --git a/include/ion-bb-internal/config.cmake b/include/ion-bb-internal/config.cmake deleted file mode 100644 index c9df571b..00000000 --- a/include/ion-bb-internal/config.cmake +++ /dev/null @@ -1,4 +0,0 @@ -set(INCLUDE_DIRS) -set(LINK_DIRS) -set(RUNTIME_ENVS) -set(LIBRARIES) diff --git a/include/ion-bb-internal/rt.h b/include/ion-bb-internal/rt.h deleted file mode 100644 index 65e53a87..00000000 --- a/include/ion-bb-internal/rt.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef ION_BB_INTERNAL_RT_H -#define ION_BB_INTERNAL_RT_H - -#endif diff --git a/include/ion-bb-sgm/config.cmake b/include/ion-bb-sgm/config.cmake deleted file mode 100644 index e69de29b..00000000 diff --git a/src/bb/CMakeLists.txt b/src/bb/CMakeLists.txt new file mode 100644 index 00000000..aaa3eb5d --- /dev/null +++ b/src/bb/CMakeLists.txt @@ -0,0 +1,52 @@ +cmake_policy(SET CMP0057 NEW) + +set(ION_BB_INCLUDE_DIRS) +set(ION_BB_LINK_DIRS) +set(ION_BB_LIBRARIES) +file(GLOB childs ${CMAKE_CURRENT_SOURCE_DIR}/*) +foreach(child ${childs}) + if(IS_DIRECTORY ${child}) + get_filename_component(BB_NAME ${child} NAME) + set(IS_TARGET_BB FALSE) + if(${BB_NAME} IN_LIST ION_TARGET_BB) + set(IS_TARGET_BB TRUE) + endif() + + if(${IS_TARGET_BB}) + set(INCLUDE_DIRS) + set(LINK_DIRS) + set(LIBRARIES) + if(EXISTS ${child}/config.cmake) + include(${child}/config.cmake) + endif() + list(APPEND ION_BB_INCLUDE_DIRS ${INCLUDE_DIRS}) + list(APPEND ION_BB_LINK_DIRS ${LINK_DIRS}) + list(APPEND ION_BB_LIBRARIES ${LIBRARIES}) + string(TOUPPER ${BB_NAME} POSTFIX) + string(REPLACE "-" "_" ${POSTFIX} POSTFIX) + add_definitions("-DION_ENABLE_BB_${POSTFIX}") + endif() + endif() +endforeach() + +add_library(ion-bb SHARED bb.cc) +target_include_directories(ion-bb PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${ION_BB_INCLUDE_DIRS}) +target_link_libraries(ion-bb PUBLIC ion-core ${ION_BB_LIBRARIES}) +message("${ION_BB_INCLUDE_DIRS}") +if(UNIX) + target_compile_options(ion-bb + PUBLIC -fno-rtti # For Halide::Generator + PUBLIC -rdynamic) # For JIT compiling +endif() + + +# +# Install +# +if (UNIX) + install(TARGETS ion-bb DESTINATION lib) +else() + install(FILES ${CMAKE_BINARY_DIR}/$<$:Release>$<$:Debug>/ion-bb.dll DESTINATION bin) + install(FILES ${CMAKE_BINARY_DIR}/$<$:Release>$<$:Debug>/ion-bb.lib DESTINATION lib) +endif() + diff --git a/include/ion-bb-core/README.en.md b/src/bb/base/README.en.md similarity index 100% rename from include/ion-bb-core/README.en.md rename to src/bb/base/README.en.md diff --git a/include/ion-bb-core/README.ja.md b/src/bb/base/README.ja.md similarity index 100% rename from include/ion-bb-core/README.ja.md rename to src/bb/base/README.ja.md diff --git a/include/ion-bb-core/bb.h b/src/bb/base/bb.h similarity index 78% rename from include/ion-bb-core/bb.h rename to src/bb/base/bb.h index c2a643f4..0a674e6e 100644 --- a/include/ion-bb-core/bb.h +++ b/src/bb/base/bb.h @@ -5,7 +5,7 @@ namespace ion { namespace bb { -namespace core { +namespace base { template class BufferLoader : public BuildingBlock { @@ -40,7 +40,7 @@ class BufferLoader : public BuildingBlock { } Halide::Func buffer_loader(static_cast(gc_prefix) + "buffer_loader"); - buffer_loader.define_extern("ion_bb_core_buffer_loader", params, Halide::type_of(), D); + buffer_loader.define_extern("ion_bb_base_buffer_loader", params, Halide::type_of(), D); buffer_loader.compute_root(); output(Halide::_) = buffer_loader(Halide::_); } @@ -215,7 +215,7 @@ class BufferSaver : public BuildingBlock { } Halide::Func buffer_saver(static_cast(gc_prefix) + "buffer_saver"); - buffer_saver.define_extern("ion_bb_core_buffer_saver", params, Halide::Int(32), 0); + buffer_saver.define_extern("ion_bb_base_buffer_saver", params, Halide::Int(32), 0); buffer_saver.compute_root(); output(Halide::_) = buffer_saver(Halide::_); } @@ -386,7 +386,7 @@ class RandomBuffer : public BuildingBlock { } Halide::Func random_buffer(static_cast(gc_prefix) + "random_buffer"); - random_buffer.define_extern("ion_bb_core_random_buffer", params, Halide::type_of(), D); + random_buffer.define_extern("ion_bb_base_random_buffer", params, Halide::type_of(), D); random_buffer.compute_root(); output(Halide::_) = random_buffer(Halide::_); } @@ -1959,214 +1959,214 @@ class ScalarToFuncFloat : public ScalarToFunc { } // namespace bb } // namespace ion -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader1DUInt8, core_buffer_loader_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader2DUInt8, core_buffer_loader_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader3DUInt8, core_buffer_loader_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader4DUInt8, core_buffer_loader_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader1DUInt16, core_buffer_loader_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader2DUInt16, core_buffer_loader_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader3DUInt16, core_buffer_loader_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader4DUInt16, core_buffer_loader_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader1DFloat, core_buffer_loader_1d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader2DFloat, core_buffer_loader_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader3DFloat, core_buffer_loader_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferLoader4DFloat, core_buffer_loader_4d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver1DUInt8, core_buffer_saver_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver2DUInt8, core_buffer_saver_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver3DUInt8, core_buffer_saver_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver4DUInt8, core_buffer_saver_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver1DUInt16, core_buffer_saver_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver2DUInt16, core_buffer_saver_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver3DUInt16, core_buffer_saver_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver4DUInt16, core_buffer_saver_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver1DFloat, core_buffer_saver_1d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver2DFloat, core_buffer_saver_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver3DFloat, core_buffer_saver_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::BufferSaver4DFloat, core_buffer_saver_4d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer1DUInt8, core_random_buffer_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer2DUInt8, core_random_buffer_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer3DUInt8, core_random_buffer_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer4DUInt8, core_random_buffer_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer1DUInt16, core_random_buffer_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer2DUInt16, core_random_buffer_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer3DUInt16, core_random_buffer_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer4DUInt16, core_random_buffer_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer1DFloat, core_random_buffer_1d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer2DFloat, core_random_buffer_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer3DFloat, core_random_buffer_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::RandomBuffer4DFloat, core_random_buffer_4d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ReorderBuffer2DUInt8, core_reorder_buffer_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ReorderBuffer3DUInt8, core_reorder_buffer_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ReorderBuffer4DUInt8, core_reorder_buffer_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ReorderBuffer2DUInt16, core_reorder_buffer_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ReorderBuffer3DUInt16, core_reorder_buffer_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ReorderBuffer4DUInt16, core_reorder_buffer_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ReorderBuffer2DFloat, core_reorder_buffer_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ReorderBuffer3DFloat, core_reorder_buffer_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ReorderBuffer4DFloat, core_reorder_buffer_4d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Denormalize1DUInt8, core_denormalize_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Denormalize2DUInt8, core_denormalize_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Denormalize3DUInt8, core_denormalize_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Denormalize4DUInt8, core_denormalize_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Denormalize1DUInt16, core_denormalize_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Denormalize2DUInt16, core_denormalize_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Denormalize3DUInt16, core_denormalize_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Denormalize4DUInt16, core_denormalize_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Normalize1DUInt8, core_normalize_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Normalize2DUInt8, core_normalize_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Normalize3DUInt8, core_normalize_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Normalize4DUInt8, core_normalize_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Normalize1DUInt16, core_normalize_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Normalize2DUInt16, core_normalize_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Normalize3DUInt16, core_normalize_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Normalize4DUInt16, core_normalize_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension0DUInt8, core_extend_dimension_0d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension1DUInt8, core_extend_dimension_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension2DUInt8, core_extend_dimension_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension3DUInt8, core_extend_dimension_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension0DUInt16, core_extend_dimension_0d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension1DUInt16, core_extend_dimension_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension2DUInt16, core_extend_dimension_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension3DUInt16, core_extend_dimension_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension0DFloat, core_extend_dimension_0d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension1DFloat, core_extend_dimension_1d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension2DFloat, core_extend_dimension_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtendDimension3DFloat, core_extend_dimension_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer1DUInt8, core_extract_buffer_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer2DUInt8, core_extract_buffer_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer3DUInt8, core_extract_buffer_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer4DUInt8, core_extract_buffer_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer1DUInt16, core_extract_buffer_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer2DUInt16, core_extract_buffer_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer3DUInt16, core_extract_buffer_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer4DUInt16, core_extract_buffer_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer1DFloat, core_extract_buffer_1d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer2DFloat, core_extract_buffer_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer3DFloat, core_extract_buffer_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ExtractBuffer4DFloat, core_extract_buffer_4d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer1DUInt8, core_concat_buffer_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer2DUInt8, core_concat_buffer_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer3DUInt8, core_concat_buffer_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer4DUInt8, core_concat_buffer_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer1DUInt16, core_concat_buffer_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer2DUInt16, core_concat_buffer_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer3DUInt16, core_concat_buffer_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer4DUInt16, core_concat_buffer_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer1DFloat, core_concat_buffer_1d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer2DFloat, core_concat_buffer_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer3DFloat, core_concat_buffer_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConcatBuffer4DFloat, core_concat_buffer_4d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer0DUInt8, core_constant_buffer_0d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer1DUInt8, core_constant_buffer_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer2DUInt8, core_constant_buffer_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer3DUInt8, core_constant_buffer_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer4DUInt8, core_constant_buffer_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer0DUInt16, core_constant_buffer_0d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer1DUInt16, core_constant_buffer_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer2DUInt16, core_constant_buffer_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer3DUInt16, core_constant_buffer_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer4DUInt16, core_constant_buffer_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer0DFloat, core_constant_buffer_0d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer1DFloat, core_constant_buffer_1d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer2DFloat, core_constant_buffer_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer3DFloat, core_constant_buffer_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ConstantBuffer4DFloat, core_constant_buffer_4d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add0DUInt8, core_add_0d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add1DUInt8, core_add_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add2DUInt8, core_add_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add3DUInt8, core_add_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add4DUInt8, core_add_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add0DUInt16, core_add_0d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add1DUInt16, core_add_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add2DUInt16, core_add_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add3DUInt16, core_add_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add4DUInt16, core_add_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add0DFloat, core_add_0d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add1DFloat, core_add_1d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add2DFloat, core_add_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add3DFloat, core_add_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Add4DFloat, core_add_4d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract0DUInt8, core_subtract_0d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract1DUInt8, core_subtract_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract2DUInt8, core_subtract_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract3DUInt8, core_subtract_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract4DUInt8, core_subtract_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract0DUInt16, core_subtract_0d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract1DUInt16, core_subtract_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract2DUInt16, core_subtract_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract3DUInt16, core_subtract_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract4DUInt16, core_subtract_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract0DFloat, core_subtract_0d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract1DFloat, core_subtract_1d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract2DFloat, core_subtract_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract3DFloat, core_subtract_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Subtract4DFloat, core_subtract_4d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply0DUInt8, core_multiply_0d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply1DUInt8, core_multiply_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply2DUInt8, core_multiply_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply3DUInt8, core_multiply_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply4DUInt8, core_multiply_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply0DUInt16, core_multiply_0d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply1DUInt16, core_multiply_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply2DUInt16, core_multiply_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply3DUInt16, core_multiply_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply4DUInt16, core_multiply_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply0DFloat, core_multiply_0d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply1DFloat, core_multiply_1d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply2DFloat, core_multiply_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply3DFloat, core_multiply_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Multiply4DFloat, core_multiply_4d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide0DUInt8, core_divide_0d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide1DUInt8, core_divide_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide2DUInt8, core_divide_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide3DUInt8, core_divide_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide4DUInt8, core_divide_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide0DUInt16, core_divide_0d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide1DUInt16, core_divide_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide2DUInt16, core_divide_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide3DUInt16, core_divide_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide4DUInt16, core_divide_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide0DFloat, core_divide_0d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide1DFloat, core_divide_1d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide2DFloat, core_divide_2d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide3DFloat, core_divide_3d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Divide4DFloat, core_divide_4d_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Modulo0DUInt8, core_modulo_0d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Modulo1DUInt8, core_modulo_1d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Modulo2DUInt8, core_modulo_2d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Modulo3DUInt8, core_modulo_3d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Modulo4DUInt8, core_modulo_4d_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Modulo0DUInt16, core_modulo_0d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Modulo1DUInt16, core_modulo_1d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Modulo2DUInt16, core_modulo_2d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Modulo3DUInt16, core_modulo_3d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Modulo4DUInt16, core_modulo_4d_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast1DUInt8ToUInt16, core_cast_1d_uint8_to_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast2DUInt8ToUInt16, core_cast_2d_uint8_to_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast3DUInt8ToUInt16, core_cast_3d_uint8_to_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast4DUInt8ToUInt16, core_cast_4d_uint8_to_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast1DUInt8ToFloat, core_cast_1d_uint8_to_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast2DUInt8ToFloat, core_cast_2d_uint8_to_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast3DUInt8ToFloat, core_cast_3d_uint8_to_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast4DUInt8ToFloat, core_cast_4d_uint8_to_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast1DUInt16ToUInt8, core_cast_1d_uint16_to_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast2DUInt16ToUInt8, core_cast_2d_uint16_to_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast3DUInt16ToUInt8, core_cast_3d_uint16_to_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast4DUInt16ToUInt8, core_cast_4d_uint16_to_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast1DUInt16ToFloat, core_cast_1d_uint16_to_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast2DUInt16ToFloat, core_cast_2d_uint16_to_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast3DUInt16ToFloat, core_cast_3d_uint16_to_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast4DUInt16ToFloat, core_cast_4d_uint16_to_float); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast1DFloatToUInt8, core_cast_1d_float_to_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast2DFloatToUInt8, core_cast_2d_float_to_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast3DFloatToUInt8, core_cast_3d_float_to_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast4DFloatToUInt8, core_cast_4d_float_to_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast1DFloatToUInt16, core_cast_1d_float_to_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast2DFloatToUInt16, core_cast_2d_float_to_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast3DFloatToUInt16, core_cast_3d_float_to_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::Cast4DFloatToUInt16, core_cast_4d_float_to_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ScalarToFuncUInt8, core_scalar_to_func_uint8); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ScalarToFuncUInt16, core_scalar_to_func_uint16); -ION_REGISTER_BUILDING_BLOCK(ion::bb::core::ScalarToFuncFloat, core_scalar_to_func_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader1DUInt8, ion_bb_base_buffer_loader_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader2DUInt8, ion_bb_base_buffer_loader_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader3DUInt8, ion_bb_base_buffer_loader_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader4DUInt8, ion_bb_base_buffer_loader_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader1DUInt16, ion_bb_base_buffer_loader_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader2DUInt16, ion_bb_base_buffer_loader_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader3DUInt16, ion_bb_base_buffer_loader_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader4DUInt16, ion_bb_base_buffer_loader_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader1DFloat, ion_bb_base_buffer_loader_1d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader2DFloat, ion_bb_base_buffer_loader_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader3DFloat, ion_bb_base_buffer_loader_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferLoader4DFloat, ion_bb_base_buffer_loader_4d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver1DUInt8, ion_bb_base_buffer_saver_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver2DUInt8, ion_bb_base_buffer_saver_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver3DUInt8, ion_bb_base_buffer_saver_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver4DUInt8, ion_bb_base_buffer_saver_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver1DUInt16, ion_bb_base_buffer_saver_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver2DUInt16, ion_bb_base_buffer_saver_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver3DUInt16, ion_bb_base_buffer_saver_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver4DUInt16, ion_bb_base_buffer_saver_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver1DFloat, ion_bb_base_buffer_saver_1d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver2DFloat, ion_bb_base_buffer_saver_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver3DFloat, ion_bb_base_buffer_saver_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::BufferSaver4DFloat, ion_bb_base_buffer_saver_4d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer1DUInt8, ion_bb_base_random_buffer_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer2DUInt8, ion_bb_base_random_buffer_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer3DUInt8, ion_bb_base_random_buffer_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer4DUInt8, ion_bb_base_random_buffer_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer1DUInt16, ion_bb_base_random_buffer_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer2DUInt16, ion_bb_base_random_buffer_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer3DUInt16, ion_bb_base_random_buffer_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer4DUInt16, ion_bb_base_random_buffer_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer1DFloat, ion_bb_base_random_buffer_1d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer2DFloat, ion_bb_base_random_buffer_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer3DFloat, ion_bb_base_random_buffer_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::RandomBuffer4DFloat, ion_bb_base_random_buffer_4d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ReorderBuffer2DUInt8, ion_bb_base_reorder_buffer_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ReorderBuffer3DUInt8, ion_bb_base_reorder_buffer_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ReorderBuffer4DUInt8, ion_bb_base_reorder_buffer_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ReorderBuffer2DUInt16, ion_bb_base_reorder_buffer_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ReorderBuffer3DUInt16, ion_bb_base_reorder_buffer_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ReorderBuffer4DUInt16, ion_bb_base_reorder_buffer_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ReorderBuffer2DFloat, ion_bb_base_reorder_buffer_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ReorderBuffer3DFloat, ion_bb_base_reorder_buffer_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ReorderBuffer4DFloat, ion_bb_base_reorder_buffer_4d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Denormalize1DUInt8, ion_bb_base_denormalize_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Denormalize2DUInt8, ion_bb_base_denormalize_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Denormalize3DUInt8, ion_bb_base_denormalize_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Denormalize4DUInt8, ion_bb_base_denormalize_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Denormalize1DUInt16, ion_bb_base_denormalize_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Denormalize2DUInt16, ion_bb_base_denormalize_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Denormalize3DUInt16, ion_bb_base_denormalize_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Denormalize4DUInt16, ion_bb_base_denormalize_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Normalize1DUInt8, ion_bb_base_normalize_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Normalize2DUInt8, ion_bb_base_normalize_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Normalize3DUInt8, ion_bb_base_normalize_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Normalize4DUInt8, ion_bb_base_normalize_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Normalize1DUInt16, ion_bb_base_normalize_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Normalize2DUInt16, ion_bb_base_normalize_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Normalize3DUInt16, ion_bb_base_normalize_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Normalize4DUInt16, ion_bb_base_normalize_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension0DUInt8, ion_bb_base_extend_dimension_0d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension1DUInt8, ion_bb_base_extend_dimension_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension2DUInt8, ion_bb_base_extend_dimension_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension3DUInt8, ion_bb_base_extend_dimension_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension0DUInt16, ion_bb_base_extend_dimension_0d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension1DUInt16, ion_bb_base_extend_dimension_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension2DUInt16, ion_bb_base_extend_dimension_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension3DUInt16, ion_bb_base_extend_dimension_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension0DFloat, ion_bb_base_extend_dimension_0d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension1DFloat, ion_bb_base_extend_dimension_1d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension2DFloat, ion_bb_base_extend_dimension_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtendDimension3DFloat, ion_bb_base_extend_dimension_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer1DUInt8, ion_bb_base_extract_buffer_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer2DUInt8, ion_bb_base_extract_buffer_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer3DUInt8, ion_bb_base_extract_buffer_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer4DUInt8, ion_bb_base_extract_buffer_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer1DUInt16, ion_bb_base_extract_buffer_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer2DUInt16, ion_bb_base_extract_buffer_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer3DUInt16, ion_bb_base_extract_buffer_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer4DUInt16, ion_bb_base_extract_buffer_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer1DFloat, ion_bb_base_extract_buffer_1d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer2DFloat, ion_bb_base_extract_buffer_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer3DFloat, ion_bb_base_extract_buffer_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ExtractBuffer4DFloat, ion_bb_base_extract_buffer_4d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer1DUInt8, ion_bb_base_concat_buffer_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer2DUInt8, ion_bb_base_concat_buffer_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer3DUInt8, ion_bb_base_concat_buffer_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer4DUInt8, ion_bb_base_concat_buffer_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer1DUInt16, ion_bb_base_concat_buffer_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer2DUInt16, ion_bb_base_concat_buffer_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer3DUInt16, ion_bb_base_concat_buffer_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer4DUInt16, ion_bb_base_concat_buffer_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer1DFloat, ion_bb_base_concat_buffer_1d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer2DFloat, ion_bb_base_concat_buffer_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer3DFloat, ion_bb_base_concat_buffer_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConcatBuffer4DFloat, ion_bb_base_concat_buffer_4d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer0DUInt8, ion_bb_base_constant_buffer_0d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer1DUInt8, ion_bb_base_constant_buffer_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer2DUInt8, ion_bb_base_constant_buffer_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer3DUInt8, ion_bb_base_constant_buffer_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer4DUInt8, ion_bb_base_constant_buffer_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer0DUInt16, ion_bb_base_constant_buffer_0d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer1DUInt16, ion_bb_base_constant_buffer_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer2DUInt16, ion_bb_base_constant_buffer_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer3DUInt16, ion_bb_base_constant_buffer_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer4DUInt16, ion_bb_base_constant_buffer_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer0DFloat, ion_bb_base_constant_buffer_0d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer1DFloat, ion_bb_base_constant_buffer_1d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer2DFloat, ion_bb_base_constant_buffer_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer3DFloat, ion_bb_base_constant_buffer_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ConstantBuffer4DFloat, ion_bb_base_constant_buffer_4d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add0DUInt8, ion_bb_base_add_0d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add1DUInt8, ion_bb_base_add_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add2DUInt8, ion_bb_base_add_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add3DUInt8, ion_bb_base_add_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add4DUInt8, ion_bb_base_add_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add0DUInt16, ion_bb_base_add_0d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add1DUInt16, ion_bb_base_add_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add2DUInt16, ion_bb_base_add_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add3DUInt16, ion_bb_base_add_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add4DUInt16, ion_bb_base_add_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add0DFloat, ion_bb_base_add_0d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add1DFloat, ion_bb_base_add_1d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add2DFloat, ion_bb_base_add_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add3DFloat, ion_bb_base_add_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Add4DFloat, ion_bb_base_add_4d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract0DUInt8, ion_bb_base_subtract_0d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract1DUInt8, ion_bb_base_subtract_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract2DUInt8, ion_bb_base_subtract_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract3DUInt8, ion_bb_base_subtract_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract4DUInt8, ion_bb_base_subtract_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract0DUInt16, ion_bb_base_subtract_0d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract1DUInt16, ion_bb_base_subtract_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract2DUInt16, ion_bb_base_subtract_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract3DUInt16, ion_bb_base_subtract_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract4DUInt16, ion_bb_base_subtract_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract0DFloat, ion_bb_base_subtract_0d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract1DFloat, ion_bb_base_subtract_1d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract2DFloat, ion_bb_base_subtract_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract3DFloat, ion_bb_base_subtract_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Subtract4DFloat, ion_bb_base_subtract_4d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply0DUInt8, ion_bb_base_multiply_0d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply1DUInt8, ion_bb_base_multiply_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply2DUInt8, ion_bb_base_multiply_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply3DUInt8, ion_bb_base_multiply_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply4DUInt8, ion_bb_base_multiply_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply0DUInt16, ion_bb_base_multiply_0d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply1DUInt16, ion_bb_base_multiply_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply2DUInt16, ion_bb_base_multiply_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply3DUInt16, ion_bb_base_multiply_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply4DUInt16, ion_bb_base_multiply_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply0DFloat, ion_bb_base_multiply_0d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply1DFloat, ion_bb_base_multiply_1d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply2DFloat, ion_bb_base_multiply_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply3DFloat, ion_bb_base_multiply_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Multiply4DFloat, ion_bb_base_multiply_4d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide0DUInt8, ion_bb_base_divide_0d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide1DUInt8, ion_bb_base_divide_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide2DUInt8, ion_bb_base_divide_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide3DUInt8, ion_bb_base_divide_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide4DUInt8, ion_bb_base_divide_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide0DUInt16, ion_bb_base_divide_0d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide1DUInt16, ion_bb_base_divide_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide2DUInt16, ion_bb_base_divide_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide3DUInt16, ion_bb_base_divide_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide4DUInt16, ion_bb_base_divide_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide0DFloat, ion_bb_base_divide_0d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide1DFloat, ion_bb_base_divide_1d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide2DFloat, ion_bb_base_divide_2d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide3DFloat, ion_bb_base_divide_3d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Divide4DFloat, ion_bb_base_divide_4d_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Modulo0DUInt8, ion_bb_base_modulo_0d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Modulo1DUInt8, ion_bb_base_modulo_1d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Modulo2DUInt8, ion_bb_base_modulo_2d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Modulo3DUInt8, ion_bb_base_modulo_3d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Modulo4DUInt8, ion_bb_base_modulo_4d_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Modulo0DUInt16, ion_bb_base_modulo_0d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Modulo1DUInt16, ion_bb_base_modulo_1d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Modulo2DUInt16, ion_bb_base_modulo_2d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Modulo3DUInt16, ion_bb_base_modulo_3d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Modulo4DUInt16, ion_bb_base_modulo_4d_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast1DUInt8ToUInt16, ion_bb_base_cast_1d_uint8_to_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast2DUInt8ToUInt16, ion_bb_base_cast_2d_uint8_to_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast3DUInt8ToUInt16, ion_bb_base_cast_3d_uint8_to_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast4DUInt8ToUInt16, ion_bb_base_cast_4d_uint8_to_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast1DUInt8ToFloat, ion_bb_base_cast_1d_uint8_to_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast2DUInt8ToFloat, ion_bb_base_cast_2d_uint8_to_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast3DUInt8ToFloat, ion_bb_base_cast_3d_uint8_to_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast4DUInt8ToFloat, ion_bb_base_cast_4d_uint8_to_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast1DUInt16ToUInt8, ion_bb_base_cast_1d_uint16_to_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast2DUInt16ToUInt8, ion_bb_base_cast_2d_uint16_to_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast3DUInt16ToUInt8, ion_bb_base_cast_3d_uint16_to_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast4DUInt16ToUInt8, ion_bb_base_cast_4d_uint16_to_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast1DUInt16ToFloat, ion_bb_base_cast_1d_uint16_to_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast2DUInt16ToFloat, ion_bb_base_cast_2d_uint16_to_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast3DUInt16ToFloat, ion_bb_base_cast_3d_uint16_to_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast4DUInt16ToFloat, ion_bb_base_cast_4d_uint16_to_float); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast1DFloatToUInt8, ion_bb_base_cast_1d_float_to_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast2DFloatToUInt8, ion_bb_base_cast_2d_float_to_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast3DFloatToUInt8, ion_bb_base_cast_3d_float_to_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast4DFloatToUInt8, ion_bb_base_cast_4d_float_to_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast1DFloatToUInt16, ion_bb_base_cast_1d_float_to_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast2DFloatToUInt16, ion_bb_base_cast_2d_float_to_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast3DFloatToUInt16, ion_bb_base_cast_3d_float_to_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::Cast4DFloatToUInt16, ion_bb_base_cast_4d_float_to_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ScalarToFuncUInt8, ion_bb_base_scalar_to_func_uint8); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ScalarToFuncUInt16, ion_bb_base_scalar_to_func_uint16); +ION_REGISTER_BUILDING_BLOCK(ion::bb::base::ScalarToFuncFloat, ion_bb_base_scalar_to_func_float); #endif diff --git a/include/ion-bb-core/httplib.h b/src/bb/base/httplib.h similarity index 100% rename from include/ion-bb-core/httplib.h rename to src/bb/base/httplib.h diff --git a/include/ion-bb-core/rt.h b/src/bb/base/rt.h similarity index 83% rename from include/ion-bb-core/rt.h rename to src/bb/base/rt.h index 7d5c227c..b484e130 100644 --- a/include/ion-bb-core/rt.h +++ b/src/bb/base/rt.h @@ -17,11 +17,10 @@ #define ION_EXPORT #endif -#if defined(ION_ENABLE_JIT_EXTERN) #include namespace ion { namespace bb { -namespace core { +namespace base { std::map extern_functions; @@ -35,14 +34,11 @@ class RegisterExtern { } // image_io } // bb } // ion -#define ION_REGISTER_EXTERN(NAME) static auto ion_register_extern_##NAME = ion::bb::core::RegisterExtern(#NAME, NAME); -#else -#define ION_REGISTER_EXTERN(NAME) -#endif +#define ION_REGISTER_EXTERN(NAME) static auto ion_register_extern_##NAME = ion::bb::base::RegisterExtern(#NAME, NAME); namespace ion { namespace bb { -namespace core { +namespace base { std::tuple parse_url(const std::string &url) { if (url.rfind("http://", 0) != 0) { // not starts_with @@ -82,16 +78,16 @@ void fill_by_rng(std::mt19937 &rng, halide_buffer_t *range, halide_buffe std::unordered_map> buffer_cache; std::unordered_map rng_map; -} // namespace core +} // namespace base } // namespace bb } // namespace ion -extern "C" ION_EXPORT int ion_bb_core_buffer_loader(halide_buffer_t *url_buf, int32_t extent0, int32_t extent1, int32_t extent2, int32_t extent3, halide_buffer_t *out) { +extern "C" ION_EXPORT int ion_bb_base_buffer_loader(halide_buffer_t *url_buf, int32_t extent0, int32_t extent1, int32_t extent2, int32_t extent3, halide_buffer_t *out) { std::string url = std::string(reinterpret_cast(url_buf->host)); if (!out->is_bounds_query()) { - auto it = ion::bb::core::buffer_cache.find(url); - if (it != ion::bb::core::buffer_cache.end() && it->second.size() == out->size_in_bytes()) { + auto it = ion::bb::base::buffer_cache.find(url); + if (it != ion::bb::base::buffer_cache.end() && it->second.size() == out->size_in_bytes()) { memcpy(out->host, it->second.data(), it->second.size()); return 0; } else { @@ -117,7 +113,7 @@ extern "C" ION_EXPORT int ion_bb_core_buffer_loader(halide_buffer_t *url_buf, in std::string host_name; std::string path_name; - std::tie(host_name, path_name) = ion::bb::core::parse_url(url); + std::tie(host_name, path_name) = ion::bb::base::parse_url(url); bool img_loaded = false; std::vector data(size); @@ -145,14 +141,14 @@ extern "C" ION_EXPORT int ion_bb_core_buffer_loader(halide_buffer_t *url_buf, in } if (img_loaded) { - ion::bb::core::buffer_cache[url] = data; + ion::bb::base::buffer_cache[url] = data; return 0; } else { return -1; } } -extern "C" int ION_EXPORT ion_bb_core_buffer_saver(halide_buffer_t *in, halide_buffer_t *path_buf, int32_t extent0, int32_t extent1, int32_t extent2, int32_t extent3, halide_buffer_t *out) { +extern "C" int ION_EXPORT ion_bb_base_buffer_saver(halide_buffer_t *in, halide_buffer_t *path_buf, int32_t extent0, int32_t extent1, int32_t extent2, int32_t extent3, halide_buffer_t *out) { std::string path = std::string(reinterpret_cast(path_buf->host)); if (in->is_bounds_query()) { in->dim[0].min = 0; @@ -180,7 +176,7 @@ extern "C" int ION_EXPORT ion_bb_core_buffer_saver(halide_buffer_t *in, halide_b return 0; } -extern "C" ION_EXPORT int ion_bb_core_random_buffer(int32_t instance_id, int32_t seed, halide_buffer_t *range, int32_t extent0, int32_t extent1, int32_t extent2, int32_t extent3, halide_buffer_t *out) { +extern "C" ION_EXPORT int ion_bb_base_random_buffer(int32_t instance_id, int32_t seed, halide_buffer_t *range, int32_t extent0, int32_t extent1, int32_t extent2, int32_t extent3, halide_buffer_t *out) { if (out->is_bounds_query()) { out->dim[0].min = 0; out->dim[0].extent = extent0; @@ -201,33 +197,33 @@ extern "C" ION_EXPORT int ion_bb_core_random_buffer(int32_t instance_id, int32_t } std::mt19937 rng; - auto it = ion::bb::core::rng_map.find(instance_id); - if (it != ion::bb::core::rng_map.end()) { + auto it = ion::bb::base::rng_map.find(instance_id); + if (it != ion::bb::base::rng_map.end()) { rng = it->second; } else { rng = std::mt19937(seed); } if (out->type == halide_type_t(halide_type_uint, 8)) { - ion::bb::core::fill_by_rng(rng, range, out); + ion::bb::base::fill_by_rng(rng, range, out); } else if (out->type == halide_type_t(halide_type_uint, 16)) { - ion::bb::core::fill_by_rng(rng, range, out); + ion::bb::base::fill_by_rng(rng, range, out); } else if (out->type == halide_type_t(halide_type_uint, 32)) { - ion::bb::core::fill_by_rng(rng, range, out); + ion::bb::base::fill_by_rng(rng, range, out); } else if (out->type == halide_type_t(halide_type_uint, 64)) { - ion::bb::core::fill_by_rng(rng, range, out); + ion::bb::base::fill_by_rng(rng, range, out); } else if (out->type == halide_type_t(halide_type_int, 8)) { - ion::bb::core::fill_by_rng(rng, range, out); + ion::bb::base::fill_by_rng(rng, range, out); } else if (out->type == halide_type_t(halide_type_int, 16)) { - ion::bb::core::fill_by_rng(rng, range, out); + ion::bb::base::fill_by_rng(rng, range, out); } else if (out->type == halide_type_t(halide_type_int, 32)) { - ion::bb::core::fill_by_rng(rng, range, out); + ion::bb::base::fill_by_rng(rng, range, out); } else if (out->type == halide_type_t(halide_type_int, 64)) { - ion::bb::core::fill_by_rng(rng, range, out); + ion::bb::base::fill_by_rng(rng, range, out); } else if (out->type == halide_type_t(halide_type_float, 32)) { - ion::bb::core::fill_by_rng(rng, range, out); + ion::bb::base::fill_by_rng(rng, range, out); } else if (out->type == halide_type_t(halide_type_float, 64)) { - ion::bb::core::fill_by_rng(rng, range, out); + ion::bb::base::fill_by_rng(rng, range, out); } else { return -1; } diff --git a/include/ion-bb-core/thirdparty_notice.txt b/src/bb/base/thirdparty_notice.txt similarity index 100% rename from include/ion-bb-core/thirdparty_notice.txt rename to src/bb/base/thirdparty_notice.txt diff --git a/src/bb/bb.cc b/src/bb/bb.cc new file mode 100644 index 00000000..b681f5a7 --- /dev/null +++ b/src/bb/bb.cc @@ -0,0 +1,66 @@ +#include +#include +#include + +#if defined(ION_ENABLE_BB_BASE) +#include "base/bb.h" +#include "base/rt.h" +#endif + +#if defined(ION_ENABLE_BB_DNN) +#include "dnn/bb.h" +#include "dnn/rt.h" +#endif + +#if defined(ION_ENABLE_BB_IMAGE_IO) +#include "image-io/bb.h" +#include "image-io/rt.h" +#endif + +#if defined(ION_ENABLE_BB_IMAGE_PROCESSING) +#include "image-processing/bb.h" +#include "image-processing/rt.h" +#endif + +#if defined(ION_ENABLE_BB_OPENCV) +#include "opencv/bb.h" +#include "opencv/rt.h" +#endif + +#if defined(ION_ENABLE_BB_SGM) +#include "sgm/bb.h" +#include "sgm/rt.h" +#endif + +extern "C" void register_externs(std::map& externs) { +#if defined(ION_ENABLE_BB_BASE) + for (auto kv : ion::bb::base::extern_functions) { + externs.insert({kv.first, Halide::JITExtern(kv.second)}); + } +#endif +#if defined(ION_ENABLE_BB_DNN) + for (auto kv : ion::bb::dnn::extern_functions) { + externs.insert({kv.first, Halide::JITExtern(kv.second)}); + } +#endif +#if defined(ION_ENABLE_BB_IMAGE_IO) + for (auto kv : ion::bb::image_io::extern_functions) { + externs.insert({kv.first, Halide::JITExtern(kv.second)}); + } +#endif +#if defined(ION_ENABLE_BB_IMAGE_PROCESSING) + for (auto kv : ion::bb::image_processing::extern_functions) { + externs.insert({kv.first, Halide::JITExtern(kv.second)}); + } +#endif +#if defined(ION_ENABLE_BB_OPENCV) + for (auto kv : ion::bb::opencv::extern_functions) { + externs.insert({kv.first, Halide::JITExtern(kv.second)}); + } +#endif +#if defined(ION_ENABLE_BB_SGM) + for (auto kv : ion::bb::sgm::extern_functions) { + externs.insert({kv.first, Halide::JITExtern(kv.second)}); + } +#endif +} diff --git a/include/ion-bb-dnn/Dockerfile b/src/bb/dnn/Dockerfile similarity index 100% rename from include/ion-bb-dnn/Dockerfile rename to src/bb/dnn/Dockerfile diff --git a/include/ion-bb-dnn/LICENSE b/src/bb/dnn/LICENSE similarity index 100% rename from include/ion-bb-dnn/LICENSE rename to src/bb/dnn/LICENSE diff --git a/include/ion-bb-dnn/Makefile b/src/bb/dnn/Makefile similarity index 100% rename from include/ion-bb-dnn/Makefile rename to src/bb/dnn/Makefile diff --git a/include/ion-bb-dnn/NvInferRuntime.h b/src/bb/dnn/NvInferRuntime.h similarity index 100% rename from include/ion-bb-dnn/NvInferRuntime.h rename to src/bb/dnn/NvInferRuntime.h diff --git a/include/ion-bb-dnn/NvInferRuntimeCommon.h b/src/bb/dnn/NvInferRuntimeCommon.h similarity index 100% rename from include/ion-bb-dnn/NvInferRuntimeCommon.h rename to src/bb/dnn/NvInferRuntimeCommon.h diff --git a/include/ion-bb-dnn/NvInferVersion.h b/src/bb/dnn/NvInferVersion.h similarity index 100% rename from include/ion-bb-dnn/NvInferVersion.h rename to src/bb/dnn/NvInferVersion.h diff --git a/include/ion-bb-dnn/README.en.md b/src/bb/dnn/README.en.md similarity index 100% rename from include/ion-bb-dnn/README.en.md rename to src/bb/dnn/README.en.md diff --git a/include/ion-bb-dnn/README.ja.md b/src/bb/dnn/README.ja.md similarity index 100% rename from include/ion-bb-dnn/README.ja.md rename to src/bb/dnn/README.ja.md diff --git a/include/ion-bb-dnn/README.md b/src/bb/dnn/README.md similarity index 100% rename from include/ion-bb-dnn/README.md rename to src/bb/dnn/README.md diff --git a/include/ion-bb-dnn/bb.h b/src/bb/dnn/bb.h similarity index 100% rename from include/ion-bb-dnn/bb.h rename to src/bb/dnn/bb.h diff --git a/include/ion-bb-dnn/config.cmake b/src/bb/dnn/config.cmake similarity index 100% rename from include/ion-bb-dnn/config.cmake rename to src/bb/dnn/config.cmake diff --git a/include/ion-bb-dnn/edgetpu_c.h b/src/bb/dnn/edgetpu_c.h similarity index 100% rename from include/ion-bb-dnn/edgetpu_c.h rename to src/bb/dnn/edgetpu_c.h diff --git a/include/ion-bb-dnn/httplib.h b/src/bb/dnn/httplib.h similarity index 100% rename from include/ion-bb-dnn/httplib.h rename to src/bb/dnn/httplib.h diff --git a/include/ion-bb-dnn/json.hpp b/src/bb/dnn/json.hpp similarity index 100% rename from include/ion-bb-dnn/json.hpp rename to src/bb/dnn/json.hpp diff --git a/include/ion-bb-dnn/n2cube.h b/src/bb/dnn/n2cube.h similarity index 100% rename from include/ion-bb-dnn/n2cube.h rename to src/bb/dnn/n2cube.h diff --git a/include/ion-bb-dnn/onnxruntime_c.h b/src/bb/dnn/onnxruntime_c.h similarity index 100% rename from include/ion-bb-dnn/onnxruntime_c.h rename to src/bb/dnn/onnxruntime_c.h diff --git a/include/ion-bb-dnn/picosha2.h b/src/bb/dnn/picosha2.h similarity index 100% rename from include/ion-bb-dnn/picosha2.h rename to src/bb/dnn/picosha2.h diff --git a/include/ion-bb-dnn/rt.h b/src/bb/dnn/rt.h similarity index 99% rename from include/ion-bb-dnn/rt.h rename to src/bb/dnn/rt.h index 155a2980..b54b0fc9 100644 --- a/include/ion-bb-dnn/rt.h +++ b/src/bb/dnn/rt.h @@ -3,7 +3,6 @@ #include -#if defined(ION_ENABLE_JIT_EXTERN) #include namespace ion { namespace bb { @@ -22,9 +21,6 @@ class RegisterExtern { } // bb } // ion #define ION_REGISTER_EXTERN(NAME) static auto ion_register_extern_##NAME = ion::bb::dnn::RegisterExtern(#NAME, NAME); -#else -#define ION_REGISTER_EXTERN(NAME) -#endif #include "json.hpp" #include "rt_dnndk.h" diff --git a/include/ion-bb-dnn/rt_dnndk.h b/src/bb/dnn/rt_dnndk.h similarity index 100% rename from include/ion-bb-dnn/rt_dnndk.h rename to src/bb/dnn/rt_dnndk.h diff --git a/include/ion-bb-dnn/rt_json.h b/src/bb/dnn/rt_json.h similarity index 100% rename from include/ion-bb-dnn/rt_json.h rename to src/bb/dnn/rt_json.h diff --git a/include/ion-bb-dnn/rt_opencv.h b/src/bb/dnn/rt_opencv.h similarity index 100% rename from include/ion-bb-dnn/rt_opencv.h rename to src/bb/dnn/rt_opencv.h diff --git a/include/ion-bb-dnn/rt_ort.h b/src/bb/dnn/rt_ort.h similarity index 100% rename from include/ion-bb-dnn/rt_ort.h rename to src/bb/dnn/rt_ort.h diff --git a/include/ion-bb-dnn/rt_ssd.h b/src/bb/dnn/rt_ssd.h similarity index 100% rename from include/ion-bb-dnn/rt_ssd.h rename to src/bb/dnn/rt_ssd.h diff --git a/include/ion-bb-dnn/rt_tfl.h b/src/bb/dnn/rt_tfl.h similarity index 100% rename from include/ion-bb-dnn/rt_tfl.h rename to src/bb/dnn/rt_tfl.h diff --git a/include/ion-bb-dnn/rt_trt.h b/src/bb/dnn/rt_trt.h similarity index 100% rename from include/ion-bb-dnn/rt_trt.h rename to src/bb/dnn/rt_trt.h diff --git a/include/ion-bb-dnn/rt_util.h b/src/bb/dnn/rt_util.h similarity index 100% rename from include/ion-bb-dnn/rt_util.h rename to src/bb/dnn/rt_util.h diff --git a/include/ion-bb-dnn/rt_yolo.h b/src/bb/dnn/rt_yolo.h similarity index 100% rename from include/ion-bb-dnn/rt_yolo.h rename to src/bb/dnn/rt_yolo.h diff --git a/include/ion-bb-dnn/sole.hpp b/src/bb/dnn/sole.hpp similarity index 100% rename from include/ion-bb-dnn/sole.hpp rename to src/bb/dnn/sole.hpp diff --git a/include/ion-bb-dnn/tensorflowlite_c.h b/src/bb/dnn/tensorflowlite_c.h similarity index 100% rename from include/ion-bb-dnn/tensorflowlite_c.h rename to src/bb/dnn/tensorflowlite_c.h diff --git a/include/ion-bb-dnn/tensorflowlite_types.h b/src/bb/dnn/tensorflowlite_types.h similarity index 100% rename from include/ion-bb-dnn/tensorflowlite_types.h rename to src/bb/dnn/tensorflowlite_types.h diff --git a/include/ion-bb-dnn/thirdparty_notice.txt b/src/bb/dnn/thirdparty_notice.txt similarity index 100% rename from include/ion-bb-dnn/thirdparty_notice.txt rename to src/bb/dnn/thirdparty_notice.txt diff --git a/include/ion-bb-fpga/Dockerfile b/src/bb/fpga/Dockerfile similarity index 100% rename from include/ion-bb-fpga/Dockerfile rename to src/bb/fpga/Dockerfile diff --git a/include/ion-bb-fpga/README.en.md b/src/bb/fpga/README.en.md similarity index 100% rename from include/ion-bb-fpga/README.en.md rename to src/bb/fpga/README.en.md diff --git a/include/ion-bb-fpga/README.ja.md b/src/bb/fpga/README.ja.md similarity index 100% rename from include/ion-bb-fpga/README.ja.md rename to src/bb/fpga/README.ja.md diff --git a/include/ion-bb-fpga/bb.h b/src/bb/fpga/bb.h similarity index 100% rename from include/ion-bb-fpga/bb.h rename to src/bb/fpga/bb.h diff --git a/include/ion-bb-fpga/config.cmake b/src/bb/fpga/config.cmake similarity index 100% rename from include/ion-bb-fpga/config.cmake rename to src/bb/fpga/config.cmake diff --git a/include/ion-bb-fpga/rt.h b/src/bb/fpga/rt.h similarity index 100% rename from include/ion-bb-fpga/rt.h rename to src/bb/fpga/rt.h diff --git a/include/ion-bb-image-io/Dockerfile b/src/bb/image-io/Dockerfile similarity index 100% rename from include/ion-bb-image-io/Dockerfile rename to src/bb/image-io/Dockerfile diff --git a/include/ion-bb-image-io/README.en.md b/src/bb/image-io/README.en.md similarity index 100% rename from include/ion-bb-image-io/README.en.md rename to src/bb/image-io/README.en.md diff --git a/include/ion-bb-image-io/README.ja.md b/src/bb/image-io/README.ja.md similarity index 100% rename from include/ion-bb-image-io/README.ja.md rename to src/bb/image-io/README.ja.md diff --git a/include/ion-bb-image-io/bb.h b/src/bb/image-io/bb.h similarity index 100% rename from include/ion-bb-image-io/bb.h rename to src/bb/image-io/bb.h diff --git a/include/ion-bb-image-io/config.cmake b/src/bb/image-io/config.cmake similarity index 100% rename from include/ion-bb-image-io/config.cmake rename to src/bb/image-io/config.cmake diff --git a/include/ion-bb-image-io/gendc_separator/ComponentHeader.h b/src/bb/image-io/gendc_separator/ComponentHeader.h similarity index 100% rename from include/ion-bb-image-io/gendc_separator/ComponentHeader.h rename to src/bb/image-io/gendc_separator/ComponentHeader.h diff --git a/include/ion-bb-image-io/gendc_separator/ContainerHeader.h b/src/bb/image-io/gendc_separator/ContainerHeader.h similarity index 100% rename from include/ion-bb-image-io/gendc_separator/ContainerHeader.h rename to src/bb/image-io/gendc_separator/ContainerHeader.h diff --git a/include/ion-bb-image-io/gendc_separator/Descriptor.h b/src/bb/image-io/gendc_separator/Descriptor.h similarity index 100% rename from include/ion-bb-image-io/gendc_separator/Descriptor.h rename to src/bb/image-io/gendc_separator/Descriptor.h diff --git a/include/ion-bb-image-io/gendc_separator/PartHeader.h b/src/bb/image-io/gendc_separator/PartHeader.h similarity index 100% rename from include/ion-bb-image-io/gendc_separator/PartHeader.h rename to src/bb/image-io/gendc_separator/PartHeader.h diff --git a/include/ion-bb-image-io/gendc_separator/tools.h b/src/bb/image-io/gendc_separator/tools.h similarity index 100% rename from include/ion-bb-image-io/gendc_separator/tools.h rename to src/bb/image-io/gendc_separator/tools.h diff --git a/include/ion-bb-image-io/ghc/filesystem.hpp b/src/bb/image-io/ghc/filesystem.hpp similarity index 100% rename from include/ion-bb-image-io/ghc/filesystem.hpp rename to src/bb/image-io/ghc/filesystem.hpp diff --git a/include/ion-bb-image-io/ghc/fs_fwd.hpp b/src/bb/image-io/ghc/fs_fwd.hpp similarity index 100% rename from include/ion-bb-image-io/ghc/fs_fwd.hpp rename to src/bb/image-io/ghc/fs_fwd.hpp diff --git a/include/ion-bb-image-io/ghc/fs_impl.hpp b/src/bb/image-io/ghc/fs_impl.hpp similarity index 100% rename from include/ion-bb-image-io/ghc/fs_impl.hpp rename to src/bb/image-io/ghc/fs_impl.hpp diff --git a/include/ion-bb-image-io/ghc/fs_std.hpp b/src/bb/image-io/ghc/fs_std.hpp similarity index 100% rename from include/ion-bb-image-io/ghc/fs_std.hpp rename to src/bb/image-io/ghc/fs_std.hpp diff --git a/include/ion-bb-image-io/ghc/fs_std_fwd.hpp b/src/bb/image-io/ghc/fs_std_fwd.hpp similarity index 100% rename from include/ion-bb-image-io/ghc/fs_std_fwd.hpp rename to src/bb/image-io/ghc/fs_std_fwd.hpp diff --git a/include/ion-bb-image-io/ghc/fs_std_impl.hpp b/src/bb/image-io/ghc/fs_std_impl.hpp similarity index 100% rename from include/ion-bb-image-io/ghc/fs_std_impl.hpp rename to src/bb/image-io/ghc/fs_std_impl.hpp diff --git a/include/ion-bb-image-io/httplib.h b/src/bb/image-io/httplib.h similarity index 100% rename from include/ion-bb-image-io/httplib.h rename to src/bb/image-io/httplib.h diff --git a/include/ion-bb-image-io/nlohmann/json.hpp b/src/bb/image-io/nlohmann/json.hpp similarity index 100% rename from include/ion-bb-image-io/nlohmann/json.hpp rename to src/bb/image-io/nlohmann/json.hpp diff --git a/include/ion-bb-image-io/nlohmann/json_fwd.hpp b/src/bb/image-io/nlohmann/json_fwd.hpp similarity index 100% rename from include/ion-bb-image-io/nlohmann/json_fwd.hpp rename to src/bb/image-io/nlohmann/json_fwd.hpp diff --git a/include/ion-bb-image-io/rt.h b/src/bb/image-io/rt.h similarity index 90% rename from include/ion-bb-image-io/rt.h rename to src/bb/image-io/rt.h index 2ea48dc5..2a6ab3b8 100644 --- a/include/ion-bb-image-io/rt.h +++ b/src/bb/image-io/rt.h @@ -8,7 +8,6 @@ #include -#if defined(ION_ENABLE_JIT_EXTERN) #include namespace ion { namespace bb { @@ -27,9 +26,6 @@ class RegisterExtern { } // bb } // ion #define ION_REGISTER_EXTERN(NAME) static auto ion_register_extern_##NAME = ion::bb::image_io::RegisterExtern(#NAME, NAME); -#else -#define ION_REGISTER_EXTERN(NAME) -#endif #include "rt_u3v.h" #include "rt_file.h" diff --git a/include/ion-bb-image-io/rt_common.h b/src/bb/image-io/rt_common.h similarity index 100% rename from include/ion-bb-image-io/rt_common.h rename to src/bb/image-io/rt_common.h diff --git a/include/ion-bb-image-io/rt_display.h b/src/bb/image-io/rt_display.h similarity index 100% rename from include/ion-bb-image-io/rt_display.h rename to src/bb/image-io/rt_display.h diff --git a/include/ion-bb-image-io/rt_file.h b/src/bb/image-io/rt_file.h similarity index 100% rename from include/ion-bb-image-io/rt_file.h rename to src/bb/image-io/rt_file.h diff --git a/include/ion-bb-image-io/rt_realsense.h b/src/bb/image-io/rt_realsense.h similarity index 100% rename from include/ion-bb-image-io/rt_realsense.h rename to src/bb/image-io/rt_realsense.h diff --git a/include/ion-bb-image-io/rt_u3v.h b/src/bb/image-io/rt_u3v.h similarity index 100% rename from include/ion-bb-image-io/rt_u3v.h rename to src/bb/image-io/rt_u3v.h diff --git a/include/ion-bb-image-io/rt_v4l2.h b/src/bb/image-io/rt_v4l2.h similarity index 100% rename from include/ion-bb-image-io/rt_v4l2.h rename to src/bb/image-io/rt_v4l2.h diff --git a/include/ion-bb-image-io/sole.hpp b/src/bb/image-io/sole.hpp similarity index 100% rename from include/ion-bb-image-io/sole.hpp rename to src/bb/image-io/sole.hpp diff --git a/include/ion-bb-image-io/thirdparty_notice.txt b/src/bb/image-io/thirdparty_notice.txt similarity index 100% rename from include/ion-bb-image-io/thirdparty_notice.txt rename to src/bb/image-io/thirdparty_notice.txt diff --git a/include/ion-bb-image-io/zip_file.hpp b/src/bb/image-io/zip_file.hpp similarity index 100% rename from include/ion-bb-image-io/zip_file.hpp rename to src/bb/image-io/zip_file.hpp diff --git a/include/ion-bb-image-processing/Dockerfile b/src/bb/image-processing/Dockerfile similarity index 100% rename from include/ion-bb-image-processing/Dockerfile rename to src/bb/image-processing/Dockerfile diff --git a/include/ion-bb-image-processing/README.en.md b/src/bb/image-processing/README.en.md similarity index 100% rename from include/ion-bb-image-processing/README.en.md rename to src/bb/image-processing/README.en.md diff --git a/include/ion-bb-image-processing/README.ja.md b/src/bb/image-processing/README.ja.md similarity index 100% rename from include/ion-bb-image-processing/README.ja.md rename to src/bb/image-processing/README.ja.md diff --git a/include/ion-bb-image-processing/bb.h b/src/bb/image-processing/bb.h similarity index 100% rename from include/ion-bb-image-processing/bb.h rename to src/bb/image-processing/bb.h diff --git a/include/ion-bb-core/config.cmake b/src/bb/image-processing/config.cmake similarity index 100% rename from include/ion-bb-core/config.cmake rename to src/bb/image-processing/config.cmake diff --git a/include/ion-bb-image-processing/rt.h b/src/bb/image-processing/rt.h similarity index 100% rename from include/ion-bb-image-processing/rt.h rename to src/bb/image-processing/rt.h diff --git a/include/ion-bb-opencv/bb.h b/src/bb/opencv/bb.h similarity index 100% rename from include/ion-bb-opencv/bb.h rename to src/bb/opencv/bb.h diff --git a/include/ion-bb-opencv/config.cmake b/src/bb/opencv/config.cmake similarity index 100% rename from include/ion-bb-opencv/config.cmake rename to src/bb/opencv/config.cmake diff --git a/include/ion-bb-opencv/rt.h b/src/bb/opencv/rt.h similarity index 96% rename from include/ion-bb-opencv/rt.h rename to src/bb/opencv/rt.h index a9acc49b..b5067041 100644 --- a/include/ion-bb-opencv/rt.h +++ b/src/bb/opencv/rt.h @@ -12,7 +12,6 @@ #define ION_EXPORT #endif -#if defined(ION_ENABLE_JIT_EXTERN) #include namespace ion { namespace bb { @@ -31,9 +30,6 @@ class RegisterExtern { } // bb } // ion #define ION_REGISTER_EXTERN(NAME) static auto ion_register_extern_##NAME = ion::bb::opencv::RegisterExtern(#NAME, NAME); -#else -#define ION_REGISTER_EXTERN(NAME) -#endif namespace { int hl2cv_type(halide_type_t hl_type, int channel) { diff --git a/include/ion-bb-sgm/Dockerfile b/src/bb/sgm/Dockerfile similarity index 100% rename from include/ion-bb-sgm/Dockerfile rename to src/bb/sgm/Dockerfile diff --git a/include/ion-bb-sgm/README.en.md b/src/bb/sgm/README.en.md similarity index 100% rename from include/ion-bb-sgm/README.en.md rename to src/bb/sgm/README.en.md diff --git a/include/ion-bb-sgm/README.ja.md b/src/bb/sgm/README.ja.md similarity index 100% rename from include/ion-bb-sgm/README.ja.md rename to src/bb/sgm/README.ja.md diff --git a/include/ion-bb-sgm/bb.h b/src/bb/sgm/bb.h similarity index 100% rename from include/ion-bb-sgm/bb.h rename to src/bb/sgm/bb.h diff --git a/include/ion-bb-image-processing/config.cmake b/src/bb/sgm/config.cmake similarity index 100% rename from include/ion-bb-image-processing/config.cmake rename to src/bb/sgm/config.cmake diff --git a/include/ion-bb-sgm/rt.h b/src/bb/sgm/rt.h similarity index 100% rename from include/ion-bb-sgm/rt.h rename to src/bb/sgm/rt.h diff --git a/src/builder.cc b/src/core/builder.cc similarity index 100% rename from src/builder.cc rename to src/core/builder.cc diff --git a/src/c_ion.cc b/src/core/c_ion.cc similarity index 100% rename from src/c_ion.cc rename to src/core/c_ion.cc diff --git a/src/dynamic_module.h b/src/core/dynamic_module.h similarity index 93% rename from src/dynamic_module.h rename to src/core/dynamic_module.h index 2cf8523a..663c7566 100644 --- a/src/dynamic_module.h +++ b/src/core/dynamic_module.h @@ -1,6 +1,8 @@ #ifndef ION_DYNAMIC_MODULE_H #define ION_DYNAMIC_MODULE_H +#include + #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include @@ -21,12 +23,14 @@ class DynamicModule { using Handle = void*; #endif - DynamicModule(const std::string& module_path) { + DynamicModule(const std::string& module_name_or_path) { if (module_path == "") { handle_ = nullptr; return; } + // TODO: WIP: test moduel_name_or_path using std::filesystem + #ifdef _WIN32 handle_ = LoadLibraryA(module_path.c_str()); if (handle_ == nullptr) { diff --git a/src/generator.cc b/src/core/generator.cc similarity index 100% rename from src/generator.cc rename to src/core/generator.cc diff --git a/src/metadata.cc b/src/core/metadata.cc similarity index 100% rename from src/metadata.cc rename to src/core/metadata.cc diff --git a/src/metadata.h b/src/core/metadata.h similarity index 100% rename from src/metadata.h rename to src/core/metadata.h diff --git a/src/node.cc b/src/core/node.cc similarity index 100% rename from src/node.cc rename to src/core/node.cc diff --git a/src/param.cc b/src/core/param.cc similarity index 100% rename from src/param.cc rename to src/core/param.cc diff --git a/src/port.cc b/src/core/port.cc similarity index 100% rename from src/port.cc rename to src/core/port.cc diff --git a/src/sole.hpp b/src/core/sole.hpp similarity index 100% rename from src/sole.hpp rename to src/core/sole.hpp diff --git a/src/util.cc b/src/core/util.cc similarity index 100% rename from src/util.cc rename to src/core/util.cc diff --git a/test/direct-extern.cc b/test/direct-extern.cc index 4e5fff7c..e692e7cc 100644 --- a/test/direct-extern.cc +++ b/test/direct-extern.cc @@ -1,10 +1,5 @@ #include "ion/ion.h" -#include "ion-bb-internal/bb.h" - -#include "test-bb.h" -#include "test-rt.h" - using namespace ion; int main() @@ -18,6 +13,8 @@ int main() Builder b; b.set_target(Halide::get_host_target().with_feature(Halide::Target::Profile)); // CPU + b.with_bb_module("ion-bb"); + b.with_bb_module("ion-bb-test"); Node n; Port ip{"input", Halide::type_of(), 2}; diff --git a/test/metadata.cc b/test/metadata.cc index ff8c10e3..43b48855 100644 --- a/test/metadata.cc +++ b/test/metadata.cc @@ -2,19 +2,6 @@ #include "ion/ion.h" -#include "ion-bb-core/bb.h" -#include "ion-bb-dnn/bb.h" -#ifdef HALIDE_FOR_FPGA -#include "ion-bb-fpga/bb.h" -#endif -#ifndef _WIN32 -#include "ion-bb-image-io/bb.h" -#endif -#include "ion-bb-image-processing/bb.h" -#include "ion-bb-internal/bb.h" -#include "ion-bb-opencv/bb.h" -#include "ion-bb-sgm/bb.h" - using namespace ion; int main() From c2292b122704f35f735dea4505027cf5ce593bbe Mon Sep 17 00:00:00 2001 From: Takuro Iizuka Date: Fri, 27 Oct 2023 00:12:31 -0700 Subject: [PATCH 02/17] WIP --- cmake/IonUtil.cmake | 8 ++++---- script/invoke.sh | 2 ++ src/bb/CMakeLists.txt | 2 +- src/bb/image-processing/rt.h | 2 -- src/core/dynamic_module.h | 24 ++++++++++++++---------- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/cmake/IonUtil.cmake b/cmake/IonUtil.cmake index 7e696f8c..4f01c10b 100644 --- a/cmake/IonUtil.cmake +++ b/cmake/IonUtil.cmake @@ -50,16 +50,16 @@ function(ion_run NAME COMPILE_NAME) add_custom_command(OUTPUT ${HEADER} ${STATIC_LIB} COMMAND ${CMAKE_SOURCE_DIR}/script/invoke.sh $ HL_TARGET ${IER_TARGET_STRING} - LD_LIBRARY_PATH ${HALIDE_ROOT}/bin - LD_LIBRARY_PATH ${CMAKE_BINARY_DIR}/$<$:Release>$<$:Debug> + LD_LIBRARY_PATH ${Halide_DIR}/../../../bin + 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 $ HL_TARGET ${IER_TARGET_STRING} - PATH ${HALIDE_ROOT}/$<$:Release>$<$:Debug> - PATH ${CMAKE_BINARY_DIR}/$<$:Release>$<$:Debug> + PATH ${Halide_DIR}/../../../$<$:Release>$<$:Debug> + PATH ${CMAKE_BINARY_DIR}/src/bb/$<$:Release>$<$:Debug> DEPENDS ${COMPILE_NAME} ${OUTPUT_PATH} WORKING_DIRECTORY ${OUTPUT_PATH}) endif() diff --git a/script/invoke.sh b/script/invoke.sh index 5f4195e6..0f497b3f 100755 --- a/script/invoke.sh +++ b/script/invoke.sh @@ -16,8 +16,10 @@ do eval set envval=\${${envname}} if [ "${envval}" == "" ]; then eval export ${envname}=${envvar} + echo ${envname}=${envvar} else eval export ${envname}=${envvar}:\${${envname}} + echo ${envname}=${envvar} fi done diff --git a/src/bb/CMakeLists.txt b/src/bb/CMakeLists.txt index aaa3eb5d..6fb8ba57 100644 --- a/src/bb/CMakeLists.txt +++ b/src/bb/CMakeLists.txt @@ -23,7 +23,7 @@ foreach(child ${childs}) list(APPEND ION_BB_LINK_DIRS ${LINK_DIRS}) list(APPEND ION_BB_LIBRARIES ${LIBRARIES}) string(TOUPPER ${BB_NAME} POSTFIX) - string(REPLACE "-" "_" ${POSTFIX} POSTFIX) + string(REPLACE "-" "_" POSTFIX ${POSTFIX}) add_definitions("-DION_ENABLE_BB_${POSTFIX}") endif() endif() diff --git a/src/bb/image-processing/rt.h b/src/bb/image-processing/rt.h index 617d0f7e..6739a8ce 100644 --- a/src/bb/image-processing/rt.h +++ b/src/bb/image-processing/rt.h @@ -1,7 +1,6 @@ // Don't use this file. // You can add only BB written by pure Halide function to ion-bb-image-processing. -#if defined(ION_ENABLE_JIT_EXTERN) #include namespace ion { @@ -20,4 +19,3 @@ class RegisterExtern { } // image_io } // bb } // ion -#endif diff --git a/src/core/dynamic_module.h b/src/core/dynamic_module.h index 663c7566..f8ba59ef 100644 --- a/src/core/dynamic_module.h +++ b/src/core/dynamic_module.h @@ -6,12 +6,14 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include +#define ION_DYNAMIC_MODULE_PREFIX "" +#define ION_DYNAMIC_MODULE_EXT ".dll" #else #include +#define ION_DYNAMIC_MODULE_PREFIX "lib" +#define ION_DYNAMIC_MODULE_EXT ".so" #endif -namespace {} - namespace ion { class DynamicModule { @@ -24,20 +26,27 @@ class DynamicModule { #endif DynamicModule(const std::string& module_name_or_path) { - if (module_path == "") { + if (module_name_or_path == "") { handle_ = nullptr; return; } + std::string target; + if (std::filesystem::exists(module_name_or_path)) { + target = module_name_or_path; + } else { + target = std::string(ION_DYNAMIC_MODULE_PREFIX) + module_name_or_path + std::string(ION_DYNAMIC_MODULE_EXT); + } + // TODO: WIP: test moduel_name_or_path using std::filesystem #ifdef _WIN32 - handle_ = LoadLibraryA(module_path.c_str()); + handle_ = LoadLibraryA(target.c_str()); if (handle_ == nullptr) { throw std::runtime_error(getErrorString()); } #else - handle_ = dlopen(module_path.c_str(), RTLD_NOW); + handle_ = dlopen(target.c_str(), RTLD_NOW); if (handle_ == nullptr) { throw std::runtime_error(getErrorString()); } @@ -48,11 +57,6 @@ class DynamicModule { if (handle_ != nullptr) { // NOTE: DSO which is loaded by with_bb_module should not be unloaded even if Builder is destructed. // Loading more than twice does not have any side effects. -#ifdef _WIN32 -// FreeLibrary(handle_); -#else -// dlclose(handle_); -#endif } } From 4949a5264ec58e7fbe30ef575894f91d7e07a775 Mon Sep 17 00:00:00 2001 From: Takuro Iizuka Date: Sun, 29 Oct 2023 08:36:19 -0700 Subject: [PATCH 03/17] Reorganized structure --- cmake/IonUtil.cmake | 6 +- example/CMakeLists.txt | 1 + example/demo.cc | 10 +- example/demo_compile.cc | 10 +- example/demo_run.cc | 12 +- example/dnn.cc | 6 +- example/dnn_compile.cc | 6 +- example/dnn_fpga.cc | 6 +- example/dnn_fpga_compile.cc | 4 +- example/dnn_run.cc | 10 +- example/fpga_isp_compile.cc | 2 +- example/gender_count.cc | 8 +- example/imx219_isp_display.cc | 2 +- example/isp.cc | 4 +- example/isp_and_sgm.cc | 12 +- example/producerx3_compile.cc | 8 +- example/sgm_compile.cc | 12 +- example/sgm_run.cc | 11 +- example/u3v.cc | 4 +- script/invoke.sh | 7 +- src/bb/CMakeLists.txt | 2 - src/bb/base/bb.h | 482 +++++++++++++++++++--------------- src/bb/base/rt.h | 6 +- 23 files changed, 348 insertions(+), 283 deletions(-) diff --git a/cmake/IonUtil.cmake b/cmake/IonUtil.cmake index 4f01c10b..f66b85d0 100644 --- a/cmake/IonUtil.cmake +++ b/cmake/IonUtil.cmake @@ -25,6 +25,7 @@ function(ion_compile NAME) 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) @@ -65,9 +66,10 @@ function(ion_run NAME COMPILE_NAME) 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 $ ${IER_RUNTIME_ARGS}) endfunction() diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 0ed85fd8..0435ec31 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -54,3 +54,4 @@ if (MSVC) add_definitions(/bigobj) message(STATUS "Allow big object for example/") endif (MSVC) + diff --git a/example/demo.cc b/example/demo.cc index b884f1db..7150cf97 100644 --- a/example/demo.cc +++ b/example/demo.cc @@ -121,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"]); @@ -137,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)})( @@ -149,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)})( @@ -184,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"); diff --git a/example/demo_compile.cc b/example/demo_compile.cc index c048cd7c..b55c3ed0 100644 --- a/example/demo_compile.cc +++ b/example/demo_compile.cc @@ -117,13 +117,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"]); @@ -133,7 +133,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)})( @@ -145,7 +145,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)})( @@ -180,7 +180,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"); diff --git a/example/demo_run.cc b/example/demo_run.cc index c0014221..c94be87b 100644 --- a/example/demo_run.cc +++ b/example/demo_run.cc @@ -1,11 +1,13 @@ -#include "demo.h" - -#include - #include #include -using namespace ion; +#include +#include +#include + +#include + +#include "demo.h" int main() { try { diff --git a/example/dnn.cc b/example/dnn.cc index 68f7a275..26892035 100644 --- a/example/dnn.cc +++ b/example/dnn.cc @@ -19,10 +19,10 @@ int main(int argc, char *argv[]) { Node n; n = b.add("image_io_color_data_loader").set_param(Param{"url", "http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}, Param{"width", std::to_string(width)}, Param{"height", std::to_string(height)}); - n = b.add("core_normalize_3d_uint8")(n["output"]); - n = b.add("core_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC + n = b.add("base_normalize_3d_uint8")(n["output"]); + n = b.add("base_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC n = b.add("dnn_object_detection")(n["output"]); - n = b.add("core_denormalize_3d_uint8")(n["output"]); + n = b.add("base_denormalize_3d_uint8")(n["output"]); Halide::Buffer out_buf(channel, width, height); diff --git a/example/dnn_compile.cc b/example/dnn_compile.cc index 61a03e0c..50a57e62 100644 --- a/example/dnn_compile.cc +++ b/example/dnn_compile.cc @@ -14,10 +14,10 @@ int main(int argc, char *argv[]) { Node n; n = b.add("image_io_color_data_loader").set_param(Param{"url", "http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}, Param{"width", std::to_string(input_width)}, Param{"height", std::to_string(input_height)}); - n = b.add("core_normalize_3d_uint8")(n["output"]); - n = b.add("core_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC + n = b.add("base_normalize_3d_uint8")(n["output"]); + n = b.add("base_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC n = b.add("dnn_object_detection")(n["output"]); - n = b.add("core_denormalize_3d_uint8")(n["output"]); + n = b.add("base_denormalize_3d_uint8")(n["output"]); b.compile("dnn"); } catch (const std::exception &e) { diff --git a/example/dnn_fpga.cc b/example/dnn_fpga.cc index 63b33391..6fac3a40 100644 --- a/example/dnn_fpga.cc +++ b/example/dnn_fpga.cc @@ -22,10 +22,10 @@ int main(int argc, char *argv[]) { Node n; n = b.add("image_io_color_data_loader").set_param(Param{"url", "http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}); - n = b.add("core_normalize_3d_uint8")(n["output"]); - n = b.add("core_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC + n = b.add("base_normalize_3d_uint8")(n["output"]); + n = b.add("base_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC n = b.add("dnn_object_detection")(n["output"]); - n = b.add("core_denormalize_3d_uint8")(n["output"]); + n = b.add("base_denormalize_3d_uint8")(n["output"]); Halide::Buffer out_buf(channel, width, height); diff --git a/example/dnn_fpga_compile.cc b/example/dnn_fpga_compile.cc index ae7e055b..957b945b 100644 --- a/example/dnn_fpga_compile.cc +++ b/example/dnn_fpga_compile.cc @@ -24,9 +24,9 @@ int main(int argc, char *argv[]) { Param{"width", "512"}, Param{"height", "512"} )(n["output"]); - n = b.add("core_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC + n = b.add("base_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC n = b.add("dnn_object_detection")(n["output"]); - n = b.add("core_denormalize_3d_uint8")(n["output"]); + n = b.add("base_denormalize_3d_uint8")(n["output"]); b.compile("dnn_fpga"); } catch (const std::exception &e) { diff --git a/example/dnn_run.cc b/example/dnn_run.cc index 9eed39a9..365e674a 100644 --- a/example/dnn_run.cc +++ b/example/dnn_run.cc @@ -1,10 +1,12 @@ -#include "dnn.h" +#include -#include +#include +#include +#include -#include +#include -using namespace ion; +#include "dnn.h" int main(int argc, char *argv[]) { try { diff --git a/example/fpga_isp_compile.cc b/example/fpga_isp_compile.cc index a7bd2084..4f06fe16 100644 --- a/example/fpga_isp_compile.cc +++ b/example/fpga_isp_compile.cc @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) { Param{"unroll_level", "3"})( downscale["output"]); - Node reorder = b.add("core_reorder_buffer_3d_uint8") + Node reorder = b.add("base_reorder_buffer_3d_uint8") .set_param( Param{"dim0", "1"}, Param{"dim1", "2"}, diff --git a/example/gender_count.cc b/example/gender_count.cc index bd3dc9c6..24aa0a1d 100644 --- a/example/gender_count.cc +++ b/example/gender_count.cc @@ -24,13 +24,13 @@ int main(int argc, char *argv[]) { Node n; n = b.add("image_io_camera").set_param(wparam, hparam); - n = b.add("core_normalize_3d_uint8")(n["output"]); - n = b.add("core_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC + n = b.add("base_normalize_3d_uint8")(n["output"]); + n = b.add("base_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC auto img = n["output"]; n = b.add("dnn_tlt_peoplenet")(img); - n = b.add("core_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "1"}, Param{"dim1", "2"}, Param{"dim2", "0"}); // HWC -> CHW - n = b.add("core_denormalize_3d_uint8")(n["output"]); + n = b.add("base_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "1"}, Param{"dim1", "2"}, Param{"dim2", "0"}); // HWC -> CHW + n = b.add("base_denormalize_3d_uint8")(n["output"]); n = b.add("image_io_gui_display")(n["output"]).set_param(wparam, hparam); Port out_p1 = n["output"]; diff --git a/example/imx219_isp_display.cc b/example/imx219_isp_display.cc index f538cc43..82d63e61 100644 --- a/example/imx219_isp_display.cc +++ b/example/imx219_isp_display.cc @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) { } n = b.add("image_processing_tile_image_horizontal_3d_float")(ns[0]["output"], ns[1]["output"]).set_param(Param{"input0_width", std::to_string(quad_width_v)}, Param{"input0_height", std::to_string(quad_height_v)}, Param{"input1_width", std::to_string(quad_width_v)}, Param{"input1_height", std::to_string(quad_height_v)}); - n = b.add("core_denormalize_3d_uint8")(n["output"]); + n = b.add("base_denormalize_3d_uint8")(n["output"]); n = b.add("image_io_gui_display")(n["output"]).set_param(Param{"width", std::to_string(half_width_v)}, Param{"height", std::to_string(quad_height_v)}); PortMap pm; diff --git a/example/isp.cc b/example/isp.cc index a862c539..81bfd798 100644 --- a/example/isp.cc +++ b/example/isp.cc @@ -157,7 +157,7 @@ int main(int argc, char *argv[]) { .set_param( Param{"luminance_method", "Average"})( demosaic["output"]); - luminance_filter = b.add("core_constant_buffer_2d_float") + luminance_filter = b.add("base_constant_buffer_2d_float") .set_param( Param{"values", "0.04"}, Param{"extent0", "5"}, @@ -180,7 +180,7 @@ int main(int argc, char *argv[]) { coef_space, filtered_luminance["output"], demosaic["output"]); - color_matrix = b.add("core_constant_buffer_2d_float") + color_matrix = b.add("base_constant_buffer_2d_float") .set_param( Param{"values", "2.20213000 -1.27425000 0.07212000 " "-0.25650000 1.45961000 -0.20311000 " diff --git a/example/isp_and_sgm.cc b/example/isp_and_sgm.cc index b43fccce..dfa356b9 100644 --- a/example/isp_and_sgm.cc +++ b/example/isp_and_sgm.cc @@ -207,7 +207,7 @@ int main(int argc, char *argv[]) { .set_param( Param{"luminance_method", "Average"})( demosaic_l["output"]); - luminance_filter_l = b.add("core_constant_buffer_2d_float") + luminance_filter_l = b.add("base_constant_buffer_2d_float") .set_param( Param{"values", "0.04"}, Param{"extent0", "5"}, @@ -230,7 +230,7 @@ int main(int argc, char *argv[]) { coef_space_l, filtered_luminance_l["output"], demosaic_l["output"]); - color_matrix_l = b.add("core_constant_buffer_2d_float") + color_matrix_l = b.add("base_constant_buffer_2d_float") .set_param( Param{"values", "1.5 -0.25 -0.25 " "-0.25 1.5 -0.25 " @@ -316,7 +316,7 @@ int main(int argc, char *argv[]) { .set_param( Param{"luminance_method", "Average"})( demosaic_r["output"]); - luminance_filter_r = b.add("core_constant_buffer_2d_float") + luminance_filter_r = b.add("base_constant_buffer_2d_float") .set_param( Param{"values", "0.04"}, Param{"extent0", "5"}, @@ -339,7 +339,7 @@ int main(int argc, char *argv[]) { coef_space_r, filtered_luminance_r["output"], demosaic_r["output"]); - color_matrix_r = b.add("core_constant_buffer_2d_float") + color_matrix_r = b.add("base_constant_buffer_2d_float") .set_param( Param{"values", "1.5 -0.25 -0.25 " "-0.25 1.5 -0.25 " @@ -378,10 +378,10 @@ int main(int argc, char *argv[]) { gamma_r, final_luminance_r["output"]); - Node ln = b.add("core_denormalize_2d_uint8")(gamma_correction_l["output"]); + Node ln = b.add("base_denormalize_2d_uint8")(gamma_correction_l["output"]); ln = b.add("sgm_census")(ln["output"]).set_param(Param{"width", std::to_string(output_width)}, Param{"height", std::to_string(output_height)}); - Node rn = b.add("core_denormalize_2d_uint8")(gamma_correction_r["output"]); + Node rn = b.add("base_denormalize_2d_uint8")(gamma_correction_r["output"]); rn = b.add("sgm_census")(rn["output"]).set_param(Param{"width", std::to_string(output_width)}, Param{"height", std::to_string(output_height)}); Node n = b.add("sgm_matching_cost")(ln["output"], rn["output"]).set_param(Param{"width", std::to_string(output_width)}, Param{"height", std::to_string(output_height)}); diff --git a/example/producerx3_compile.cc b/example/producerx3_compile.cc index f0934a2b..4271b859 100644 --- a/example/producerx3_compile.cc +++ b/example/producerx3_compile.cc @@ -11,10 +11,10 @@ int main() { b.set_target(Halide::get_target_from_environment()); b.with_bb_module("ion-bb"); - Node n = b.add("core_scalar_to_func_uint8")(input); - n = b.add("core_extend_dimension_0d_uint8")(n["output"]); - n = b.add("core_extend_dimension_1d_uint8")(n["output"]); - n = b.add("core_extend_dimension_2d_uint8")(n["output"]); + Node n = b.add("base_scalar_to_func_uint8")(input); + n = b.add("base_extend_dimension_0d_uint8")(n["output"]); + n = b.add("base_extend_dimension_1d_uint8")(n["output"]); + n = b.add("base_extend_dimension_2d_uint8")(n["output"]); b.compile("producerx3"); } catch (const std::exception &e) { diff --git a/example/sgm_compile.cc b/example/sgm_compile.cc index 31a972f1..c0d6b4d6 100644 --- a/example/sgm_compile.cc +++ b/example/sgm_compile.cc @@ -16,18 +16,18 @@ int main() { b.with_bb_module("ion-bb"); Node ln = b.add("image_io_color_data_loader").set_param(Param{"url", "http://ion-kit.s3.us-west-2.amazonaws.com/images/aloe_left.jpg"}, Param{"width", std::to_string(input_width)}, Param{"height", std::to_string(input_height)}); - ln = b.add("core_normalize_3d_uint8")(ln["output"]); + ln = b.add("base_normalize_3d_uint8")(ln["output"]); ln = b.add("image_processing_resize_nearest_3d")(ln["output"]).set_param(Param{"width", std::to_string(input_width)}, Param{"height", std::to_string(input_height)}, Param{"scale", std::to_string(scale)}); - ln = b.add("internal_schedule")(ln["output"]).set_param(Param{"output_name", "scaled_left"}, Param{"compute_level", "compute_root"}); + ln = b.add("base_schedule")(ln["output"]).set_param(Param{"output_name", "scaled_left"}, Param{"compute_level", "compute_root"}); ln = b.add("image_processing_calc_luminance")(ln["output"]).set_param(Param{"luminance_method", "Average"}); - ln = b.add("core_denormalize_2d_uint8")(ln["output"]); + ln = b.add("base_denormalize_2d_uint8")(ln["output"]); Node rn = b.add("image_io_color_data_loader").set_param(Param{"url", "http://ion-kit.s3.us-west-2.amazonaws.com/images/aloe_right.jpg"}, Param{"width", std::to_string(input_width)}, Param{"height", std::to_string(input_height)}); - rn = b.add("core_normalize_3d_uint8")(rn["output"]); + rn = b.add("base_normalize_3d_uint8")(rn["output"]); rn = b.add("image_processing_resize_nearest_3d")(rn["output"]).set_param(Param{"width", std::to_string(input_width)}, Param{"height", std::to_string(input_height)}, Param{"scale", std::to_string(scale)}); - rn = b.add("internal_schedule")(rn["output"]).set_param(Param{"output_name", "scaled_right"}, Param{"compute_level", "compute_root"}); + rn = b.add("base_schedule")(rn["output"]).set_param(Param{"output_name", "scaled_right"}, Param{"compute_level", "compute_root"}); rn = b.add("image_processing_calc_luminance")(rn["output"]).set_param(Param{"luminance_method", "Average"}); - rn = b.add("core_denormalize_2d_uint8")(rn["output"]); + rn = b.add("base_denormalize_2d_uint8")(rn["output"]); Node n = b.add("sgm_sgm")(ln["output"], rn["output"]).set_param(Param{"disp", std::to_string(disp)}, Param{"width", std::to_string(output_width)}, Param{"height", std::to_string(output_height)}); diff --git a/example/sgm_run.cc b/example/sgm_run.cc index ae509603..f57cafab 100644 --- a/example/sgm_run.cc +++ b/example/sgm_run.cc @@ -1,10 +1,13 @@ -#include "sgm.h" +#include +#include -#include +#include +#include +#include -#include +#include -// using namespace ion; +#include "sgm.h" int main() { try { diff --git a/example/u3v.cc b/example/u3v.cc index a22b3ef8..140ab2d8 100644 --- a/example/u3v.cc +++ b/example/u3v.cc @@ -71,7 +71,7 @@ void display_and_save(int32_t width, int32_t height, std::string directory_path, Param{"height", std::to_string(height)}, Param{"scale", std::to_string(2.0f)} ); - n = b.add("core_denormalize_3d_uint8")(n["output"]); + n = b.add("base_denormalize_3d_uint8")(n["output"]); n = b.add("image_processing_crop_image_3d_uint8")(n["output"]).set_param( Param{"input_width", std::to_string(width)}, Param{"input_height", std::to_string(height)}, @@ -93,7 +93,7 @@ void display_and_save(int32_t width, int32_t height, std::string directory_path, Param{"height", std::to_string(height)}, Param{"scale", std::to_string(2.0f)} ); - n = b.add("core_denormalize_3d_uint8")(n["output"]); + n = b.add("base_denormalize_3d_uint8")(n["output"]); n = b.add("image_processing_crop_image_3d_uint8")(n["output"]).set_param( Param{"input_width", std::to_string(width)}, Param{"input_height", std::to_string(height)}, diff --git a/script/invoke.sh b/script/invoke.sh index 0f497b3f..0765071f 100755 --- a/script/invoke.sh +++ b/script/invoke.sh @@ -13,13 +13,14 @@ do envvar=${1} shift - eval set envval=\${${envname}} + eval envval=\${${envname}} + if [ "${envval}" == "" ]; then eval export ${envname}=${envvar} - echo ${envname}=${envvar} + eval echo ${envname}=${envvar} else eval export ${envname}=${envvar}:\${${envname}} - echo ${envname}=${envvar} + eval echo ${envname}=${envvar}:\${${envname}} fi done diff --git a/src/bb/CMakeLists.txt b/src/bb/CMakeLists.txt index 6fb8ba57..f2c035bf 100644 --- a/src/bb/CMakeLists.txt +++ b/src/bb/CMakeLists.txt @@ -32,7 +32,6 @@ endforeach() add_library(ion-bb SHARED bb.cc) target_include_directories(ion-bb PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${ION_BB_INCLUDE_DIRS}) target_link_libraries(ion-bb PUBLIC ion-core ${ION_BB_LIBRARIES}) -message("${ION_BB_INCLUDE_DIRS}") if(UNIX) target_compile_options(ion-bb PUBLIC -fno-rtti # For Halide::Generator @@ -49,4 +48,3 @@ else() install(FILES ${CMAKE_BINARY_DIR}/$<$:Release>$<$:Debug>/ion-bb.dll DESTINATION bin) install(FILES ${CMAKE_BINARY_DIR}/$<$:Release>$<$:Debug>/ion-bb.lib DESTINATION lib) endif() - diff --git a/src/bb/base/bb.h b/src/bb/base/bb.h index 0a674e6e..dd61bc52 100644 --- a/src/bb/base/bb.h +++ b/src/bb/base/bb.h @@ -1,5 +1,5 @@ -#ifndef ION_BB_CORE_BB_H -#define ION_BB_CORE_BB_H +#ifndef ION_BB_BASE_BB_H +#define ION_BB_BASE_BB_H #include @@ -1955,218 +1955,274 @@ class ScalarToFuncFloat : public ScalarToFunc { // GeneratorParam gc_title{"gc_title", "ScalarToFuncFloat"}; }; -} // namespace core +class Schedule : public ion::BuildingBlock { +public: + GeneratorParam output_name{"output_name", ""}; + GeneratorParam compute_level{"compute_level", ""}; // "compute_inline" or "compute_root" + GeneratorParam concurrency{"concurrency", ""}; // comma separated string + + GeneratorInput input{"input"}; + GeneratorOutput output{"output"}; + + void generate() { + using namespace Halide; + if (static_cast(compute_level) == "compute_inline") { + output = input; + } else if (static_cast(compute_level) == "compute_root") { + Func f(static_cast(output_name)); + f(_) = input(_); + f.compute_root(); + if (get_target().has_gpu_feature()) { + if (f.args().size() == 0) { + // NOP + } else if (f.args().size() == 1) { + Var i = f.args()[0]; + Var block, thread; + f.split(i, block, thread, 64); + f.gpu_blocks(block).gpu_threads(thread); + } else { + Var x = f.args()[0]; + Var y = f.args()[1]; + for (int i=2; i #include @@ -31,7 +31,7 @@ class RegisterExtern { } }; -} // image_io +} // base } // bb } // ion #define ION_REGISTER_EXTERN(NAME) static auto ion_register_extern_##NAME = ion::bb::base::RegisterExtern(#NAME, NAME); From fd9c9145f2e20c873d11fa61e42e50b0069d40bd Mon Sep 17 00:00:00 2001 From: Takuro Iizuka Date: Sun, 29 Oct 2023 08:37:56 -0700 Subject: [PATCH 04/17] Deleted garbage --- bin/x | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 bin/x diff --git a/bin/x b/bin/x deleted file mode 100644 index e69de29b..00000000 From 5fc44e678c847d3a4a67ed1eb72b25d15ea270ed Mon Sep 17 00:00:00 2001 From: Takuro Iizuka Date: Mon, 30 Oct 2023 17:18:37 -0700 Subject: [PATCH 05/17] Adding ion-bb path for testing --- cmake/IonUtil.cmake | 6 + example/isp.cc | 376 +++++++++++++++++++++-------------------- example/isp_and_sgm.cc | 2 +- script/invoke.sh | 3 - 4 files changed, 198 insertions(+), 189 deletions(-) diff --git a/cmake/IonUtil.cmake b/cmake/IonUtil.cmake index f66b85d0..db276442 100644 --- a/cmake/IonUtil.cmake +++ b/cmake/IonUtil.cmake @@ -107,6 +107,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") + else() + set(IERT_RUNTIME_ENVS "PATH=${CMAKE_BINARY_DIR}/src/bb/$<$:Release>$<$:Debug>") + endif() + if (IERT_TARGET_STRING) list(APPEND IERT_RUNTIME_ENVS "HL_TARGET=${IERT_TARGET_STRING}") endif() diff --git a/example/isp.cc b/example/isp.cc index 81bfd798..c103fd2f 100644 --- a/example/isp.cc +++ b/example/isp.cc @@ -36,191 +36,197 @@ void save_image(Halide::Buffer buffer, std::string filename) { } int main(int argc, char *argv[]) { - assert(argc >= 6); - - Builder b; - b.set_target(Halide::get_target_from_environment()); - b.with_bb_module("ion-bb"); - - // Parameters for IMX219 - Port input{"input", Halide::type_of(), 2}; - Port offset_r{"offset_r", Halide::type_of()}; - Port offset_g{"offset_g", Halide::type_of()}; - Port offset_b{"offset_b", Halide::type_of()}; - Port gain_r{"gain_r", Halide::type_of()}; - Port gain_g{"gain_g", Halide::type_of()}; - Port gain_b{"gain_b", Halide::type_of()}; - Port shading_correction_slope_r{"shading_correction_slope_r", Halide::type_of()}; - Port shading_correction_slope_g{"shading_correction_slope_g", Halide::type_of()}; - Port shading_correction_slope_b{"shading_correction_slope_b", Halide::type_of()}; - Port shading_correction_offset_r{"shading_correction_offset_r", Halide::type_of()}; - Port shading_correction_offset_g{"shading_correction_offset_g", Halide::type_of()}; - Port shading_correction_offset_b{"shading_correction_offset_b", Halide::type_of()}; - Port coef_color{"coef_color", Halide::type_of()}; - Port coef_space{"coef_space", Halide::type_of()}; - Port gamma{"gamma", Halide::type_of()}; - Port k1{"k1", Halide::type_of()}; - Port k2{"k2", Halide::type_of()}; - Port k3{"k3", Halide::type_of()}; - Port p1{"p1", Halide::type_of()}; - Port p2{"p2", Halide::type_of()}; - Port fx{"fx", Halide::type_of()}; - Port fy{"fy", Halide::type_of()}; - Port cx{"cx", Halide::type_of()}; - Port cy{"cy", Halide::type_of()}; - Port output_scale{"output_scale", Halide::type_of()}; - Port scale{"scale", Halide::type_of()}; - - int32_t width = 3264; - int32_t height = 2464; - float resize_scale = 0.4f; - - PortMap pm; - pm.set(offset_r, 1.f / 16.f); - pm.set(offset_g, 1.f / 16.f); - pm.set(offset_b, 1.f / 16.f); - pm.set(gain_r, 2.5f); - pm.set(gain_g, 2.0f); - pm.set(gain_b, 3.2f); - pm.set(shading_correction_slope_r, 0.7f); - pm.set(shading_correction_slope_g, 0.2f); - pm.set(shading_correction_slope_b, 0.1f); - pm.set(shading_correction_offset_r, 1.f); - pm.set(shading_correction_offset_g, 1.f); - pm.set(shading_correction_offset_b, 1.f); - pm.set(coef_color, 100.f); - pm.set(coef_space, 0.03); - pm.set(gamma, 1.f / 2.2f); - pm.set(k1, 0.f); - pm.set(k2, 0.f); - pm.set(k3, 0.f); - pm.set(scale, resize_scale); - pm.set(p1, 0.f); - pm.set(p2, 0.f); - pm.set(output_scale, 1.f); - pm.set(fx, static_cast(sqrt(width * width + height * height) / 2)); - pm.set(fy, static_cast(sqrt(width * width + height * height) / 2)); - pm.set(cx, width * 0.5f); - pm.set(cy, height * 0.6f); - - Param bayer_pattern{"bayer_pattern", "RGGB"}; - - Node loader, normalize, offset, shading_correction, white_balance, demosaic, luminance, filtered_luminance, luminance_filter, noise_reduction; - Node color_matrix, color_conversion, gamma_correction, distortion_lut, distortion_correction, resize; - Node debug_output; - - loader = b.add("image_io_grayscale_data_loader") - .set_param( - Param{"width", "3264"}, - Param{"height", "2464"}, - Param{"url", "http://ion-kit.s3.us-west-2.amazonaws.com/images/IMX219-3264x2464-RG10.raw"}); - - normalize = b.add("image_processing_normalize_raw_image") - .set_param( - Param{"bit_width", "10"}, - Param{"bit_shift", "0"})( - loader["output"]); - - offset = b.add("image_processing_bayer_offset") - .set_param( - bayer_pattern)( - offset_r, offset_g, - offset_b, - normalize["output"]); - - shading_correction = b.add("image_processing_lens_shading_correction_linear") - .set_param( - bayer_pattern, - Param{"width", std::to_string(width)}, - Param{"height", std::to_string(height)})( - shading_correction_slope_r, - shading_correction_slope_g, - shading_correction_slope_b, - shading_correction_offset_r, - shading_correction_offset_g, - shading_correction_offset_b, - offset["output"]); - white_balance = b.add("image_processing_bayer_white_balance") - .set_param( - bayer_pattern)( - gain_r, - gain_g, - gain_b, - shading_correction["output"]); - demosaic = b.add("image_processing_bayer_demosaic_filter") - .set_param( - bayer_pattern, - Param{"width", std::to_string(width)}, - Param{"height", std::to_string(height)})( - white_balance["output"]); - luminance = b.add("image_processing_calc_luminance") - .set_param( - Param{"luminance_method", "Average"})( - demosaic["output"]); - luminance_filter = b.add("base_constant_buffer_2d_float") - .set_param( - Param{"values", "0.04"}, - Param{"extent0", "5"}, - Param{"extent1", "5"}); - filtered_luminance = b.add("image_processing_convolution_2d") - .set_param( - Param{"boundary_conditions_method", "MirrorInterior"}, - Param{"window_size", "2"}, - Param{"width", std::to_string(width)}, - Param{"height", std::to_string(height)})( - luminance_filter["output"], - luminance["output"]); - noise_reduction = b.add("image_processing_bilateral_filter_3d") - .set_param( - Param{"color_difference_method", "Average"}, - Param{"window_size", "2"}, - Param{"width", std::to_string(width)}, - Param{"height", std::to_string(height)})( - coef_color, - coef_space, - filtered_luminance["output"], - demosaic["output"]); - color_matrix = b.add("base_constant_buffer_2d_float") - .set_param( - Param{"values", "2.20213000 -1.27425000 0.07212000 " - "-0.25650000 1.45961000 -0.20311000 " - "0.07458000 -1.35791000 2.28333000"}, - Param{"extent0", "3"}, - Param{"extent1", "3"}); - color_conversion = b.add("image_processing_color_matrix")( - color_matrix["output"], - noise_reduction["output"]); - distortion_correction = b.add("image_processing_lens_distortion_correction_model_3d") - .set_param( - Param{"width", std::to_string(width)}, - Param{"height", std::to_string(height)})( - k1, - k2, - k3, - p1, - p2, - fx, - fy, - cx, - cy, - output_scale, - color_conversion["output"]); - resize = b.add("image_processing_resize_area_average_3d") - .set_param( - Param{"width", std::to_string(width)}, - Param{"height", std::to_string(height)}, - Param{"scale", std::to_string(resize_scale)})( - distortion_correction["output"]); - gamma_correction = b.add("image_processing_gamma_correction_3d")( - gamma, - resize["output"]); - - Halide::Buffer obuf(width * resize_scale, height * resize_scale, 3); - pm.set(gamma_correction["output"], obuf); - - b.run(pm); - obuf.copy_to_host(); - save_image(obuf, "output.png"); + try { + Builder b; + b.set_target(Halide::get_target_from_environment()); + b.with_bb_module("ion-bb"); + + // Parameters for IMX219 + Port input{"input", Halide::type_of(), 2}; + Port offset_r{"offset_r", Halide::type_of()}; + Port offset_g{"offset_g", Halide::type_of()}; + Port offset_b{"offset_b", Halide::type_of()}; + Port gain_r{"gain_r", Halide::type_of()}; + Port gain_g{"gain_g", Halide::type_of()}; + Port gain_b{"gain_b", Halide::type_of()}; + Port shading_correction_slope_r{"shading_correction_slope_r", Halide::type_of()}; + Port shading_correction_slope_g{"shading_correction_slope_g", Halide::type_of()}; + Port shading_correction_slope_b{"shading_correction_slope_b", Halide::type_of()}; + Port shading_correction_offset_r{"shading_correction_offset_r", Halide::type_of()}; + Port shading_correction_offset_g{"shading_correction_offset_g", Halide::type_of()}; + Port shading_correction_offset_b{"shading_correction_offset_b", Halide::type_of()}; + Port coef_color{"coef_color", Halide::type_of()}; + Port coef_space{"coef_space", Halide::type_of()}; + Port gamma{"gamma", Halide::type_of()}; + Port k1{"k1", Halide::type_of()}; + Port k2{"k2", Halide::type_of()}; + Port k3{"k3", Halide::type_of()}; + Port p1{"p1", Halide::type_of()}; + Port p2{"p2", Halide::type_of()}; + Port fx{"fx", Halide::type_of()}; + Port fy{"fy", Halide::type_of()}; + Port cx{"cx", Halide::type_of()}; + Port cy{"cy", Halide::type_of()}; + Port output_scale{"output_scale", Halide::type_of()}; + Port scale{"scale", Halide::type_of()}; + + int32_t width = 3264; + int32_t height = 2464; + float resize_scale = 0.4f; + + PortMap pm; + pm.set(offset_r, 1.f / 16.f); + pm.set(offset_g, 1.f / 16.f); + pm.set(offset_b, 1.f / 16.f); + pm.set(gain_r, 2.5f); + pm.set(gain_g, 2.0f); + pm.set(gain_b, 3.2f); + pm.set(shading_correction_slope_r, 0.7f); + pm.set(shading_correction_slope_g, 0.2f); + pm.set(shading_correction_slope_b, 0.1f); + pm.set(shading_correction_offset_r, 1.f); + pm.set(shading_correction_offset_g, 1.f); + pm.set(shading_correction_offset_b, 1.f); + pm.set(coef_color, 100.f); + pm.set(coef_space, 0.03); + pm.set(gamma, 1.f / 2.2f); + pm.set(k1, 0.f); + pm.set(k2, 0.f); + pm.set(k3, 0.f); + pm.set(scale, resize_scale); + pm.set(p1, 0.f); + pm.set(p2, 0.f); + pm.set(output_scale, 1.f); + pm.set(fx, static_cast(sqrt(width * width + height * height) / 2)); + pm.set(fy, static_cast(sqrt(width * width + height * height) / 2)); + pm.set(cx, width * 0.5f); + pm.set(cy, height * 0.6f); + + Param bayer_pattern{"bayer_pattern", "RGGB"}; + + Node loader, normalize, offset, shading_correction, white_balance, demosaic, luminance, filtered_luminance, luminance_filter, noise_reduction; + Node color_matrix, color_conversion, gamma_correction, distortion_lut, distortion_correction, resize; + Node debug_output; + + loader = b.add("image_io_grayscale_data_loader") + .set_param( + Param{"width", "3264"}, + Param{"height", "2464"}, + Param{"url", "http://ion-kit.s3.us-west-2.amazonaws.com/images/IMX219-3264x2464-RG10.raw"}); + + normalize = b.add("image_processing_normalize_raw_image") + .set_param( + Param{"bit_width", "10"}, + Param{"bit_shift", "0"})( + loader["output"]); + + offset = b.add("image_processing_bayer_offset") + .set_param( + bayer_pattern)( + offset_r, offset_g, + offset_b, + normalize["output"]); + + shading_correction = b.add("image_processing_lens_shading_correction_linear") + .set_param( + bayer_pattern, + Param{"width", std::to_string(width)}, + Param{"height", std::to_string(height)})( + shading_correction_slope_r, + shading_correction_slope_g, + shading_correction_slope_b, + shading_correction_offset_r, + shading_correction_offset_g, + shading_correction_offset_b, + offset["output"]); + white_balance = b.add("image_processing_bayer_white_balance") + .set_param( + bayer_pattern)( + gain_r, + gain_g, + gain_b, + shading_correction["output"]); + demosaic = b.add("image_processing_bayer_demosaic_filter") + .set_param( + bayer_pattern, + Param{"width", std::to_string(width)}, + Param{"height", std::to_string(height)})( + white_balance["output"]); + luminance = b.add("image_processing_calc_luminance") + .set_param( + Param{"luminance_method", "Average"})( + demosaic["output"]); + luminance_filter = b.add("base_constant_buffer_2d_float") + .set_param( + Param{"values", "0.04"}, + Param{"extent0", "5"}, + Param{"extent1", "5"}); + filtered_luminance = b.add("image_processing_convolution_2d") + .set_param( + Param{"boundary_conditions_method", "MirrorInterior"}, + Param{"window_size", "2"}, + Param{"width", std::to_string(width)}, + Param{"height", std::to_string(height)})( + luminance_filter["output"], + luminance["output"]); + noise_reduction = b.add("image_processing_bilateral_filter_3d") + .set_param( + Param{"color_difference_method", "Average"}, + Param{"window_size", "2"}, + Param{"width", std::to_string(width)}, + Param{"height", std::to_string(height)})( + coef_color, + coef_space, + filtered_luminance["output"], + demosaic["output"]); + color_matrix = b.add("base_constant_buffer_2d_float") + .set_param( + Param{"values", "2.20213000 -1.27425000 0.07212000 " + "-0.25650000 1.45961000 -0.20311000 " + "0.07458000 -1.35791000 2.28333000"}, + Param{"extent0", "3"}, + Param{"extent1", "3"}); + color_conversion = b.add("image_processing_color_matrix")( + color_matrix["output"], + noise_reduction["output"]); + distortion_correction = b.add("image_processing_lens_distortion_correction_model_3d") + .set_param( + Param{"width", std::to_string(width)}, + Param{"height", std::to_string(height)})( + k1, + k2, + k3, + p1, + p2, + fx, + fy, + cx, + cy, + output_scale, + color_conversion["output"]); + resize = b.add("image_processing_resize_area_average_3d") + .set_param( + Param{"width", std::to_string(width)}, + Param{"height", std::to_string(height)}, + Param{"scale", std::to_string(resize_scale)})( + distortion_correction["output"]); + gamma_correction = b.add("image_processing_gamma_correction_3d")( + gamma, + resize["output"]); + + Halide::Buffer obuf(width * resize_scale, height * resize_scale, 3); + pm.set(gamma_correction["output"], obuf); + + b.run(pm); + obuf.copy_to_host(); + save_image(obuf, "output.png"); + } catch (const std::exception &e) { + std::cerr << e.what() << std::endl; + return -1; + } catch (...) { + return -1; + } + return 0; } diff --git a/example/isp_and_sgm.cc b/example/isp_and_sgm.cc index dfa356b9..4310f6a9 100644 --- a/example/isp_and_sgm.cc +++ b/example/isp_and_sgm.cc @@ -11,7 +11,7 @@ using namespace ion; int main(int argc, char *argv[]) { - assert(argc >= 6); + try { int32_t raw_width = 5184; int32_t raw_height = 1944; diff --git a/script/invoke.sh b/script/invoke.sh index 0765071f..052df429 100755 --- a/script/invoke.sh +++ b/script/invoke.sh @@ -14,13 +14,10 @@ do shift eval envval=\${${envname}} - if [ "${envval}" == "" ]; then eval export ${envname}=${envvar} - eval echo ${envname}=${envvar} else eval export ${envname}=${envvar}:\${${envname}} - eval echo ${envname}=${envvar}:\${${envname}} fi done From a5bf2afbc05ff3dac9a700ad3a67d3911c6dae8b Mon Sep 17 00:00:00 2001 From: Takuro Iizuka Date: Mon, 30 Oct 2023 17:30:34 -0700 Subject: [PATCH 06/17] Adding macro to lookup symbol --- src/bb/image-io/rt_realsense.h | 3 +++ src/bb/image-io/rt_v4l2.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/bb/image-io/rt_realsense.h b/src/bb/image-io/rt_realsense.h index 4c722979..a750ea88 100644 --- a/src/bb/image-io/rt_realsense.h +++ b/src/bb/image-io/rt_realsense.h @@ -312,6 +312,7 @@ extern "C" int ION_EXPORT ion_bb_image_io_realsense_d435_infrared(halide_buffer_ return -1; } } +ION_REGISTER_EXTERN(ion_bb_image_io_realsense_d435_infrared) extern "C" int ION_EXPORT ion_bb_image_io_realsense_d435_depth(halide_buffer_t *in, halide_buffer_t *out_d) { try { @@ -350,6 +351,7 @@ extern "C" int ION_EXPORT ion_bb_image_io_realsense_d435_depth(halide_buffer_t * return -1; } } +ION_REGISTER_EXTERN(ion_bb_image_io_realsense_d435_depth) extern "C" int ION_EXPORT ion_bb_image_io_realsense_d435_frameset(halide_buffer_t *out) { try { @@ -378,5 +380,6 @@ extern "C" int ION_EXPORT ion_bb_image_io_realsense_d435_frameset(halide_buffer_ return -1; } } +ION_REGISTER_EXTERN(ion_bb_image_io_realsense_d435_frameset) #endif diff --git a/src/bb/image-io/rt_v4l2.h b/src/bb/image-io/rt_v4l2.h index 98dd9d7d..499f659a 100644 --- a/src/bb/image-io/rt_v4l2.h +++ b/src/bb/image-io/rt_v4l2.h @@ -547,6 +547,7 @@ extern "C" ION_EXPORT int ion_bb_image_io_v4l2( return -1; } } +ION_REGISTER_EXTERN(ion_bb_image_io_v4l2) extern "C" int ION_EXPORT ion_bb_image_io_camera(int32_t instance_id, int32_t index, int32_t fps, int32_t width, int32_t height, halide_buffer_t *url_buf, halide_buffer_t *out) { try { @@ -572,5 +573,6 @@ extern "C" int ION_EXPORT ion_bb_image_io_camera(int32_t instance_id, int32_t in return -1; } } +ION_REGISTER_EXTERN(ion_bb_image_io_camera) #endif From 09f68a7384c5c33c4d8bbff71f43994296b27b4c Mon Sep 17 00:00:00 2001 From: Takuro Iizuka Date: Tue, 31 Oct 2023 12:54:17 -0700 Subject: [PATCH 07/17] Added test, updated json.hpp, remove header dependencies --- cmake/IonUtil.cmake | 4 +- example/gender_count.cc | 5 +- include/ion/builder.h | 6 +- include/ion/generator.h | 2 - include/ion/node.h | 26 +- include/ion/param.h | 10 +- include/ion/port.h | 31 +- src/core/builder.cc | 8 +- {include/ion => src/core}/json.hpp | 13861 +++++++++++++-------------- src/core/metadata.cc | 3 +- src/core/metadata.h | 2 +- src/core/node.cc | 27 - src/core/param.cc | 15 - src/core/port.cc | 20 - src/core/serializer.h | 86 + test/CMakeLists.txt | 18 +- test/{c_test.c => c_api.c} | 0 test/direct-extern.cc | 4 +- test/dup-port-name.cc | 2 +- test/export.cc | 6 +- test/inverted_dep.cc | 13 +- test/ion-bb-test.cc | 7 + test/port-binding.cc | 2 +- 23 files changed, 6668 insertions(+), 7490 deletions(-) rename {include/ion => src/core}/json.hpp (69%) delete mode 100644 src/core/node.cc delete mode 100644 src/core/param.cc create mode 100644 src/core/serializer.h rename test/{c_test.c => c_api.c} (100%) diff --git a/cmake/IonUtil.cmake b/cmake/IonUtil.cmake index db276442..70a8d857 100644 --- a/cmake/IonUtil.cmake +++ b/cmake/IonUtil.cmake @@ -108,9 +108,9 @@ function(ion_register_test TEST_NAME EXEC_NAME) cmake_parse_arguments(IERT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if (UNIX) - set(IERT_RUNTIME_ENVS "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src/bb") + 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/$<$:Release>$<$:Debug>") + set(IERT_RUNTIME_ENVS "PATH=${CMAKE_BINARY_DIR}/src/bb/$<$:Release>$<$:Debug>\\\;${CMAKE_BINARY_DIR}/test/$<$:Release>$<$:Debug>") endif() if (IERT_TARGET_STRING) diff --git a/example/gender_count.cc b/example/gender_count.cc index 24aa0a1d..2a4ca9ff 100644 --- a/example/gender_count.cc +++ b/example/gender_count.cc @@ -1,11 +1,8 @@ -#include -#include #include +#include using namespace ion; -using json = nlohmann::json; - int main(int argc, char *argv[]) { try { // TODO: Test with FullHD diff --git a/include/ion/builder.h b/include/ion/builder.h index 8e67b99b..b315e199 100644 --- a/include/ion/builder.h +++ b/include/ion/builder.h @@ -9,14 +9,11 @@ #include "def.h" #include "block.h" -#include "json.hpp" #include "node.h" #include "port_map.h" namespace ion { -using json = nlohmann::json; - class DynamicModule; /** @@ -100,7 +97,8 @@ class Builder { /** * Get the node list. */ - const std::vector& get_nodes() const; + const std::vector& nodes() const { return nodes_; } + std::vector& nodes() { return nodes_; } void set_jit_externs(const std::map &externs) { pipeline_.set_jit_externs(externs); diff --git a/include/ion/generator.h b/include/ion/generator.h index 12db0242..fe5ef26f 100644 --- a/include/ion/generator.h +++ b/include/ion/generator.h @@ -23,8 +23,6 @@ #define user_assert(c) _halide_internal_assertion(c, Halide::Internal::ErrorReport::User) #endif -// #include "json.hpp" - /** \file * diff --git a/include/ion/node.h b/include/ion/node.h index 1e66f7c5..4000a89b 100644 --- a/include/ion/node.h +++ b/include/ion/node.h @@ -7,14 +7,11 @@ #include -#include "json.hpp" #include "param.h" #include "port.h" namespace ion { -using json = nlohmann::json; - /** * Node class is used to manage node which consists graph structure. */ @@ -36,9 +33,6 @@ class Node { public: friend class Builder; - friend void to_json(json&, const Node&); - friend void from_json(const json&, Node&); - Node() : impl_(new Node_) {}; /** @@ -101,22 +95,42 @@ class Node { return impl_->id; } + std::string& id() { + return impl_->id; + } + std::string name() const { return impl_->name; } + std::string& name(){ + return impl_->name; + } + Halide::Target target() const { return impl_->target; } + Halide::Target& target() { + return impl_->target; + } + std::vector params() const { return impl_->params; } + std::vector& params() { + return impl_->params; + } + std::vector ports() const { return impl_->ports; } + std::vector& ports() { + return impl_->ports; + } + private: Node(const std::string& id, const std::string& name, const Halide::Target& target) : impl_(new Node_{id, name, target}) diff --git a/include/ion/param.h b/include/ion/param.h index ba71069e..1bb81f4c 100644 --- a/include/ion/param.h +++ b/include/ion/param.h @@ -3,20 +3,13 @@ #include -#include "json.hpp" - namespace ion { -using json = nlohmann::json; - /** * Param class is used to create static parameter for each node. */ class Param { public: - friend void to_json(json&, const Param&); - friend void from_json(const json&, Param&); - Param() {} /** @@ -29,7 +22,10 @@ class Param { Param(const std::string& key, const std::string& val) : key_(key), val_(val) {} std::string key() const { return key_; } + std::string& key() { return key_; } + std::string val() const { return val_; } + std::string& val() { return val_; } private: std::string key_; diff --git a/include/ion/port.h b/include/ion/port.h index a6c50bed..a9da7a46 100644 --- a/include/ion/port.h +++ b/include/ion/port.h @@ -8,30 +8,8 @@ #include -#include "json.hpp" - -namespace nlohmann { -template <> -class adl_serializer { -public: - static void to_json(json& j, const halide_type_t& v) { - j["code"] = v.code; - j["bits"] = v.bits; - j["lanes"] = v.lanes; - } - - static void from_json(const json& j, halide_type_t& v) { - v.code = j["code"]; - v.bits = j["bits"]; - v.lanes = j["lanes"]; - } -}; -} // namespace nlohmann - namespace ion { -using json = nlohmann::json; - class ParamContainer { public: ParamContainer() { @@ -166,8 +144,6 @@ DECLARE_SET_TO_PARAM(double, f64_); */ class Port { public: - friend void to_json(json&, const Port&); - friend void from_json(const json&, Port&); friend class Node; Port() @@ -191,12 +167,19 @@ class Port { : key_(k), type_(t), dimensions_(d), node_id_(), param_info_(new ParamContainer(k, t, d)) {} std::string key() const { return key_; } + std::string& key() { return key_; } Halide::Type type() const { return type_; } + Halide::Type& type() { return type_; } int32_t dimensions() const { return dimensions_; } + int32_t& dimensions() { return dimensions_; } std::string node_id() const { return node_id_; } + std::string& node_id() { return node_id_; } + + std::shared_ptr param_info() const { return param_info_; } + std::shared_ptr& param_info() { return param_info_; } Halide::Expr expr() const { return param_info_->expr(); diff --git a/src/core/builder.cc b/src/core/builder.cc index d9d6068f..18e8156c 100644 --- a/src/core/builder.cc +++ b/src/core/builder.cc @@ -6,12 +6,13 @@ #include "ion/builder.h" #include "ion/generator.h" -#include "ion/json.hpp" #include "ion/util.h" #include "dynamic_module.h" +#include "json.hpp" #include "metadata.h" #include "sole.hpp" +#include "serializer.h" namespace ion { @@ -406,9 +407,4 @@ std::string Builder::bb_metadata(void) { return j.dump(); } - -const std::vector& Builder::get_nodes() const { - return nodes_; -} - } //namespace ion diff --git a/include/ion/json.hpp b/src/core/json.hpp similarity index 69% rename from include/ion/json.hpp rename to src/core/json.hpp index a70aaf8c..4d1a37ad 100644 --- a/include/ion/json.hpp +++ b/src/core/json.hpp @@ -1,44 +1,30 @@ -/* - __ _____ _____ _____ - __| | __| | | | JSON for Modern C++ -| | |__ | | | | | | version 3.9.1 -|_____|_____|_____|_|___| https://github.com/nlohmann/json - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2013-2019 Niels Lohmann . - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + +/****************************************************************************\ + * Note on documentation: The source files contain links to the online * + * documentation of the public API at https://json.nlohmann.me. This URL * + * contains the most recent documentation and should also be applicable to * + * previous versions; documentation for deprecated functions is not * + * removed, but marked deprecated. See "Generate documentation" section in * + * file docs/README.md. * +\****************************************************************************/ #ifndef INCLUDE_NLOHMANN_JSON_HPP_ #define INCLUDE_NLOHMANN_JSON_HPP_ -#define NLOHMANN_JSON_VERSION_MAJOR 3 -#define NLOHMANN_JSON_VERSION_MINOR 9 -#define NLOHMANN_JSON_VERSION_PATCH 1 - #include // all_of, find, for_each #include // nullptr_t, ptrdiff_t, size_t #include // hash, less #include // initializer_list -#include // istream, ostream +#ifndef JSON_NO_IO + #include // istream, ostream +#endif // JSON_NO_IO #include // random_access_iterator_tag #include // unique_ptr #include // accumulate @@ -47,11 +33,129 @@ SOFTWARE. #include // vector // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + #include +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// This file contains all macro definitions affecting or depending on the ABI + +#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK + #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) + #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2 + #warning "Already included a different version of the library!" + #endif + #endif +#endif + +#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum) +#define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum) +#define NLOHMANN_JSON_VERSION_PATCH 2 // NOLINT(modernize-macro-to-enum) + +#ifndef JSON_DIAGNOSTICS + #define JSON_DIAGNOSTICS 0 +#endif + +#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 +#endif + +#if JSON_DIAGNOSTICS + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag +#else + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS +#endif + +#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp +#else + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION + #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 +#endif + +// Construct the namespace ABI tags component +#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b +#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ + NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) + +#define NLOHMANN_JSON_ABI_TAGS \ + NLOHMANN_JSON_ABI_TAGS_CONCAT( \ + NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ + NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) + +// Construct the namespace version component +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ + _v ## major ## _ ## minor ## _ ## patch +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) + +#if NLOHMANN_JSON_NAMESPACE_NO_VERSION +#define NLOHMANN_JSON_NAMESPACE_VERSION +#else +#define NLOHMANN_JSON_NAMESPACE_VERSION \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ + NLOHMANN_JSON_VERSION_MINOR, \ + NLOHMANN_JSON_VERSION_PATCH) +#endif + +// Combine namespace components +#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b +#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ + NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) + +#ifndef NLOHMANN_JSON_NAMESPACE +#define NLOHMANN_JSON_NAMESPACE \ + nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ + NLOHMANN_JSON_ABI_TAGS, \ + NLOHMANN_JSON_NAMESPACE_VERSION) +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN +#define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { \ + inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ + NLOHMANN_JSON_ABI_TAGS, \ + NLOHMANN_JSON_NAMESPACE_VERSION) \ + { +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_END +#define NLOHMANN_JSON_NAMESPACE_END \ + } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ + } // namespace nlohmann +#endif + // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + #include // transform @@ -67,63 +171,169 @@ SOFTWARE. #include // valarray // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + +#include // nullptr_t #include // exception #include // runtime_error #include // to_string +#include // vector -// #include +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + +#include // array #include // size_t +#include // uint8_t +#include // string + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // declval, pair +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + -namespace nlohmann +#include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +template struct make_void { + using type = void; +}; +template using void_t = typename make_void::type; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { -/// struct to capture the start position of the current token -struct position_t + +// https://en.cppreference.com/w/cpp/experimental/is_detected +struct nonesuch { - /// the total number of characters read - std::size_t chars_read_total = 0; - /// the number of characters read in the current line - std::size_t chars_read_current_line = 0; - /// the number of lines read - std::size_t lines_read = 0; + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; + nonesuch(nonesuch const&&) = delete; + void operator=(nonesuch const&) = delete; + void operator=(nonesuch&&) = delete; +}; - /// conversion to size_t to preserve SAX interface - constexpr operator size_t() const - { - return chars_read_total; - } +template class Op, + class... Args> +struct detector +{ + using value_t = std::false_type; + using type = Default; }; -} // namespace detail -} // namespace nlohmann +template class Op, class... Args> +struct detector>, Op, Args...> +{ + using value_t = std::true_type; + using type = Op; +}; -// #include +template class Op, class... Args> +using is_detected = typename detector::value_t; +template class Op, class... Args> +struct is_detected_lazy : is_detected { }; + +template class Op, class... Args> +using detected_t = typename detector::type; + +template class Op, class... Args> +using detected_or = detector; + +template class Op, class... Args> +using detected_or_t = typename detected_or::type; + +template class Op, class... Args> +using is_detected_exact = std::is_same>; + +template class Op, class... Args> +using is_detected_convertible = + std::is_convertible, To>; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END -#include // pair // #include + + +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-FileCopyrightText: 2016-2021 Evan Nemerson +// SPDX-License-Identifier: MIT + /* Hedley - https://nemequ.github.io/hedley * Created by Evan Nemerson - * - * To the extent possible under law, the author(s) have dedicated all - * copyright and related and neighboring rights to this software to - * the public domain worldwide. This software is distributed without - * any warranty. - * - * For details, see . - * SPDX-License-Identifier: CC0-1.0 */ -#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 13) +#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) #if defined(JSON_HEDLEY_VERSION) #undef JSON_HEDLEY_VERSION #endif -#define JSON_HEDLEY_VERSION 13 +#define JSON_HEDLEY_VERSION 15 #if defined(JSON_HEDLEY_STRINGIFY_EX) #undef JSON_HEDLEY_STRINGIFY_EX @@ -196,18 +406,18 @@ struct position_t #if defined(JSON_HEDLEY_MSVC_VERSION) #undef JSON_HEDLEY_MSVC_VERSION #endif -#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) +#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) -#elif defined(_MSC_FULL_VER) +#elif defined(_MSC_FULL_VER) && !defined(__ICL) #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && !defined(__ICL) #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) #endif #if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) #undef JSON_HEDLEY_MSVC_VERSION_CHECK #endif -#if !defined(_MSC_VER) +#if !defined(JSON_HEDLEY_MSVC_VERSION) #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) #elif defined(_MSC_VER) && (_MSC_VER >= 1400) #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) @@ -220,9 +430,9 @@ struct position_t #if defined(JSON_HEDLEY_INTEL_VERSION) #undef JSON_HEDLEY_INTEL_VERSION #endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) -#elif defined(__INTEL_COMPILER) +#elif defined(__INTEL_COMPILER) && !defined(__ICL) #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) #endif @@ -235,6 +445,22 @@ struct position_t #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) #endif +#if defined(JSON_HEDLEY_INTEL_CL_VERSION) + #undef JSON_HEDLEY_INTEL_CL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) + #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) +#endif + +#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) + #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_INTEL_CL_VERSION) + #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) +#endif + #if defined(JSON_HEDLEY_PGI_VERSION) #undef JSON_HEDLEY_PGI_VERSION #endif @@ -474,7 +700,7 @@ struct position_t #if __VER__ > 1000 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) #else - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) #endif #endif @@ -551,6 +777,22 @@ struct position_t #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) #endif +#if defined(JSON_HEDLEY_MCST_LCC_VERSION) + #undef JSON_HEDLEY_MCST_LCC_VERSION +#endif +#if defined(__LCC__) && defined(__LCC_MINOR__) + #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) +#endif + +#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) + #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_MCST_LCC_VERSION) + #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) +#endif + #if defined(JSON_HEDLEY_GCC_VERSION) #undef JSON_HEDLEY_GCC_VERSION #endif @@ -560,6 +802,7 @@ struct position_t !defined(JSON_HEDLEY_INTEL_VERSION) && \ !defined(JSON_HEDLEY_PGI_VERSION) && \ !defined(JSON_HEDLEY_ARM_VERSION) && \ + !defined(JSON_HEDLEY_CRAY_VERSION) && \ !defined(JSON_HEDLEY_TI_VERSION) && \ !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ @@ -567,7 +810,8 @@ struct position_t !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ - !defined(__COMPCERT__) + !defined(__COMPCERT__) && \ + !defined(JSON_HEDLEY_MCST_LCC_VERSION) #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION #endif @@ -583,17 +827,21 @@ struct position_t #if defined(JSON_HEDLEY_HAS_ATTRIBUTE) #undef JSON_HEDLEY_HAS_ATTRIBUTE #endif -#if defined(__has_attribute) - #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) +#if \ + defined(__has_attribute) && \ + ( \ + (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ + ) +# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) #else - #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) +# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) #endif #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) #else #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif @@ -602,7 +850,7 @@ struct position_t #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) #else #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif @@ -787,6 +1035,72 @@ struct position_t #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + defined(__clang__) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_PRAGMA(value) __pragma(value) +#else + #define JSON_HEDLEY_PRAGMA(value) +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) + #undef JSON_HEDLEY_DIAGNOSTIC_PUSH +#endif +#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) + #undef JSON_HEDLEY_DIAGNOSTIC_POP +#endif +#if defined(__clang__) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#else + #define JSON_HEDLEY_DIAGNOSTIC_PUSH + #define JSON_HEDLEY_DIAGNOSTIC_POP +#endif + /* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) @@ -795,12 +1109,22 @@ struct position_t #if defined(__cplusplus) # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ +# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ xpr \ JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# endif # else # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ JSON_HEDLEY_DIAGNOSTIC_PUSH \ @@ -865,7 +1189,7 @@ struct position_t # define JSON_HEDLEY_CPP_CAST(T, expr) \ JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("diag_suppress=Pe137") \ - JSON_HEDLEY_DIAGNOSTIC_POP \ + JSON_HEDLEY_DIAGNOSTIC_POP # else # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) # endif @@ -873,70 +1197,6 @@ struct position_t # define JSON_HEDLEY_CPP_CAST(T, expr) (expr) #endif -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - defined(__clang__) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) - #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_PRAGMA(value) __pragma(value) -#else - #define JSON_HEDLEY_PRAGMA(value) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) - #undef JSON_HEDLEY_DIAGNOSTIC_PUSH -#endif -#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) - #undef JSON_HEDLEY_DIAGNOSTIC_POP -#endif -#if defined(__clang__) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) - #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_PUSH - #define JSON_HEDLEY_DIAGNOSTIC_POP -#endif - #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED #endif @@ -944,12 +1204,18 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") #elif \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ @@ -982,6 +1248,8 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) @@ -998,6 +1266,8 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") #else #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS #endif @@ -1011,8 +1281,12 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) @@ -1024,6 +1298,8 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") #else #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES #endif @@ -1041,20 +1317,34 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL #endif +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunused-function") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION +#endif + #if defined(JSON_HEDLEY_DEPRECATED) #undef JSON_HEDLEY_DEPRECATED #endif #if defined(JSON_HEDLEY_DEPRECATED_FOR) #undef JSON_HEDLEY_DEPRECATED_FOR #endif -#if JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) +#if \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) -#elif defined(__cplusplus) && (__cplusplus >= 201402L) - #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) #elif \ - JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ + (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ @@ -1064,9 +1354,13 @@ struct position_t JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) +#elif defined(__cplusplus) && (__cplusplus >= 201402L) + #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) #elif \ JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ @@ -1081,12 +1375,15 @@ struct position_t (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) #elif \ JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) + JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) @@ -1103,7 +1400,8 @@ struct position_t #if \ JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) #else #define JSON_HEDLEY_UNAVAILABLE(available_since) @@ -1115,13 +1413,7 @@ struct position_t #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG #endif -#if (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) -#elif \ +#if \ JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ @@ -1137,9 +1429,16 @@ struct position_t JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) +#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) #elif defined(_Check_return_) /* SAL */ #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ @@ -1155,7 +1454,8 @@ struct position_t JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) #else #define JSON_HEDLEY_SENTINEL(position) @@ -1166,7 +1466,9 @@ struct position_t #endif #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) #define JSON_HEDLEY_NO_RETURN __noreturn -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +#elif \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #define JSON_HEDLEY_NO_RETURN _Noreturn @@ -1188,11 +1490,14 @@ struct position_t (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") @@ -1224,7 +1529,8 @@ struct position_t #endif #if \ JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_ASSUME(expr) __assume(expr) #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) @@ -1242,7 +1548,9 @@ struct position_t JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() #elif defined(JSON_HEDLEY_ASSUME) #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) @@ -1320,7 +1628,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) @@ -1356,15 +1665,16 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) #endif #if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) + (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) #elif \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ @@ -1378,7 +1688,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) # define JSON_HEDLEY_PREDICT(expr, expected, probability) \ (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ @@ -1424,11 +1735,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_MALLOC __declspec(restrict) #else #define JSON_HEDLEY_MALLOC @@ -1455,7 +1769,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) # define JSON_HEDLEY_PURE __attribute__((__pure__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") @@ -1491,7 +1806,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_CONST __attribute__((__const__)) #elif \ JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) @@ -1509,6 +1825,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ @@ -1518,7 +1835,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - defined(__clang__) + defined(__clang__) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_RESTRICT __restrict #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) #define JSON_HEDLEY_RESTRICT _Restrict @@ -1539,13 +1857,15 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_HEDLEY_INLINE __inline__ #elif \ JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_INLINE __inline #else #define JSON_HEDLEY_INLINE @@ -1571,9 +1891,13 @@ JSON_HEDLEY_DIAGNOSTIC_POP (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) # define JSON_HEDLEY_ALWAYS_INLINE __forceinline #elif defined(__cplusplus) && \ ( \ @@ -1611,9 +1935,13 @@ JSON_HEDLEY_DIAGNOSTIC_POP (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") @@ -1656,7 +1984,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ ) \ - ) + ) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) # else @@ -1672,10 +2001,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if \ JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) #elif \ JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) #define JSON_HEDLEY_NO_THROW __declspec(nothrow) #else @@ -1687,7 +2018,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif #if \ JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) + JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) @@ -1704,7 +2036,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif #if \ JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) #elif defined(_Ret_notnull_) /* SAL */ #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ @@ -1746,7 +2079,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) #endif #if !defined(__cplusplus) @@ -1770,7 +2104,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ !defined(JSON_HEDLEY_PGI_VERSION) && \ !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ + (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ @@ -1840,7 +2174,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if \ !defined(__cplusplus) && ( \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - JSON_HEDLEY_HAS_FEATURE(c_static_assert) || \ + (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ defined(_Static_assert) \ @@ -1848,7 +2182,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) #elif \ (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) + JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) #else # define JSON_HEDLEY_STATIC_ASSERT(expr, message) @@ -1908,7 +2243,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) #else # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) @@ -1944,8 +2281,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_FLAGS) #undef JSON_HEDLEY_FLAGS #endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) +#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) +#else + #define JSON_HEDLEY_FLAGS #endif #if defined(JSON_HEDLEY_FLAGS_CAST) @@ -1965,7 +2304,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_EMPTY_BASES) #undef JSON_HEDLEY_EMPTY_BASES #endif -#if JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0) +#if \ + (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) #else #define JSON_HEDLEY_EMPTY_BASES @@ -2020,9 +2361,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ -// This file contains all internal macro definitions +// This file contains all internal macro definitions (except those affecting ABI) // You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them +// #include + + // exclude unsupported compilers #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) #if defined(__clang__) @@ -2037,30 +2381,128 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif // C++ language standard detection -#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) - #define JSON_HAS_CPP_20 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 +// if the user manually specified the used c++ version this is skipped +#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) + #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) + #define JSON_HAS_CPP_20 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 + #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 + #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 + #endif + // the cpp 11 flag is always specified because it is the minimal required version + #define JSON_HAS_CPP_11 +#endif + +#ifdef __has_include + #if __has_include() + #include + #endif +#endif + +#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) + #ifdef JSON_HAS_CPP_17 + #if defined(__cpp_lib_filesystem) + #define JSON_HAS_FILESYSTEM 1 + #elif defined(__cpp_lib_experimental_filesystem) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif !defined(__has_include) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #endif + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__clang_major__) && __clang_major__ < 7 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support + #if defined(_MSC_VER) && _MSC_VER < 1914 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before iOS 13 + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before macOS Catalina + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + #endif +#endif + +#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_FILESYSTEM + #define JSON_HAS_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_THREE_WAY_COMPARISON + #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \ + && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L + #define JSON_HAS_THREE_WAY_COMPARISON 1 + #else + #define JSON_HAS_THREE_WAY_COMPARISON 0 + #endif +#endif + +#ifndef JSON_HAS_RANGES + // ranges header shipping in GCC 11.1.0 (released 2021-04-27) has syntax error + #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427 + #define JSON_HAS_RANGES 0 + #elif defined(__cpp_lib_ranges) + #define JSON_HAS_RANGES 1 + #else + #define JSON_HAS_RANGES 0 + #endif +#endif + +#ifdef JSON_HAS_CPP_17 + #define JSON_INLINE_VARIABLE inline +#else + #define JSON_INLINE_VARIABLE #endif -// disable float-equal warnings on GCC/clang -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wfloat-equal" +#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address) + #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]] +#else + #define JSON_NO_UNIQUE_ADDRESS #endif // disable documentation warnings on clang #if defined(__clang__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdocumentation" + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdocumentation" + #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" #endif -// allow to disable exceptions +// allow disabling exceptions #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try @@ -2094,12 +2536,19 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER #endif -// allow to override assert +// allow overriding assert #if !defined(JSON_ASSERT) #include // assert #define JSON_ASSERT(x) assert(x) #endif +// allow to access some private functions (needed by the test suite) +#if defined(JSON_TESTS_PRIVATE) + #define JSON_PRIVATE_UNLESS_TESTED public +#else + #define JSON_PRIVATE_UNLESS_TESTED private +#endif + /*! @brief macro to briefly define a mapping between an enum and JSON @def NLOHMANN_JSON_SERIALIZE_ENUM @@ -2283,6 +2732,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); +#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1); /*! @brief macro @@ -2293,6 +2743,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + /*! @brief macro @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE @@ -2302,6 +2756,49 @@ JSON_HEDLEY_DIAGNOSTIC_POP inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + + +// inspired from https://stackoverflow.com/a/26745591 +// allows to call any std function as if (e.g. with begin): +// using std::begin; begin(x); +// +// it allows using the detected idiom to retrieve the return type +// of such an expression +#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ + namespace detail { \ + using std::std_name; \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + } \ + \ + namespace detail2 { \ + struct std_name##_tag \ + { \ + }; \ + \ + template \ + std_name##_tag std_name(T&&...); \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + \ + template \ + struct would_call_std_##std_name \ + { \ + static constexpr auto const value = ::nlohmann::detail:: \ + is_detected_exact::value; \ + }; \ + } /* namespace detail2 */ \ + \ + template \ + struct would_call_std_##std_name : detail2::would_call_std_##std_name \ + { \ + } + #ifndef JSON_USE_IMPLICIT_CONVERSIONS #define JSON_USE_IMPLICIT_CONVERSIONS 1 #endif @@ -2312,406 +2809,383 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_EXPLICIT explicit #endif +#ifndef JSON_DISABLE_ENUM_SERIALIZATION + #define JSON_DISABLE_ENUM_SERIALIZATION 0 +#endif -namespace nlohmann -{ +#ifndef JSON_USE_GLOBAL_UDLS + #define JSON_USE_GLOBAL_UDLS 1 +#endif + +#if JSON_HAS_THREE_WAY_COMPARISON + #include // partial_ordering +#endif + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { -//////////////// -// exceptions // -//////////////// + +/////////////////////////// +// JSON type enumeration // +/////////////////////////// /*! -@brief general exception of the @ref basic_json class +@brief the JSON type enumeration + +This enumeration collects the different JSON types. It is internally used to +distinguish the stored values, and the functions @ref basic_json::is_null(), +@ref basic_json::is_object(), @ref basic_json::is_array(), +@ref basic_json::is_string(), @ref basic_json::is_boolean(), +@ref basic_json::is_number() (with @ref basic_json::is_number_integer(), +@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), +@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and +@ref basic_json::is_structured() rely on it. -This class is an extension of `std::exception` objects with a member @a id for -exception ids. It is used as the base class for all exceptions thrown by the -@ref basic_json class. This class can hence be used as "wildcard" to catch -exceptions. +@note There are three enumeration entries (number_integer, number_unsigned, and +number_float), because the library distinguishes these three types for numbers: +@ref basic_json::number_unsigned_t is used for unsigned integers, +@ref basic_json::number_integer_t is used for signed integers, and +@ref basic_json::number_float_t is used for floating-point numbers or to +approximate integers which do not fit in the limits of their respective type. -Subclasses: -- @ref parse_error for exceptions indicating a parse error -- @ref invalid_iterator for exceptions indicating errors with iterators -- @ref type_error for exceptions indicating executing a member function with - a wrong type -- @ref out_of_range for exceptions indicating access out of the defined range -- @ref other_error for exceptions indicating other library errors +@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON +value with the default value for a given type -@internal -@note To have nothrow-copy-constructible exceptions, we internally use - `std::runtime_error` which can cope with arbitrary-length error messages. - Intermediate strings are built with static functions and then passed to - the actual constructor. -@endinternal +@since version 1.0.0 +*/ +enum class value_t : std::uint8_t +{ + null, ///< null value + object, ///< object (unordered set of name/value pairs) + array, ///< array (ordered collection of values) + string, ///< string value + boolean, ///< boolean value + number_integer, ///< number value (signed integer) + number_unsigned, ///< number value (unsigned integer) + number_float, ///< number value (floating-point) + binary, ///< binary array (ordered collection of bytes) + discarded ///< discarded by the parser callback function +}; + +/*! +@brief comparison operator for JSON types -@liveexample{The following code shows how arbitrary library exceptions can be -caught.,exception} +Returns an ordering that is similar to Python: +- order: null < boolean < number < object < array < string < binary +- furthermore, each type is not smaller than itself +- discarded values are not comparable +- binary is represented as a b"" string in python and directly comparable to a + string; however, making a binary array directly comparable with a string would + be surprising behavior in a JSON file. -@since version 3.0.0 +@since version 1.0.0 */ -class exception : public std::exception +#if JSON_HAS_THREE_WAY_COMPARISON + inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD* +#else + inline bool operator<(const value_t lhs, const value_t rhs) noexcept +#endif { - public: - /// returns the explanatory string - JSON_HEDLEY_RETURNS_NON_NULL - const char* what() const noexcept override + static constexpr std::array order = {{ + 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, + 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, + 6 /* binary */ + } + }; + + const auto l_index = static_cast(lhs); + const auto r_index = static_cast(rhs); +#if JSON_HAS_THREE_WAY_COMPARISON + if (l_index < order.size() && r_index < order.size()) { - return m.what(); + return order[l_index] <=> order[r_index]; // *NOPAD* } + return std::partial_ordering::unordered; +#else + return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; +#endif +} - /// the id of the exception - const int id; +// GCC selects the built-in operator< over an operator rewritten from +// a user-defined spaceship operator +// Clang, MSVC, and ICC select the rewritten candidate +// (see GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105200) +#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__) +inline bool operator<(const value_t lhs, const value_t rhs) noexcept +{ + return std::is_lt(lhs <=> rhs); // *NOPAD* +} +#endif - protected: - JSON_HEDLEY_NON_NULL(3) - exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END - static std::string name(const std::string& ename, int id_) - { - return "[json.exception." + ename + "." + std::to_string(id_) + "] "; - } +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT - private: - /// an exception object as storage for error messages - std::runtime_error m; -}; -/*! -@brief exception indicating a parse error - -This exception is thrown by the library when a parse error occurs. Parse errors -can occur during the deserialization of JSON text, CBOR, MessagePack, as well -as when using JSON Patch. - -Member @a byte holds the byte index of the last read character in the input -file. - -Exceptions have ids 1xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position. -json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. -json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. -json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. -json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. -json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. -json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. -json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences. -json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number. -json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read. -json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. -json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read. -json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet). -json.exception.parse_error.115 | parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A | A UBJSON high-precision number could not be parsed. - -@note For an input with n bytes, 1 is the index of the first character and n+1 - is the index of the terminating null byte or the end of file. This also - holds true when reading a byte vector (CBOR or MessagePack). - -@liveexample{The following code shows how a `parse_error` exception can be -caught.,parse_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class parse_error : public exception -{ - public: - /*! - @brief create a parse error exception - @param[in] id_ the id of the exception - @param[in] pos the position where the error occurred (or with - chars_read_total=0 if the position cannot be - determined) - @param[in] what_arg the explanatory string - @return parse_error object - */ - static parse_error create(int id_, const position_t& pos, const std::string& what_arg) - { - std::string w = exception::name("parse_error", id_) + "parse error" + - position_string(pos) + ": " + what_arg; - return parse_error(id_, pos.chars_read_total, w.c_str()); - } - static parse_error create(int id_, std::size_t byte_, const std::string& what_arg) - { - std::string w = exception::name("parse_error", id_) + "parse error" + - (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") + - ": " + what_arg; - return parse_error(id_, byte_, w.c_str()); - } +// #include - /*! - @brief byte index of the parse error - The byte index of the last read character in the input file. +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ - @note For an input with n bytes, 1 is the index of the first character and - n+1 is the index of the terminating null byte or the end of file. - This also holds true when reading a byte vector (CBOR or MessagePack). - */ - const std::size_t byte; +/*! +@brief replace all occurrences of a substring by another string - private: - parse_error(int id_, std::size_t byte_, const char* what_arg) - : exception(id_, what_arg), byte(byte_) {} +@param[in,out] s the string to manipulate; changed so that all + occurrences of @a f are replaced with @a t +@param[in] f the substring to replace with @a t +@param[in] t the string to replace @a f - static std::string position_string(const position_t& pos) - { - return " at line " + std::to_string(pos.lines_read + 1) + - ", column " + std::to_string(pos.chars_read_current_line); - } -}; +@pre The search string @a f must not be empty. **This precondition is +enforced with an assertion.** -/*! -@brief exception indicating errors with iterators - -This exception is thrown if iterators passed to a library function do not match -the expected semantics. - -Exceptions have ids 2xx. - -name / id | example message | description ------------------------------------ | --------------- | ------------------------- -json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. -json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from. -json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid. -json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid. -json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range. -json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key. -json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to. -json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container. -json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered. -json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin(). - -@liveexample{The following code shows how an `invalid_iterator` exception can be -caught.,invalid_iterator} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 +@since version 2.0.0 */ -class invalid_iterator : public exception +template +inline void replace_substring(StringType& s, const StringType& f, + const StringType& t) { - public: - static invalid_iterator create(int id_, const std::string& what_arg) - { - std::string w = exception::name("invalid_iterator", id_) + what_arg; - return invalid_iterator(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - invalid_iterator(int id_, const char* what_arg) - : exception(id_, what_arg) {} -}; + JSON_ASSERT(!f.empty()); + for (auto pos = s.find(f); // find first occurrence of f + pos != StringType::npos; // make sure f was found + s.replace(pos, f.size(), t), // replace with t, and + pos = s.find(f, pos + t.size())) // find next occurrence of f + {} +} /*! -@brief exception indicating executing a member function with a wrong type - -This exception is thrown in case of a type error; that is, a library function is -executed on a JSON value whose type does not match the expected semantics. - -Exceptions have ids 3xx. - -name / id | example message | description ------------------------------ | --------------- | ------------------------- -json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead. -json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. -json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &. -json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types. -json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types. -json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types. -json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types. -json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types. -json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types. -json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types. -json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types. -json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types. -json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined. -json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers. -json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive. -json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. | -json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) | - -@liveexample{The following code shows how a `type_error` exception can be -caught.,type_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class type_error : public exception + * @brief string escaping as described in RFC 6901 (Sect. 4) + * @param[in] s string to escape + * @return escaped string + * + * Note the order of escaping "~" to "~0" and "/" to "~1" is important. + */ +template +inline StringType escape(StringType s) { - public: - static type_error create(int id_, const std::string& what_arg) - { - std::string w = exception::name("type_error", id_) + what_arg; - return type_error(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; + replace_substring(s, StringType{"~"}, StringType{"~0"}); + replace_substring(s, StringType{"/"}, StringType{"~1"}); + return s; +} /*! -@brief exception indicating access out of the defined range - -This exception is thrown in case a library function is called on an input -parameter that exceeds the expected range, for instance in case of array -indices or nonexisting object keys. - -Exceptions have ids 4xx. - -name / id | example message | description -------------------------------- | --------------- | ------------------------- -json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1. -json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it. -json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object. -json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. -json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. -json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. -json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. (until version 3.8.0) | -json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. | -json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string | - -@liveexample{The following code shows how an `out_of_range` exception can be -caught.,out_of_range} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class out_of_range : public exception + * @brief string unescaping as described in RFC 6901 (Sect. 4) + * @param[in] s string to unescape + * @return unescaped string + * + * Note the order of escaping "~1" to "/" and "~0" to "~" is important. + */ +template +static void unescape(StringType& s) { - public: - static out_of_range create(int id_, const std::string& what_arg) - { - std::string w = exception::name("out_of_range", id_) + what_arg; - return out_of_range(id_, w.c_str()); - } + replace_substring(s, StringType{"~1"}, StringType{"/"}); + replace_substring(s, StringType{"~0"}, StringType{"~"}); +} - private: - JSON_HEDLEY_NON_NULL(3) - out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END -/*! -@brief exception indicating other library errors +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT -This exception is thrown in case of errors that cannot be classified with the -other exception types. -Exceptions have ids 5xx. -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. +#include // size_t -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range +// #include -@liveexample{The following code shows how an `other_error` exception can be -caught.,other_error} -@since version 3.0.0 -*/ -class other_error : public exception +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail { - public: - static other_error create(int id_, const std::string& what_arg) + +/// struct to capture the start position of the current token +struct position_t +{ + /// the total number of characters read + std::size_t chars_read_total = 0; + /// the number of characters read in the current line + std::size_t chars_read_current_line = 0; + /// the number of lines read + std::size_t lines_read = 0; + + /// conversion to size_t to preserve SAX interface + constexpr operator size_t() const { - std::string w = exception::name("other_error", id_) + what_arg; - return other_error(id_, w.c_str()); + return chars_read_total; } - - private: - JSON_HEDLEY_NON_NULL(3) - other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-FileCopyrightText: 2018 The Abseil Authors +// SPDX-License-Identifier: MIT + +#include // array #include // size_t #include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type +#include // index_sequence, make_index_sequence, index_sequence_for -namespace nlohmann -{ +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + +template +using uncvref_t = typename std::remove_cv::type>::type; + +#ifdef JSON_HAS_CPP_14 + +// the following utilities are natively available in C++14 +using std::enable_if_t; +using std::index_sequence; +using std::make_index_sequence; +using std::index_sequence_for; + +#else + // alias templates to reduce boilerplate template using enable_if_t = typename std::enable_if::type; -template -using uncvref_t = typename std::remove_cv::type>::type; +// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h +// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0. + +//// START OF CODE FROM GOOGLE ABSEIL -// implementation of C++14 index_sequence and affiliates -// source: https://stackoverflow.com/a/32223343 -template -struct index_sequence +// integer_sequence +// +// Class template representing a compile-time integer sequence. An instantiation +// of `integer_sequence` has a sequence of integers encoded in its +// type through its template arguments (which is a common need when +// working with C++11 variadic templates). `absl::integer_sequence` is designed +// to be a drop-in replacement for C++14's `std::integer_sequence`. +// +// Example: +// +// template< class T, T... Ints > +// void user_function(integer_sequence); +// +// int main() +// { +// // user_function's `T` will be deduced to `int` and `Ints...` +// // will be deduced to `0, 1, 2, 3, 4`. +// user_function(make_integer_sequence()); +// } +template +struct integer_sequence { - using type = index_sequence; - using value_type = std::size_t; + using value_type = T; static constexpr std::size_t size() noexcept { return sizeof...(Ints); } }; -template -struct merge_and_renumber; +// index_sequence +// +// A helper template for an `integer_sequence` of `size_t`, +// `absl::index_sequence` is designed to be a drop-in replacement for C++14's +// `std::index_sequence`. +template +using index_sequence = integer_sequence; + +namespace utility_internal +{ + +template +struct Extend; + +// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. +template +struct Extend, SeqSize, 0> +{ + using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; +}; + +template +struct Extend, SeqSize, 1> +{ + using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; +}; + +// Recursion helper for 'make_integer_sequence'. +// 'Gen::type' is an alias for 'integer_sequence'. +template +struct Gen +{ + using type = + typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; +}; + +template +struct Gen +{ + using type = integer_sequence; +}; + +} // namespace utility_internal -template -struct merge_and_renumber, index_sequence> - : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; +// Compile-time sequences of integers -template -struct make_index_sequence - : merge_and_renumber < typename make_index_sequence < N / 2 >::type, - typename make_index_sequence < N - N / 2 >::type > {}; +// make_integer_sequence +// +// This template alias is equivalent to +// `integer_sequence`, and is designed to be a drop-in +// replacement for C++14's `std::make_integer_sequence`. +template +using make_integer_sequence = typename utility_internal::Gen::type; -template<> struct make_index_sequence<0> : index_sequence<> {}; -template<> struct make_index_sequence<1> : index_sequence<0> {}; +// make_index_sequence +// +// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, +// and is designed to be a drop-in replacement for C++14's +// `std::make_index_sequence`. +template +using make_index_sequence = make_integer_sequence; -template +// index_sequence_for +// +// Converts a typename pack into an index sequence of the same length, and +// is designed to be a drop-in replacement for C++14's +// `std::index_sequence_for()` +template using index_sequence_for = make_index_sequence; +//// END OF CODE FROM GOOGLE ABSEIL + +#endif + // dispatch utility (taken from ranges-v3) template struct priority_tag : priority_tag < N - 1 > {}; template<> struct priority_tag<0> {}; @@ -2720,48 +3194,63 @@ template<> struct priority_tag<0> {}; template struct static_const { - static constexpr T value{}; + static JSON_INLINE_VARIABLE constexpr T value{}; }; -template -constexpr T static_const::value; +#ifndef JSON_HAS_CPP_17 + template + constexpr T static_const::value; +#endif + +template +inline constexpr std::array make_array(Args&& ... args) +{ + return std::array {{static_cast(std::forward(args))...}}; +} + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + #include // numeric_limits #include // false_type, is_constructible, is_integral, is_same, true_type #include // declval +#include // tuple // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT -#include // random_access_iterator_tag -// #include +#include // random_access_iterator_tag +// #include -namespace nlohmann -{ -namespace detail -{ -template struct make_void -{ - using type = void; -}; -template using void_t = typename make_void::type; -} // namespace detail -} // namespace nlohmann +// #include // #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template struct iterator_types {}; @@ -2800,157 +3289,135 @@ struct iterator_traits::value>> using pointer = T*; using reference = T&; }; -} // namespace detail -} // namespace nlohmann + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END // #include -// #include +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT -// #include -#include +// #include -// #include +NLOHMANN_JSON_NAMESPACE_BEGIN -// https://en.cppreference.com/w/cpp/experimental/is_detected -namespace nlohmann -{ -namespace detail -{ -struct nonesuch -{ - nonesuch() = delete; - ~nonesuch() = delete; - nonesuch(nonesuch const&) = delete; - nonesuch(nonesuch const&&) = delete; - void operator=(nonesuch const&) = delete; - void operator=(nonesuch&&) = delete; -}; +NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); -template class Op, - class... Args> -struct detector -{ - using value_t = std::false_type; - using type = Default; -}; +NLOHMANN_JSON_NAMESPACE_END -template class Op, class... Args> -struct detector>, Op, Args...> -{ - using value_t = std::true_type; - using type = Op; -}; +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT -template class Op, class... Args> -using is_detected = typename detector::value_t; -template class Op, class... Args> -using detected_t = typename detector::type; -template class Op, class... Args> -using detected_or = detector; +// #include -template class Op, class... Args> -using detected_or_t = typename detected_or::type; -template class Op, class... Args> -using is_detected_exact = std::is_same>; +NLOHMANN_JSON_NAMESPACE_BEGIN -template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; -} // namespace detail -} // namespace nlohmann +NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); + +NLOHMANN_JSON_NAMESPACE_END + +// #include + +// #include // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ -#define INCLUDE_NLOHMANN_JSON_FWD_HPP_ + #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ -#include // int64_t, uint64_t -#include // map -#include // allocator -#include // string -#include // vector + #include // int64_t, uint64_t + #include // map + #include // allocator + #include // string + #include // vector -/*! -@brief namespace for Niels Lohmann -@see https://github.com/nlohmann -@since version 1.0.0 -*/ -namespace nlohmann -{ -/*! -@brief default JSONSerializer template argument + // #include -This serializer ignores the template arguments and uses ADL -([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) -for serialization. -*/ -template -struct adl_serializer; - -template class ObjectType = - std::map, - template class ArrayType = std::vector, - class StringType = std::string, class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer, - class BinaryType = std::vector> -class basic_json; -/*! -@brief JSON Pointer + /*! + @brief namespace for Niels Lohmann + @see https://github.com/nlohmann + @since version 1.0.0 + */ + NLOHMANN_JSON_NAMESPACE_BEGIN -A JSON pointer defines a string syntax for identifying a specific value -within a JSON document. It can be used with functions `at` and -`operator[]`. Furthermore, JSON pointers are the base for JSON patches. + /*! + @brief default JSONSerializer template argument -@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) + This serializer ignores the template arguments and uses ADL + ([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) + for serialization. + */ + template + struct adl_serializer; -@since version 2.0.0 -*/ -template -class json_pointer; + /// a class to store JSON values + /// @sa https://json.nlohmann.me/api/basic_json/ + template class ObjectType = + std::map, + template class ArrayType = std::vector, + class StringType = std::string, class BooleanType = bool, + class NumberIntegerType = std::int64_t, + class NumberUnsignedType = std::uint64_t, + class NumberFloatType = double, + template class AllocatorType = std::allocator, + template class JSONSerializer = + adl_serializer, + class BinaryType = std::vector> + class basic_json; -/*! -@brief default JSON class + /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document + /// @sa https://json.nlohmann.me/api/json_pointer/ + template + class json_pointer; -This type is the default specialization of the @ref basic_json class which -uses the standard template types. + /*! + @brief default specialization + @sa https://json.nlohmann.me/api/json/ + */ + using json = basic_json<>; -@since version 1.0.0 -*/ -using json = basic_json<>; + /// @brief a minimal map-like container that preserves insertion order + /// @sa https://json.nlohmann.me/api/ordered_map/ + template + struct ordered_map; -template -struct ordered_map; + /// @brief specialization that maintains the insertion order of object keys + /// @sa https://json.nlohmann.me/api/ordered_json/ + using ordered_json = basic_json; -/*! -@brief ordered JSON class - -This type preserves the insertion order of object keys. - -@since version 3.9.0 -*/ -using ordered_json = basic_json; - -} // namespace nlohmann + NLOHMANN_JSON_NAMESPACE_END #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /*! @brief detail namespace with internal helper functions @@ -2961,6 +3428,7 @@ implementations of some @ref basic_json methods, and meta-programming helpers. */ namespace detail { + ///////////// // helpers // ///////////// @@ -2979,6 +3447,16 @@ template struct is_basic_json : std::false_type {}; NLOHMANN_BASIC_JSON_TPL_DECLARATION struct is_basic_json : std::true_type {}; +// used by exceptions create() member functions +// true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t +// false_type otherwise +template +struct is_basic_json_context : + std::integral_constant < bool, + is_basic_json::type>::type>::value + || std::is_same::value > +{}; + ////////////////////// // json_ref helpers // ////////////////////// @@ -3017,9 +3495,6 @@ using reference_t = typename T::reference; template using iterator_category_t = typename T::iterator_category; -template -using iterator_t = typename T::iterator; - template using to_json_function = decltype(T::to_json(std::declval()...)); @@ -3044,8 +3519,7 @@ struct is_getable }; template -struct has_from_json < BasicJsonType, T, - enable_if_t < !is_basic_json::value >> +struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> { using serializer = typename BasicJsonType::template json_serializer; @@ -3084,11 +3558,78 @@ struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> T>::value; }; +template +using detect_key_compare = typename T::key_compare; + +template +struct has_key_compare : std::integral_constant::value> {}; + +// obtains the actual object key comparator +template +struct actual_object_comparator +{ + using object_t = typename BasicJsonType::object_t; + using object_comparator_t = typename BasicJsonType::default_object_comparator_t; + using type = typename std::conditional < has_key_compare::value, + typename object_t::key_compare, object_comparator_t>::type; +}; + +template +using actual_object_comparator_t = typename actual_object_comparator::type; /////////////////// // is_ functions // /////////////////// +// https://en.cppreference.com/w/cpp/types/conjunction +template struct conjunction : std::true_type { }; +template struct conjunction : B { }; +template +struct conjunction +: std::conditional(B::value), conjunction, B>::type {}; + +// https://en.cppreference.com/w/cpp/types/negation +template struct negation : std::integral_constant < bool, !B::value > { }; + +// Reimplementation of is_constructible and is_default_constructible, due to them being broken for +// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). +// This causes compile errors in e.g. clang 3.5 or gcc 4.9. +template +struct is_default_constructible : std::is_default_constructible {}; + +template +struct is_default_constructible> + : conjunction, is_default_constructible> {}; + +template +struct is_default_constructible> + : conjunction, is_default_constructible> {}; + +template +struct is_default_constructible> + : conjunction...> {}; + +template +struct is_default_constructible> + : conjunction...> {}; + + +template +struct is_constructible : std::is_constructible {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + + template struct is_iterator_traits : std::false_type {}; @@ -3107,7 +3648,34 @@ struct is_iterator_traits> is_detected::value; }; -// source: https://stackoverflow.com/a/37193089/4116453 +template +struct is_range +{ + private: + using t_ref = typename std::add_lvalue_reference::type; + + using iterator = detected_t; + using sentinel = detected_t; + + // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator + // and https://en.cppreference.com/w/cpp/iterator/sentinel_for + // but reimplementing these would be too much work, as a lot of other concepts are used underneath + static constexpr auto is_iterator_begin = + is_iterator_traits>::value; + + public: + static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; +}; + +template +using iterator_t = enable_if_t::value, result_of_begin())>>; + +template +using range_value_t = value_type_t>>; + +// The following implementation of is_complete_type is taken from +// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ +// and is written by Xiang Fan who agreed to using it in this library. template struct is_complete_type : std::false_type {}; @@ -3125,14 +3693,13 @@ struct is_compatible_object_type_impl < enable_if_t < is_detected::value&& is_detected::value >> { - using object_t = typename BasicJsonType::object_t; // macOS's is_constructible does not play well with nonesuch... static constexpr bool value = - std::is_constructible::value && - std::is_constructible::value; }; @@ -3153,10 +3720,10 @@ struct is_constructible_object_type_impl < using object_t = typename BasicJsonType::object_t; static constexpr bool value = - (std::is_default_constructible::value && + (is_default_constructible::value && (std::is_move_assignable::value || std::is_copy_assignable::value) && - (std::is_constructible::value && std::is_same < typename object_t::mapped_type, @@ -3173,60 +3740,46 @@ struct is_constructible_object_type : is_constructible_object_type_impl {}; -template -struct is_compatible_string_type_impl : std::false_type {}; - template -struct is_compatible_string_type_impl < - BasicJsonType, CompatibleStringType, - enable_if_t::value >> +struct is_compatible_string_type { static constexpr auto value = - std::is_constructible::value; + is_constructible::value; }; template -struct is_compatible_string_type - : is_compatible_string_type_impl {}; - -template -struct is_constructible_string_type_impl : std::false_type {}; - -template -struct is_constructible_string_type_impl < - BasicJsonType, ConstructibleStringType, - enable_if_t::value >> +struct is_constructible_string_type { + // launder type through decltype() to fix compilation failure on ICPC +#ifdef __INTEL_COMPILER + using laundered_type = decltype(std::declval()); +#else + using laundered_type = ConstructibleStringType; +#endif + static constexpr auto value = - std::is_constructible::value; + conjunction < + is_constructible, + is_detected_exact>::value; }; -template -struct is_constructible_string_type - : is_constructible_string_type_impl {}; - template struct is_compatible_array_type_impl : std::false_type {}; template struct is_compatible_array_type_impl < BasicJsonType, CompatibleArrayType, - enable_if_t < is_detected::value&& + enable_if_t < is_detected::value&& -// This is needed because json_reverse_iterator has a ::iterator type... -// Therefore it is detected as a CompatibleArrayType. -// The real fix would be to have an Iterable concept. - !is_iterator_traits < - iterator_traits>::value >> + is_iterator_traits>>::value&& +// special case for types like std::filesystem::path whose iterator's value_type are themselves +// c.f. https://github.com/nlohmann/json/pull/3073 + !std::is_same>::value >> { static constexpr bool value = - std::is_constructible::value; + is_constructible>::value; }; template @@ -3248,28 +3801,29 @@ struct is_constructible_array_type_impl < BasicJsonType, ConstructibleArrayType, enable_if_t < !std::is_same::value&& - std::is_default_constructible::value&& + !is_compatible_string_type::value&& + is_default_constructible::value&& (std::is_move_assignable::value || std::is_copy_assignable::value)&& -is_detected::value&& is_detected::value&& -is_complete_type < -detected_t>::value >> +is_iterator_traits>>::value&& +is_detected::value&& +// special case for types like std::filesystem::path whose iterator's value_type are themselves +// c.f. https://github.com/nlohmann/json/pull/3073 +!std::is_same>::value&& + is_complete_type < + detected_t>::value >> { + using value_type = range_value_t; + static constexpr bool value = - // This is needed because json_reverse_iterator has a ::iterator type, - // furthermore, std::back_insert_iterator (and other iterators) have a - // base class `iterator`... Therefore it is detected as a - // ConstructibleArrayType. The real fix would be to have an Iterable - // concept. - !is_iterator_traits>::value && - - (std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, typename ConstructibleArrayType::value_type >::value); + std::is_same::value || + has_from_json::value || + has_non_default_from_json < + BasicJsonType, + value_type >::value; }; template @@ -3292,7 +3846,7 @@ struct is_compatible_integer_type_impl < using CompatibleLimits = std::numeric_limits; static constexpr auto value = - std::is_constructible::value && CompatibleLimits::is_integer && RealLimits::is_signed == CompatibleLimits::is_signed; @@ -3319,221 +3873,843 @@ template struct is_compatible_type : is_compatible_type_impl {}; -// https://en.cppreference.com/w/cpp/types/conjunction -template struct conjunction : std::true_type { }; -template struct conjunction : B1 { }; -template -struct conjunction -: std::conditional, B1>::type {}; - template struct is_constructible_tuple : std::false_type {}; template -struct is_constructible_tuple> : conjunction...> {}; -} // namespace detail -} // namespace nlohmann +struct is_constructible_tuple> : conjunction...> {}; -// #include +template +struct is_json_iterator_of : std::false_type {}; +template +struct is_json_iterator_of : std::true_type {}; -#include // array -#include // size_t -#include // uint8_t -#include // string +template +struct is_json_iterator_of : std::true_type +{}; -namespace nlohmann -{ -namespace detail -{ -/////////////////////////// -// JSON type enumeration // -/////////////////////////// +// checks if a given type T is a template specialization of Primary +template