Skip to content

Commit 3602148

Browse files
authored
ci: Try to reduce costs and timeouts for expensive tests in debug mode (#5150)
* Fix setting and response of OIIO_CI -- it was less functional before than I had thought because we didn't actually define the symbol for compilation. * More aggressive cost reduction when combining CI + Debug builds, reduce resolution of some benchmarks, etc., in addition to reducing iterations as we had done before. * Mark the most expensive unit tests with a cost, so CTest knows to start them first. (more explanation below) * Add Testing/Temporary/CTestCostData.txt to the cache-save paths -- that preserves CTest's understanding of how much each test costs so it can schedule it more intellegently for the next run. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent c3fbed1 commit 3602148

7 files changed

Lines changed: 62 additions & 14 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ if (TEX_BATCH_SIZE)
142142
add_compile_definitions (OIIO_TEXTURE_SIMD_BATCH_WIDTH=${TEX_BATCH_SIZE})
143143
endif ()
144144

145+
# If we're building this just for CI, define a symbol so the code can
146+
# tell (and reduce complexity of some tests)
147+
set_option (OIIO_CI "Set if this build is for our GHA CI" OFF)
148+
if (OIIO_CI)
149+
add_compile_definitions (OIIO_CI=1)
150+
endif ()
145151

146152
# Namespace settings
147153
#

src/build-scripts/ci-startup.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages:$P
3636
export COMPILER=${COMPILER:=gcc}
3737
export CC=${CC:=gcc}
3838
export CXX=${CXX:=g++}
39-
export OpenImageIO_CI=true
39+
export OpenImageIO_CI=1
4040
export USE_NINJA=${USE_NINJA:=1}
4141
export CMAKE_GENERATOR=${CMAKE_GENERATOR:=Ninja}
4242
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}

src/libOpenImageIO/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,13 @@ if (OIIO_BUILD_TESTS AND BUILD_TESTING)
263263
LINK_LIBRARIES OpenImageIO Imath::Imath
264264
FOLDER "Unit Tests" NO_INSTALL)
265265
add_test (unit_image_span ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/image_span_test)
266+
set_tests_properties (unit_image_span PROPERTIES COST 10)
266267

267268
fancy_add_executable (NAME imagebuf_test SRC imagebuf_test.cpp
268269
LINK_LIBRARIES OpenImageIO
269270
FOLDER "Unit Tests" NO_INSTALL)
270271
add_test (unit_imagebuf ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/imagebuf_test)
272+
set_tests_properties (unit_imagebuf PROPERTIES COST 30)
271273

272274
fancy_add_executable (NAME imagecache_test SRC imagecache_test.cpp
273275
LINK_LIBRARIES OpenImageIO
@@ -284,6 +286,7 @@ if (OIIO_BUILD_TESTS AND BUILD_TESTING)
284286
FOLDER "Unit Tests" NO_INSTALL)
285287
target_compile_definitions (imagebufalgo_test PRIVATE OIIO_USE_HWY=${_oiio_use_hwy})
286288
add_test (unit_imagebufalgo ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/imagebufalgo_test)
289+
set_tests_properties (unit_imagebufalgo PROPERTIES PROCESSORS 2 COST 60)
287290

288291
fancy_add_executable (NAME imagespec_test SRC imagespec_test.cpp
289292
LINK_LIBRARIES OpenImageIO
@@ -294,6 +297,7 @@ if (OIIO_BUILD_TESTS AND BUILD_TESTING)
294297
LINK_LIBRARIES OpenImageIO
295298
FOLDER "Unit Tests" NO_INSTALL)
296299
add_test (unit_imageinout ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/imageinout_test)
300+
set_tests_properties (unit_imageinout PROPERTIES PROCESSORS 2 COST 30)
297301

298302
if (NOT DEFINED ENV{OpenImageIO_CI})
299303
fancy_add_executable (NAME imagespeed_test SRC imagespeed_test.cpp

src/libOpenImageIO/image_span_test.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ using namespace OIIO;
2121
static int ntrials = 5;
2222
static int iterations = 0;
2323

24+
#if defined(NDEBUG) || !defined(OIIO_CI)
25+
static const int big_xres = 2048, big_yres = 1536;
26+
#else
27+
// Only for debug builds that are part of OIIO's CI - reduce resolution to
28+
// make it run faster
29+
static const int big_xres = 2048 / 2, big_yres = 1536 / 2;
30+
#endif
31+
2432

2533

2634
template<typename T>
@@ -156,7 +164,7 @@ template<typename T = float>
156164
void
157165
test_image_span_copy_image()
158166
{
159-
const int xres = 2048, yres = 1536, nchans = 4;
167+
const int xres = big_xres, yres = big_yres, nchans = 4;
160168
const size_t chansize = sizeof(T);
161169
print("\nTesting copy_image {} (total {} MB):\n", TypeDescFromC<T>::value(),
162170
xres * yres * nchans * chansize * 3 / 4 / 1024 / 1024);
@@ -223,7 +231,7 @@ test_image_span_contiguize()
223231
// Benchmark old (ptr) versus new (span) contiguize functions
224232
using pvt::contiguize;
225233

226-
const int xres = 2048, yres = 1536, nchans = 4;
234+
const int xres = big_xres, yres = big_yres, nchans = 4;
227235
const size_t chansize = sizeof(T);
228236
print("\nTesting contiguize {} (total {} MB):\n", TypeDescFromC<T>::value(),
229237
xres * yres * nchans * chansize * 3 / 4 / 1024 / 1024);
@@ -296,7 +304,7 @@ void
296304
test_image_span_convert_image()
297305
{
298306
// Benchmark old (ptr) versus new (span) convert_image functions
299-
const int xres = 2048, yres = 1536, nchans = 4;
307+
const int xres = big_xres, yres = big_yres, nchans = 4;
300308
const size_t schansize = sizeof(Stype);
301309
const size_t dchansize = sizeof(Dtype);
302310
print("\nTesting convert_image {} -> {} (total {}M values):\n",
@@ -423,7 +431,7 @@ void
423431
benchmark_image_span_passing()
424432
{
425433
print("\nbenchmark_image_span_passing\n");
426-
const int xres = 2048, yres = 1536, nchans = 4;
434+
const int xres = big_xres, yres = big_yres, nchans = 4;
427435
std::vector<float> sbuf(xres * yres * nchans, 1.0f);
428436
image_span<const float> ispan(sbuf.data(), nchans, xres, yres, 1);
429437

src/libOpenImageIO/imagebuf_test.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,13 @@ time_get_pixels()
409409
bench.trials(ntrials);
410410
bench.iterations(iterations);
411411
const int nchans = 4;
412+
#if defined(NDEBUG) || !defined(OIIO_CI)
412413
const int xres = 2000, yres = 1000;
414+
#else
415+
// Only for debug builds that are part of OIIO's CI - reduce resolution to
416+
// make it run faster
417+
const int xres = 1000, yres = 500;
418+
#endif
413419
ImageBuf A(ImageSpec(xres, yres, nchans, TypeDesc::FLOAT));
414420
ImageBufAlgo::zero(A);
415421

@@ -609,7 +615,14 @@ void
609615
time_iterators()
610616
{
611617
print("Timing iterator operations:\n");
618+
619+
#if defined(NDEBUG) || !defined(OIIO_CI)
612620
const int rez = 4096, nchans = 4;
621+
#else
622+
// Only for debug builds that are part of OIIO's CI - reduce resolution to
623+
// make it run faster
624+
const int rez = 1024, nchans = 4;
625+
#endif
613626
ImageSpec spec(rez, rez, nchans, TypeFloat);
614627
ImageBuf img(spec);
615628
ImageBufAlgo::fill(img, { 0.25f, 0.5f, 0.75f, 1.0f });

src/libOpenImageIO/imagebufalgo_test.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,17 @@ test_zero_fill()
205205
Benchmarker bench;
206206
bench.trials(ntrials);
207207
bench.iterations(iterations);
208-
ImageBuf buf_rgba_float(ImageSpec(1000, 1000, 4, TypeFloat));
209-
ImageBuf buf_rgba_uint8(ImageSpec(1000, 1000, 4, TypeUInt8));
210-
ImageBuf buf_rgba_half(ImageSpec(1000, 1000, 4, TypeHalf));
211-
ImageBuf buf_rgba_uint16(ImageSpec(1000, 1000, 4, TypeDesc::UINT16));
208+
#if defined(NDEBUG) || !defined(OIIO_CI)
209+
const int rez = 1000;
210+
#else
211+
// Only for debug builds that are part of OIIO's CI - reduce resolution to
212+
// make it run faster
213+
const int rez = 256;
214+
#endif
215+
ImageBuf buf_rgba_float(ImageSpec(rez, rez, 4, TypeFloat));
216+
ImageBuf buf_rgba_uint8(ImageSpec(rez, rez, 4, TypeUInt8));
217+
ImageBuf buf_rgba_half(ImageSpec(rez, rez, 4, TypeHalf));
218+
ImageBuf buf_rgba_uint16(ImageSpec(rez, rez, 4, TypeDesc::UINT16));
212219
float vals[] = { 0, 0, 0, 0 };
213220
bench(" IBA::fill float[4] ",
214221
[&]() { ImageBufAlgo::fill(buf_rgba_float, cspan<float>(vals)); });
@@ -1413,10 +1420,17 @@ test_simple_perpixel()
14131420
bench.trials(ntrials);
14141421
bench.iterations(iterations);
14151422
bench.units(Benchmarker::Unit::ms);
1416-
ImageBuf af(ImageSpec(2048, 2048, 4, TypeFloat));
1417-
ImageBuf bf(ImageSpec(2048, 2048, 4, TypeFloat));
1418-
ImageBuf au8(ImageSpec(2048, 2048, 4, TypeUInt8));
1419-
ImageBuf bu8(ImageSpec(2048, 2048, 4, TypeUInt8));
1423+
#if defined(NDEBUG) || !defined(OIIO_CI)
1424+
const int rez = 2048;
1425+
#else
1426+
// Only for debug builds that are part of OIIO's CI - reduce resolution to
1427+
// make it run faster
1428+
const int rez = 1024;
1429+
#endif
1430+
ImageBuf af(ImageSpec(rez, rez, 4, TypeFloat));
1431+
ImageBuf bf(ImageSpec(rez, rez, 4, TypeFloat));
1432+
ImageBuf au8(ImageSpec(rez, rez, 4, TypeUInt8));
1433+
ImageBuf bu8(ImageSpec(rez, rez, 4, TypeUInt8));
14201434
bench(" IBA::add() float",
14211435
[&]() { ImageBuf r = ImageBufAlgo::add(af, bf); });
14221436
bench(" IBA::add() u8",
@@ -1747,7 +1761,9 @@ main(int argc, char** argv)
17471761
benchmark_parallel_image(64, iterations * 64);
17481762
benchmark_parallel_image(512, iterations * 16);
17491763
benchmark_parallel_image(1024, iterations * 4);
1764+
#if defined(NDEBUG) || !defined(OIIO_CI)
17501765
benchmark_parallel_image(2048, iterations);
1766+
#endif
17511767

17521768
return unit_test_failures;
17531769
}

src/libutil/hash_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <OpenImageIO/argparse.h>
1313
#include <OpenImageIO/benchmark.h>
14+
#include <OpenImageIO/fmath.h>
1415
#include <OpenImageIO/hash.h>
1516
#include <OpenImageIO/strutil.h>
1617
#include <OpenImageIO/timer.h>
@@ -215,7 +216,7 @@ main(int argc, char* argv[])
215216

216217
// fill data with random values so we can hash it a bunch of different ways
217218
std::mt19937 rng(42);
218-
data.resize(iterations / sizeof(data[0]), 0);
219+
data.resize(round_to_multiple(iterations, 4) / sizeof(data[0]), 0);
219220
for (uint32_t& d : data)
220221
d = rng();
221222

0 commit comments

Comments
 (0)