@@ -96,91 +96,71 @@ if(BUILD_TESTS)
9696 set (gtest_force_shared_crt ON CACHE BOOL "" FORCE )
9797 FetchContent_MakeAvailable (googletest)
9898
99- add_executable (test_sgemm tests/test_sgemm.cu )
100- target_include_directories (test_sgemm PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /src )
101- target_compile_definitions (test_sgemm PRIVATE SGEMM_HAS_WMMA_TARGET=${SGEMM_HAS_WMMA_TARGET} )
102- target_link_options (test_sgemm PRIVATE -L${SGEMM_CUDA_LIBRARY_DIR} )
103- target_link_libraries (test_sgemm PRIVATE
104- GTest::gtest_main
105- CUDA::cudart
106- CUDA::cublas
107- CUDA::curand
108- )
109- target_compile_options (test_sgemm PRIVATE
110- $<$<COMPILE_LANGUAGE :CUDA >:--expt -relaxed -constexpr >
111- )
99+ include (GoogleTest )
112100
113- # 工具层测试
114- add_executable (test_utils tests/test_utils.cu )
115- target_include_directories (test_utils PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /src )
116- target_compile_definitions (test_utils PRIVATE SGEMM_HAS_WMMA_TARGET=${SGEMM_HAS_WMMA_TARGET} )
117- target_link_options (test_utils PRIVATE -L${SGEMM_CUDA_LIBRARY_DIR} )
118- target_link_libraries (test_utils PRIVATE
119- GTest::gtest_main
120- CUDA::cudart
121- CUDA::cublas
122- CUDA::curand
123- )
124- target_compile_options (test_utils PRIVATE
125- $<$<COMPILE_LANGUAGE :CUDA >:--expt -relaxed -constexpr >
126- )
101+ # Include test helper functions
102+ include (cmake/SgemmTestHelpers.cmake )
127103
128- # 性能回归测试
129- add_executable (test_performance tests/test_performance.cu )
130- target_include_directories (test_performance PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /src )
131- target_compile_definitions (test_performance PRIVATE SGEMM_HAS_WMMA_TARGET=${SGEMM_HAS_WMMA_TARGET} )
132- target_link_options (test_performance PRIVATE -L${SGEMM_CUDA_LIBRARY_DIR} )
133- target_link_libraries (test_performance PRIVATE
134- GTest::gtest_main
135- CUDA::cudart
136- CUDA::cublas
137- CUDA::curand
138- )
139- target_compile_options (test_performance PRIVATE
140- $<$<COMPILE_LANGUAGE :CUDA >:--expt -relaxed -constexpr >
104+ # ═══════════════════════════════════════════════════════════════
105+ # CPU-only Tests (no CUDA required)
106+ # ═══════════════════════════════════════════════════════════════
107+
108+ # Benchmark settings module test - pure C++, no CUDA dependencies
109+ sgemm_add_cpu_test (
110+ NAME test_benchmark_settings
111+ SOURCES tests/test_benchmark_settings.cpp
141112 )
142113
143- # Benchmark 设置模块测试
144- add_executable (test_benchmark_settings tests/test_benchmark_settings.cu )
145- target_include_directories (test_benchmark_settings PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /src )
146- target_link_libraries (test_benchmark_settings PRIVATE
147- GTest::gtest_main
148- CUDA::cudart
149- CUDA::cublas
114+ # Device info provider CPU tests - uses fake device properties
115+ # Compiled as .cu because it includes kernel headers with CUDA launch syntax
116+ sgemm_add_cpu_test (
117+ NAME test_device_info_cpu
118+ SOURCES tests/test_device_info_cpu.cu
150119 )
151- target_compile_options (test_benchmark_settings PRIVATE
152- $<$<COMPILE_LANGUAGE :CUDA >:--expt -relaxed -constexpr >
120+
121+ # ═══════════════════════════════════════════════════════════════
122+ # CUDA Tests (requires CUDA device, skipped if unavailable)
123+ # ═══════════════════════════════════════════════════════════════
124+
125+ # Kernel correctness tests with property-based testing
126+ sgemm_add_cuda_test (
127+ NAME test_sgemm
128+ SOURCES tests/test_sgemm.cu
129+ CUDA_LIBRARIES CUDA::curand
130+ REQUIRES_WMMA
153131 )
154132
155- # Kernel catalog module test
156- add_executable (test_kernel_catalog tests/test_kernel_catalog.cu )
157- target_include_directories (test_kernel_catalog PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /src )
158- target_link_libraries (test_kernel_catalog PRIVATE
159- GTest::gtest_main
160- CUDA::cudart
161- CUDA::cublas
133+ # Utility layer tests (DeviceMemory, verifier RAII, etc.)
134+ sgemm_add_cuda_test (
135+ NAME test_utils
136+ SOURCES tests/test_utils.cu
137+ CUDA_LIBRARIES CUDA::curand
138+ REQUIRES_WMMA
162139 )
163- target_compile_options (test_kernel_catalog PRIVATE
164- $<$<COMPILE_LANGUAGE :CUDA >:--expt -relaxed -constexpr >
140+
141+ # Kernel catalog module test - requires device memory and kernel launch
142+ sgemm_add_cuda_test (
143+ NAME test_kernel_catalog
144+ SOURCES tests/test_kernel_catalog.cu
145+ REQUIRES_WMMA
165146 )
166147
167- # Device info seam test
168- add_executable (test_device_info_seam tests/test_device_info_seam.cu )
169- target_include_directories (test_device_info_seam PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } /src )
170- target_link_libraries (test_device_info_seam PRIVATE
171- GTest::gtest_main
172- CUDA::cudart
173- CUDA::cublas
148+ # Device info provider CUDA tests - requires real GPU for production adapter
149+ sgemm_add_cuda_test (
150+ NAME test_device_info_cuda
151+ SOURCES tests/test_device_info_cuda.cu
174152 )
175- target_compile_options (test_device_info_seam PRIVATE
176- $<$<COMPILE_LANGUAGE :CUDA >:--expt -relaxed -constexpr >
153+
154+ # ═══════════════════════════════════════════════════════════════
155+ # Performance Tests (CUDA + performance label)
156+ # ═══════════════════════════════════════════════════════════════
157+
158+ # Performance regression tests
159+ sgemm_add_cuda_perf_test (
160+ NAME test_performance
161+ SOURCES tests/test_performance.cu
162+ CUDA_LIBRARIES CUDA::curand
163+ REQUIRES_WMMA
177164 )
178165
179- include (GoogleTest )
180- gtest_discover_tests (test_sgemm )
181- gtest_discover_tests (test_utils )
182- gtest_discover_tests (test_performance )
183- gtest_discover_tests (test_benchmark_settings )
184- gtest_discover_tests (test_kernel_catalog )
185- gtest_discover_tests (test_device_info_seam )
186166endif ()
0 commit comments