Skip to content

Commit d527fb5

Browse files
authored
[DCU] fix dcu compile failure (#62573)
1 parent fbf852d commit d527fb5

File tree

7 files changed

+47
-10
lines changed

7 files changed

+47
-10
lines changed

cmake/generic.cmake

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -758,12 +758,6 @@ function(hip_library TARGET_NAME)
758758
cmake_parse_arguments(hip_library "${options}" "${oneValueArgs}"
759759
"${multiValueArgs}" ${ARGN})
760760
if(hip_library_SRCS)
761-
# FindHIP.cmake defined hip_add_library, HIP_SOURCE_PROPERTY_FORMAT is requried if no .cu files found
762-
if(NOT (${CMAKE_CURRENT_SOURCE_DIR} MATCHES ".*/operators"
763-
OR ${CMAKE_CURRENT_SOURCE_DIR} MATCHES ".*/phi/kernels"))
764-
set_source_files_properties(${hip_library_SRCS}
765-
PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
766-
endif()
767761
if(hip_library_SHARED OR hip_library_shared) # build *.so
768762
hip_add_library(${TARGET_NAME} SHARED ${hip_library_SRCS})
769763
else()
@@ -777,6 +771,10 @@ function(hip_library TARGET_NAME)
777771
endif()
778772
# cpplint code style
779773
foreach(source_file ${hip_library_SRCS})
774+
if(NOT ${source_file} MATCHES "\\.cu$")
775+
set_source_files_properties(${source_file}
776+
PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
777+
endif()
780778
string(REGEX REPLACE "\\.[^.]*$" "" source ${source_file})
781779
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source}.h)
782780
list(APPEND hip_library_HEADERS

paddle/phi/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,11 @@ if(WITH_GPU)
134134
SRCS ${PHI_SRCS}
135135
DEPS ${PHI_DEPS})
136136
elseif(WITH_ROCM)
137-
hip_add_library(phi ${PHI_BUILD_TYPE} ${PHI_SRCS})
138-
target_link_libraries(phi ${PHI_DEPS})
137+
hip_library(
138+
phi ${PHI_BUILD_TYPE}
139+
SRCS ${PHI_SRCS}
140+
DEPS ${PHI_DEPS})
141+
139142
elseif(WITH_XPU_KP)
140143
xpu_library(
141144
phi ${PHI_BUILD_TYPE}

paddle/phi/core/visit_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ namespace phi {
355355
"`"); \
356356
} \
357357
}()
358-
#if defined(PADDLE_WITH_XPU)
358+
#if defined(PADDLE_WITH_XPU) || defined(PADDLE_WITH_HIP)
359359
#define PD_VISIT_ALL_TYPES(TYPE, NAME, ...) \
360360
[&] { \
361361
const auto& __dtype__ = TYPE; \

paddle/phi/kernels/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,32 @@ if(NOT WITH_CUDNN_FRONTEND)
177177
"fusion/gpu/fused_dconv_drelu_dbn_kernel.cu")
178178
endif()
179179

180+
# Note(qili93): remove kernels not supported on DCU yet
181+
if(WITH_ROCM)
182+
list(
183+
REMOVE_ITEM
184+
kernel_cu
185+
"gpu/affine_grid_grad_kernel.cu"
186+
"gpu/apply_per_channel_scale_kernel.cu"
187+
"gpu/cholesky_solve_kernel.cu"
188+
"gpu/eigh_kernel.cu"
189+
"gpu/eigvalsh_kernel.cu"
190+
"gpu/lstsq_kernel.cu"
191+
"gpu/lu_kernel.cu"
192+
"gpu/matrix_rank_kernel.cu"
193+
"gpu/matrix_rank_tol_kernel.cu"
194+
"gpu/multiclass_nms3_kernel.cu"
195+
"gpu/put_along_axis_grad_kernel.cu"
196+
"gpu/put_along_axis_kernel.cu"
197+
"gpu/qr_kernel.cu"
198+
"gpu/svd_kernel.cu"
199+
"gpudnn/mha_cudnn_frontend.cu"
200+
"fusion/gpu/block_multi_head_attention_kernel.cu"
201+
"fusion/gpu/fused_bn_add_activation_grad_kernel.cu"
202+
"fusion/gpu/fused_bn_add_activation_kernel.cu"
203+
"fusion/gpu/fusion_transpose_flatten_concat_kernel.cu")
204+
endif()
205+
180206
set(cc_search_pattern
181207
"*.cc"
182208
"cpu/*.cc"

paddle/phi/kernels/funcs/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@ if(WITH_GPU OR WITH_ROCM)
1515
"*.cu")
1616
endif()
1717

18+
# Note(qili93): remove kernels not supported on DCU yet
19+
if(WITH_ROCM)
20+
list(REMOVE_ITEM func_cu_srcs "weight_only_gemv.cu")
21+
endif()
22+
1823
collect_srcs(kernels_srcs SRCS ${func_cc_srcs} ${func_cu_srcs})

paddle/phi/kernels/gpu/top_p_sampling_kernel.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ __device__ __forceinline__ void BlockReduce(Pair<T> shared_max[],
290290
if (*beam >= MaxLength) break;
291291
} else {
292292
#ifdef PADDLE_WITH_HIP
293-
uint64 mask = 0;
293+
unsigned mask = 0u;
294294
mask = __ballot(true);
295295
if (tid_max / WARP_SIZE == wid) {
296296
if (__shfl_down(*beam, tid_max % WARP_SIZE, WARP_SIZE) == MaxLength)

paddle/phi/kernels/gpu/unique_kernel.cu

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626
#include <iostream>
2727
#include <vector>
2828

29+
#ifdef PADDLE_WITH_CUDA
2930
#include "cub/cub.cuh"
31+
#else
32+
#include <hipcub/hipcub.hpp>
33+
namespace cub = hipcub;
34+
#endif
3035
#include "paddle/phi/backends/gpu/gpu_context.h"
3136
#include "paddle/phi/common/memory_utils.h"
3237
#include "paddle/phi/core/kernel_registry.h"

0 commit comments

Comments
 (0)