mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
[Windows][ROCm] Fix c10 hip tests (#146599)
- Solves a problem related to .hip source files being ignored by the build system when HIP language is not enabled in CMake. - Also ensures that the test executables link to an appropriate CRT Runtime Library and hence have access to all the necessary symbols. Previously, there were many problems related to linkage errors. - Moves part of Linux-related hipBLASLt changes in `LoadHIP.cmake` under the UNIX conditional branch, as these aren't supported on Windows yet. Pull Request resolved: https://github.com/pytorch/pytorch/pull/146599 Approved by: https://github.com/jeffdaily
This commit is contained in:
parent
e13a544b54
commit
3f5ed05688
3 changed files with 50 additions and 29 deletions
|
|
@ -14,7 +14,13 @@ if(BUILD_TEST)
|
|||
foreach(test_src ${C10_CUDA_ALL_TEST_FILES})
|
||||
get_filename_component(test_file_name ${test_src} NAME_WE)
|
||||
set(test_name "c10_cuda_${test_file_name}")
|
||||
add_executable(${test_name} "${test_src}")
|
||||
if(WIN32 AND test_src MATCHES "^.*\.hip$")
|
||||
set_source_files_properties(${test_src} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
|
||||
hip_add_executable(${test_name} "${test_src}")
|
||||
set_target_properties(${test_name} PROPERTIES LINKER_LANGUAGE CXX HIP_ARCHITECTURES ${PYTORCH_ROCM_ARCH})
|
||||
else()
|
||||
add_executable(${test_name} "${test_src}")
|
||||
endif()
|
||||
target_link_libraries(${test_name} ${C10_CUDA_LIB} ${C10_LIB} gtest_main)
|
||||
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
||||
if(INSTALL_TEST)
|
||||
|
|
|
|||
|
|
@ -1013,7 +1013,23 @@ if(USE_ROCM)
|
|||
caffe2_update_option(USE_SYSTEM_NCCL ON)
|
||||
endif()
|
||||
|
||||
list(APPEND HIP_CXX_FLAGS -fPIC)
|
||||
if(WIN32)
|
||||
if(${CAFFE2_USE_MSVC_STATIC_RUNTIME})
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
list(APPEND HIP_CXX_FLAGS -fms-runtime-lib=static_dbg)
|
||||
else()
|
||||
list(APPEND HIP_CXX_FLAGS -fms-runtime-lib=static)
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
list(APPEND HIP_CXX_FLAGS -fms-runtime-lib=dll_dbg)
|
||||
else()
|
||||
list(APPEND HIP_CXX_FLAGS -fms-runtime-lib=dll)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
list(APPEND HIP_CXX_FLAGS -fPIC)
|
||||
endif()
|
||||
list(APPEND HIP_CXX_FLAGS -D__HIP_PLATFORM_AMD__=1)
|
||||
list(APPEND HIP_CXX_FLAGS -DCUDA_HAS_FP16=1)
|
||||
list(APPEND HIP_CXX_FLAGS -DUSE_ROCM)
|
||||
|
|
|
|||
|
|
@ -192,35 +192,34 @@ if(HIP_FOUND)
|
|||
#message("HIP is NOT using new type enums: ${hip_compile_output}")
|
||||
message("HIP is NOT using new type enums")
|
||||
endif()
|
||||
|
||||
if(ROCM_VERSION_DEV VERSION_GREATER_EQUAL "5.7.0")
|
||||
# check whether hipblaslt provides HIPBLASLT_MATMUL_DESC_A_SCALE_POINTER_VEC_EXT
|
||||
set(file "${PROJECT_BINARY_DIR}/hipblaslt_test_vec_ext.cc")
|
||||
file(WRITE ${file} ""
|
||||
"#define LEGACY_HIPBLAS_DIRECT\n"
|
||||
"#include <hipblaslt/hipblaslt.h>\n"
|
||||
"int main() {\n"
|
||||
" hipblasLtMatmulDescAttributes_t attr = HIPBLASLT_MATMUL_DESC_A_SCALE_POINTER_VEC_EXT;\n"
|
||||
" return 0;\n"
|
||||
"}\n"
|
||||
)
|
||||
try_compile(hipblaslt_compile_result_vec_ext ${PROJECT_RANDOM_BINARY_DIR} ${file}
|
||||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${ROCM_INCLUDE_DIRS}"
|
||||
COMPILE_DEFINITIONS -D__HIP_PLATFORM_AMD__ -D__HIP_PLATFORM_HCC__
|
||||
OUTPUT_VARIABLE hipblaslt_compile_output)
|
||||
if(hipblaslt_compile_result_vec_ext)
|
||||
set(HIPBLASLT_VEC_EXT ON)
|
||||
#message("hipblaslt is using scale pointer vec ext: ${hipblaslt_compile_output}")
|
||||
message("hipblaslt is using scale pointer vec ext")
|
||||
else()
|
||||
set(HIPBLASLT_VEC_EXT OFF)
|
||||
message("hipblaslt is NOT using scale pointer vec ext: ${hipblaslt_compile_output}")
|
||||
#message("hipblaslt is NOT using scale pointer vec ext")
|
||||
endif()
|
||||
endif()
|
||||
else() # Win32
|
||||
# With HIP-SDK 6.2, HIP declares new enum types on Windows
|
||||
set(HIP_NEW_TYPE_ENUMS ON)
|
||||
endif()
|
||||
|
||||
if(ROCM_VERSION_DEV VERSION_GREATER_EQUAL "5.7.0")
|
||||
# check whether hipblaslt provides HIPBLASLT_MATMUL_DESC_A_SCALE_POINTER_VEC_EXT
|
||||
set(file "${PROJECT_BINARY_DIR}/hipblaslt_test_vec_ext.cc")
|
||||
file(WRITE ${file} ""
|
||||
"#define LEGACY_HIPBLAS_DIRECT\n"
|
||||
"#include <hipblaslt/hipblaslt.h>\n"
|
||||
"int main() {\n"
|
||||
" hipblasLtMatmulDescAttributes_t attr = HIPBLASLT_MATMUL_DESC_A_SCALE_POINTER_VEC_EXT;\n"
|
||||
" return 0;\n"
|
||||
"}\n"
|
||||
)
|
||||
try_compile(hipblaslt_compile_result_vec_ext ${PROJECT_RANDOM_BINARY_DIR} ${file}
|
||||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${ROCM_INCLUDE_DIRS}"
|
||||
COMPILE_DEFINITIONS -D__HIP_PLATFORM_AMD__ -D__HIP_PLATFORM_HCC__
|
||||
OUTPUT_VARIABLE hipblaslt_compile_output)
|
||||
if(hipblaslt_compile_result_vec_ext)
|
||||
set(HIPBLASLT_VEC_EXT ON)
|
||||
#message("hipblaslt is using scale pointer vec ext: ${hipblaslt_compile_output}")
|
||||
message("hipblaslt is using scale pointer vec ext")
|
||||
else()
|
||||
set(HIPBLASLT_VEC_EXT OFF)
|
||||
message("hipblaslt is NOT using scale pointer vec ext: ${hipblaslt_compile_output}")
|
||||
#message("hipblaslt is NOT using scale pointer vec ext")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
|
|
|||
Loading…
Reference in a new issue