iree icon indicating copy to clipboard operation
iree copied to clipboard

Rework HAL CTS build targets to improve build/link time

Open ScottTodd opened this issue 1 year ago • 0 comments

I noticed multiple minutes of build time and large chunks of build directory disk space being spent on HAL CTS test object files and binary linking at https://github.com/iree-org/iree/pull/17145#discussion_r1576873396 and https://github.com/iree-org/iree/pull/16273#issuecomment-1918174524. Each driver that instantiates the CTS (e.g. hal/drivers/vulkan/cts/CMakeLists.txt) creates one test binary per test case file (e.g. allocator_test, event_test, semaphore_test). We should be able to share part of the build time and binary size between similar tests (across drivers) and/or drivers (across tests).

Some other ideas from Ben:

I don't recall exactly, but I'd probably have suggested one exe per test with all the drivers compiled in, or one exe per driver with all the tests compiled in, or a dynamic library per driver with all the tests compiled in and then generated shim exes that just loaded it and called main (for easy f5 debugging/avoiding flags) (dynamic library is trickier and limits to platforms where dynamic libraries are a thing, etc, so not great) an exe per driver seems fine - can use gtest filtering to run subsuites and such or run exe to run all tests and get a nice report without having to run different binaries could expose to ctest as individual test suites using the same exe but with different flags, so it shows up in reports nicer

Code:

  • https://github.com/iree-org/iree/blob/main/runtime/src/iree/hal/cts/cts_test_base.h
  • https://github.com/iree-org/iree/blob/main/runtime/src/iree/hal/cts/cts_test_template.cc.in
  • https://github.com/iree-org/iree/blob/main/build_tools/cmake/iree_hal_cts_test_suite.cmake

Progress/sketches at https://github.com/ScottTodd/iree/tree/cts-improve-link-time

  • That starts to split the C++ template file into one for the test case itself and one for the driver. Something about header inclusion order isn't working as expected on Vulkan though (fails to find Vulkan video or something...)

ScottTodd avatar Apr 25 '24 16:04 ScottTodd