composable_kernel icon indicating copy to clipboard operation
composable_kernel copied to clipboard

Spit add_example_executable and use add_example_test

Open qianfengz opened this issue 2 years ago • 4 comments

Have add_example_test() separated from add_example_executable() enables more testing command-lines being added for each single example. And having the add_example_test() enables the developer to use one example .cpp and executable to support multiple testing cases from the example, which saves compiling time and makes development easier.

The CMakeLists.txt will be like the following:

add_example_executable(example_exe  example_source.cpp)
add_example_test(example_test_case_1 example_exe arg1, arg2, ...)
add_example_test(example_test_case_2 example_exe arg2, arg2, ...)

qianfengz avatar May 22 '22 05:05 qianfengz

I think CMake does the equivalent thing under the hood. It resolves target dependency and reuses build cache where possible, so it doesn't rebuild the same binary more than once. Can you find a counter-example?

rosenrodt avatar May 26 '22 03:05 rosenrodt

How I add a different testing case using the same executable under the current framework ?

qianfengz avatar May 26 '22 04:05 qianfengz

I think I get what you mean now. Doing so does produce 2 executables and doubles compilation time. I was using ccache so I got the wrong impression that CMake will avoid compiling twice.

add_example_executable(example_gemm_xdl_fp16_test1 gemm_xdl_fp16.cpp)
add_example_executable(example_gemm_xdl_fp16_test2 gemm_xdl_fp16.cpp 0 1 10 7680 8192 8192 8192 8192 8192)

So yeah I agree this is lacking. But I lean more toward that add_example_executable by default will be run by CTest. And we add extra helper function to add extra test params for the example code.

rosenrodt avatar May 26 '22 04:05 rosenrodt

@qianfengz Is this ticket still relevant? If not, please close the ticket. Thanks!

ppanchad-amd avatar Aug 20 '24 18:08 ppanchad-amd