onnxruntime

Форк
0
/
Fix_Clang_Build.patch 
200 строк · 7.7 Кб
1
diff --git a/CMakeLists.txt b/CMakeLists.txt
2
index c23746e7f..bc326c8b5 100644
3
--- a/CMakeLists.txt
4
+++ b/CMakeLists.txt
5
@@ -23,10 +23,10 @@ endif()
6
 
7
 set(version 1.1.0)
8
 # Check support for CUDA/HIP in Cmake
9
-project(composable_kernel VERSION ${version} LANGUAGES CXX)
10
+project(composable_kernel VERSION ${version} LANGUAGES CXX HIP)
11
 include(CTest)
12
 
13
-find_package(Python3 3.6 COMPONENTS Interpreter REQUIRED)
14
+find_package(Python3 COMPONENTS Interpreter REQUIRED)
15
 
16
 list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
17
 
18
@@ -227,27 +227,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
19
 set(CMAKE_CXX_EXTENSIONS OFF)
20
 message("CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
21
 
22
-## OpenMP
23
-if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
24
-	# workaround issue hipcc in rocm3.5 cannot find openmp
25
-	set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
26
-	set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
27
-	set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp5")
28
-	set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
29
-	set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
30
-	set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
31
-else()
32
-	find_package(OpenMP REQUIRED)
33
-endif()
34
-
35
-message("OpenMP_CXX_LIB_NAMES: ${OpenMP_CXX_LIB_NAMES}")
36
-message("OpenMP_gomp_LIBRARY: ${OpenMP_gomp_LIBRARY}")
37
-message("OpenMP_pthread_LIBRARY: ${OpenMP_pthread_LIBRARY}")
38
-message("OpenMP_CXX_FLAGS: ${OpenMP_CXX_FLAGS}")
39
-
40
-link_libraries(${OpenMP_gomp_LIBRARY})
41
-link_libraries(${OpenMP_pthread_LIBRARY})
42
-
43
 ## HIP
44
 find_package(HIP REQUIRED)
45
 # Override HIP version in config.h, if necessary.
46
@@ -269,12 +248,6 @@ if( DEFINED CK_OVERRIDE_HIP_VERSION_PATCH )
47
     message(STATUS "CK_HIP_VERSION_PATCH overridden with ${CK_OVERRIDE_HIP_VERSION_PATCH}")
48
 endif()
49
 message(STATUS "Build with HIP ${HIP_VERSION}")
50
-link_libraries(hip::device)
51
-if(CK_hip_VERSION VERSION_GREATER_EQUAL 6.0.23494)
52
-    add_compile_definitions(__HIP_PLATFORM_AMD__=1)
53
-else()
54
-    add_compile_definitions(__HIP_PLATFORM_HCC__=1)
55
-endif()
56
 
57
 ## tidy
58
 include(EnableCompilerWarnings)
59
@@ -541,11 +514,3 @@ rocm_install(FILES
60
 
61
 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
62
 set(CPACK_RPM_PACKAGE_LICENSE "MIT")
63
-
64
-rocm_create_package(
65
-    NAME composablekernel
66
-    DESCRIPTION "High Performance Composable Kernel for AMD GPUs"
67
-    MAINTAINER "MIOpen Kernels Dev Team <dl.MIOpen@amd.com>"
68
-    LDCONFIG
69
-    HEADER_ONLY
70
-)
71
diff --git a/example/ck_tile/01_fmha/generate.py b/example/ck_tile/01_fmha/generate.py
72
index 51fecd07b..5ed371995 100644
73
--- a/example/ck_tile/01_fmha/generate.py
74
+++ b/example/ck_tile/01_fmha/generate.py
75
@@ -566,7 +566,7 @@ def write_blobs(output_dir : Optional[str], kernel_filter : Optional[str], recei
76
 def list_blobs(output_file : Optional[str], kernel_filter : Optional[str], receipt, mask_impl) -> None:
77
     assert output_file is not None
78
     file_path = Path(output_file)
79
-    with file_path.open('a') as f:
80
+    with file_path.open('w') as f:
81
         _, kernels = get_blobs(kernel_filter, receipt, mask_impl)
82
         for kernel in kernels:
83
             f.write(str(file_path.parent / GEN_DIR / kernel.filename) + "\n")
84
diff --git a/include/ck/host_utility/hip_check_error.hpp b/include/ck/host_utility/hip_check_error.hpp
85
index c0894f1d7..559481fee 100644
86
--- a/include/ck/host_utility/hip_check_error.hpp
87
+++ b/include/ck/host_utility/hip_check_error.hpp
88
@@ -6,19 +6,7 @@
89
 #include <sstream>
90
 #include <hip/hip_runtime.h>
91
 
92
-// To be removed, which really does not tell the location of failed HIP functional call
93
-inline void hip_check_error(hipError_t x)
94
-{
95
-    if(x != hipSuccess)
96
-    {
97
-        std::ostringstream ss;
98
-        ss << "HIP runtime error: " << hipGetErrorString(x) << ". "
99
-           << "hip_check_error.hpp"
100
-           << ": " << __LINE__ << "in function: " << __func__;
101
-        throw std::runtime_error(ss.str());
102
-    }
103
-}
104
-
105
+#ifndef HIP_CHECK_ERROR
106
 #define HIP_CHECK_ERROR(retval_or_funcall)                                 \
107
     do                                                                     \
108
     {                                                                      \
109
@@ -32,3 +20,9 @@ inline void hip_check_error(hipError_t x)
110
             throw std::runtime_error(ostr.str());                          \
111
         }                                                                  \
112
     } while(0)
113
+#endif
114
+
115
+#ifndef hip_check_error
116
+#define hip_check_error HIP_CHECK_ERROR
117
+#endif
118
+
119
diff --git a/include/ck_tile/core/utility/transpose_vectors.hpp b/include/ck_tile/core/utility/transpose_vectors.hpp
120
index a164c3f94..293ead89a 100644
121
--- a/include/ck_tile/core/utility/transpose_vectors.hpp
122
+++ b/include/ck_tile/core/utility/transpose_vectors.hpp
123
@@ -11,6 +11,9 @@
124
 
125
 namespace ck_tile {
126
 
127
+template <typename... Ts>
128
+constexpr bool always_false = false;
129
+
130
 // S: scalar type (or it can be non-scalar type)
131
 // NX: # of vector before transpose
132
 // NY: # of vector after transpose
133
@@ -117,9 +120,11 @@ struct transpose_vectors
134
         }
135
         else
136
         {
137
-            static_assert(false, "not implemented");
138
+            static_assert(always_false<S_, number<NX>, number<NY>>, "not implemented");
139
         }
140
     }
141
 };
142
 
143
+
144
 } // namespace ck_tile
145
+
146
diff --git a/include/ck_tile/host/hip_check_error.hpp b/include/ck_tile/host/hip_check_error.hpp
147
index 3acdb4d87..cc26e184f 100644
148
--- a/include/ck_tile/host/hip_check_error.hpp
149
+++ b/include/ck_tile/host/hip_check_error.hpp
150
@@ -8,20 +8,7 @@
151
 #include <stdexcept>
152
 #include <hip/hip_runtime.h>
153
 
154
-namespace ck_tile {
155
-// To be removed, which really does not tell the location of failed HIP functional call
156
-CK_TILE_HOST void hip_check_error(hipError_t x)
157
-{
158
-    if(x != hipSuccess)
159
-    {
160
-        std::ostringstream ss;
161
-        ss << "HIP runtime error: " << hipGetErrorString(x) << ". " << __FILE__ << ": " << __LINE__
162
-           << "in function: " << __func__;
163
-        throw std::runtime_error(ss.str());
164
-    }
165
-}
166
-} // namespace ck_tile
167
-
168
+#ifndef HIP_CHECK_ERROR
169
 #define HIP_CHECK_ERROR(retval_or_funcall)                                         \
170
     do                                                                             \
171
     {                                                                              \
172
@@ -34,3 +21,9 @@ CK_TILE_HOST void hip_check_error(hipError_t x)
173
             throw std::runtime_error(ostr.str());                                  \
174
         }                                                                          \
175
     } while(0)
176
+#endif
177
+
178
+#ifndef hip_check_error
179
+#define hip_check_error HIP_CHECK_ERROR
180
+#endif
181
+
182
diff --git a/library/src/tensor_operation_instance/gpu/CMakeLists.txt b/library/src/tensor_operation_instance/gpu/CMakeLists.txt
183
index c035e7e56..8c5f36d2e 100644
184
--- a/library/src/tensor_operation_instance/gpu/CMakeLists.txt
185
+++ b/library/src/tensor_operation_instance/gpu/CMakeLists.txt
186
@@ -59,8 +59,14 @@ function(add_instance_library INSTANCE_NAME)
187
     endforeach()
188
     #only continue if there are some source files left on the list
189
     if(ARGN)
190
+        set_source_files_properties(${ARGN} PROPERTIES LANGUAGE HIP)
191
         add_library(${INSTANCE_NAME} OBJECT ${ARGN})
192
+        # Always disable debug symbol and C debug assert due to
193
+        # - Linker error: ... relocation truncated to fit ..., caused by object files to be linked are too huge.
194
+        # - https://github.com/ROCmSoftwarePlatform/composable_kernel/issues/622
195
+        target_compile_options(${INSTANCE_NAME} PRIVATE -g0 -DNDEBUG)
196
         target_compile_features(${INSTANCE_NAME} PUBLIC)
197
+        target_compile_definitions(${INSTANCE_NAME} PRIVATE "__HIP_PLATFORM_AMD__=1" "__HIP_PLATFORM_HCC__=1")
198
         set_target_properties(${INSTANCE_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
199
         clang_tidy_check(${INSTANCE_NAME})
200
         set(result 0)
201

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.