@@ -378,10 +378,17 @@ endif()
378
378
379
379
380
380
381
- # files generated by compile.py
382
- set (KERNEL_HIPRT_COMP "${BASE_OUTPUT_DIR} /${CMAKE_BUILD_TYPE} /hiprt${version_str_} _${HIP_VERSION_STR} _amd.hipfb" )
381
+ # files generated by compile.py and precompile_bitcode.py
382
+ if (WIN32 )
383
+ set (KERNEL_OS_POSTFIX "win" )
384
+ else ()
385
+ set (KERNEL_OS_POSTFIX "linux" )
386
+ endif ()
387
+ set (KERNEL_HIPRT_COMP "${BASE_OUTPUT_DIR} /${CMAKE_BUILD_TYPE} /hiprt${version_str_} _${HIP_VERSION_STR} _amd.hipfb" ) # example: hiprt02005_6.2_amd.hipfb
388
+ set (KERNEL_UNITTEST_COMP "${BASE_OUTPUT_DIR} /${CMAKE_BUILD_TYPE} /hiprt${version_str_} _${HIP_VERSION_STR} _precompiled_bitcode_${KERNEL_OS_POSTFIX} .hipfb" ) # example: hiprt02005_6.2_precompiled_bitcode_win.hipfb
383
389
set (KERNEL_OROCHI_COMP "${BASE_OUTPUT_DIR} /${CMAKE_BUILD_TYPE} /oro_compiled_kernels.hipfb" )
384
390
391
+
385
392
# precompile kernels:
386
393
if (PRECOMPILE)
387
394
@@ -434,11 +441,29 @@ if(PRECOMPILE)
434
441
)
435
442
436
443
if (NOT NO_UNITTEST)
437
- message (">> Execute: ${PYTHON_EXECUTABLE} precompile_bitcode.py ${CUDA_OPTION} --hipSdkPath \" ${HIP_FINAL_PATH} \" " )
438
- execute_process (
444
+
445
+ set (unittest_kernel_source
446
+ ${CMAKE_SOURCE_DIR} /test /bitcodes/custom_func_table.cpp
447
+ ${CMAKE_SOURCE_DIR} /test /bitcodes/unit_test.cpp
448
+ )
449
+
450
+ message (">> add_custom_command: ${PYTHON_EXECUTABLE} precompile_bitcode.py ${CUDA_OPTION} --hipSdkPath \" ${HIP_FINAL_PATH} \" " )
451
+ add_custom_command (
452
+ OUTPUT ${KERNEL_UNITTEST_COMP}
439
453
COMMAND ${PYTHON_EXECUTABLE} precompile_bitcode.py ${CUDA_OPTION} --hipSdkPath ${HIP_FINAL_PATH}
454
+ DEPENDS ${KERNEL_HIPRT_COMP} # Ensure compile.py has already run.
440
455
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} /scripts/bitcodes
456
+ COMMENT "Precompiling unit tests kernels via precompile_bitcode.py"
457
+ VERBATIM
458
+ DEPENDS ${unittest_kernel_source}
441
459
)
460
+
461
+ # create the 'precompile_unittest_kernels' project
462
+ add_custom_target (precompile_unittest_kernels ALL
463
+ DEPENDS ${KERNEL_UNITTEST_COMP}
464
+ )
465
+
466
+ add_dependencies (${HIPRT_NAME} precompile_unittest_kernels)
442
467
endif ()
443
468
444
469
0 commit comments