Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ else ()
endif ()
option (${PROJ_NAME}_BUILD_TOOLS "Build the command-line tools" ON)
option (${PROJ_NAME}_BUILD_TESTS "Build the unit tests" ON)
set_option (OIIO_USE_HWY "Enable experimental Google Highway SIMD optimizations (if Highway is available)" OFF)
set_option (OIIO_USE_HWY "Enable experimental Google Highway SIMD optimizations (if Highway is available)" OFF VERBOSE)
set (OIIO_LIBNAME_SUFFIX "" CACHE STRING
"Optional name appended to ${PROJECT_NAME} libraries that are built")
option (BUILD_OIIOUTIL_ONLY "If ON, will build *only* libOpenImageIO_Util" OFF)
Expand Down
39 changes: 37 additions & 2 deletions src/cmake/testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ set(OIIO_TESTSUITE_IMAGEDIR "${PROJECT_BINARY_DIR}/testsuite" CACHE PATH
# [ URL http://find.reference.cases.here.com ]
# [ FOUNDVAR variable_name ... ]
# [ ENABLEVAR variable_name ... ]
# [ DISABLEVAR variable_name ... ]
# [ SUFFIX suffix ]
# [ ENVIRONMENT "VAR=value" ... ]
# )
Expand All @@ -43,35 +44,48 @@ set(OIIO_TESTSUITE_IMAGEDIR "${PROJECT_BINARY_DIR}/testsuite" CACHE PATH
# not existing and true, will skip the test.
#
# The optional ENABLEVAR introduces variables (typically ENABLE_Foo) that
# if existing and yet false, will skip the test.
# if existing and yet false/off/zero, will skip the test. (Not existing
# does NOT disable the test.)
#
# The optional DISABLEVAR introduces variables that, if existing and
# true/on/nonzero, will skip the test.
#
# The optional SUFFIX is appended to the test name.
#
# The optional ENVIRONMENT is a list of environment variables to set for the
# test.
#
macro (oiio_add_tests)
cmake_parse_arguments (_ats "" "SUFFIX;TESTNAME" "URL;IMAGEDIR;LABEL;FOUNDVAR;ENABLEVAR;ENVIRONMENT" ${ARGN})
cmake_parse_arguments (_ats "" "SUFFIX;TESTNAME" "URL;IMAGEDIR;LABEL;FOUNDVAR;ENABLEVAR;DISABLEVAR;ENVIRONMENT" ${ARGN})
# Arguments: <prefix> <options> <one_value_keywords> <multi_value_keywords> args...
set (_ats_testdir "${OIIO_TESTSUITE_IMAGEDIR}/${_ats_IMAGEDIR}")
# If there was a FOUNDVAR param specified and that variable name is
# not defined, mark the test as broken.
set (_test_disabled FALSE)
set (_test_notfound FALSE)
foreach (_var ${_ats_FOUNDVAR})
# FOUNDVAR entires had better exist and be true
if (NOT ${_var})
set (_ats_LABEL "broken")
set (_test_notfound TRUE)
endif ()
endforeach ()
set (_test_disabled 0)
foreach (_var ${_ats_ENABLEVAR})
# ENABLEVAR, *if* it exists, must be true. But not existing is fine.
if ((NOT "${${_var}}" STREQUAL "" AND NOT "${${_var}}") OR
(NOT "$ENV{${_var}}" STREQUAL "" AND NOT "$ENV{${_var}}"))
set (_ats_LABEL "broken")
set (_test_disabled TRUE)
endif ()
endforeach ()
foreach (_var ${_ats_DISABLEVAR})
# DISABLEVAR, if true, disable the test. Not existing is fine.
if (${_var})
set (_ats_LABEL "broken")
set (_test_disabled TRUE)
endif ()
endforeach ()
# For OCIO 2.2+, have the testsuite use the default built-in config
list (APPEND _ats_ENVIRONMENT "OCIO=ocio://default"
"OIIO_TESTSUITE_OCIOCONFIG=ocio://default")
Expand Down Expand Up @@ -238,6 +252,27 @@ macro (oiio_add_all_tests)
oiio_add_tests (oiiotool-color
FOUNDVAR OpenColorIO_FOUND)

# Tests to run with HWY enabled.
# Remember to add tests here as hwy enabled IBA functions are added
oiio_add_tests ( oiiotool
oiiotool-composite
oiiotool-xform
docs-examples-cpp
FOUNDVAR hwy_FOUND
ENABLEVAR OIIO_USE_HWY
SUFFIX ".hwy"
ENVIRONMENT "OPENIMAGEIO_ENABLE_HWY=1"
)

oiio_add_tests ( python-imagebufalgo
FOUNDVAR hwy_FOUND
ENABLEVAR OIIO_USE_HWY USE_PYTHON
DISABLEVAR BUILD_OIIOUTIL_ONLY SANITIZE
SUFFIX ".hwy"
ENVIRONMENT "OPENIMAGEIO_ENABLE_HWY=1"
IMAGEDIR oiio-images
)

# List testsuites for specific formats or features which might be not found
# or be intentionally disabled, or which need special external reference
# images from the web that if not found, should skip the tests:
Expand Down
1 change: 1 addition & 0 deletions src/libOpenImageIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ if (OIIO_BUILD_TESTS AND BUILD_TESTING)
${OpenCV_LIBRARIES}
${OPENIMAGEIO_IMATH_TARGETS}
FOLDER "Unit Tests" NO_INSTALL)
target_compile_definitions (imagebufalgo_test PRIVATE OIIO_USE_HWY=${_oiio_use_hwy})
add_test (unit_imagebufalgo ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/imagebufalgo_test)

fancy_add_executable (NAME imagespec_test SRC imagespec_test.cpp
Expand Down
31 changes: 23 additions & 8 deletions src/libOpenImageIO/imagebufalgo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ static bool wedge = false;
static int threadcounts[] = { 1, 2, 4, 8, 12, 16, 20,
24, 28, 32, 64, 128, 1024, 1 << 30 };

static const int hwy_build = OIIO_USE_HWY;
static int hwy_on = hwy_build;



static void
getargs(int argc, char* argv[])
Expand Down Expand Up @@ -403,7 +407,7 @@ test_channel_append()
void
test_add()
{
std::cout << "test add\n";
print("test add{}\n", hwy_on ? " (HWY)" : "");

// Create buffers
const float Aval[] = { 0.1f, 0.2f, 0.3f, 0.4f };
Expand All @@ -429,7 +433,7 @@ test_add()
void
test_sub()
{
std::cout << "test sub\n";
print("test sub{}\n", hwy_on ? " (HWY)" : "");

// Create buffers
const float Aval[] = { 0.1f, 0.2f, 0.3f, 0.4f };
Expand All @@ -455,7 +459,7 @@ test_sub()
void
test_mul()
{
std::cout << "test mul\n";
print("test mul{}\n", hwy_on ? " (HWY)" : "");

// Create buffers
// Create buffers
Expand All @@ -482,7 +486,7 @@ test_mul()
void
test_mad()
{
std::cout << "test mad\n";
print("test mad{}\n", hwy_on ? " (HWY)" : "");
const int WIDTH = 4, HEIGHT = 4, CHANNELS = 4;
ImageSpec spec(WIDTH, HEIGHT, CHANNELS, TypeDesc::FLOAT);

Expand Down Expand Up @@ -1678,6 +1682,17 @@ test_demosaic()
}



// clang-format off
// Neat trick macro to prefix in front of the calls where we want to
// run it in both hwy and non-hwy modes. It will loop over both settings.
#define HWY_TEST \
for (hwy_on = 0; hwy_on <= hwy_build; ++hwy_on) \
OIIO::attribute("enable_hwy", hwy_on), /* next command */
// clang-format on



int
main(int argc, char** argv)
{
Expand All @@ -1702,10 +1717,10 @@ main(int argc, char** argv)
test_crop();
test_paste();
test_channel_append();
test_add();
test_sub();
test_mul();
test_mad();
HWY_TEST test_add();
HWY_TEST test_sub();
HWY_TEST test_mul();
HWY_TEST test_mad();
test_hwy_strided_roi_fallback();
test_min();
test_max();
Expand Down
Loading