Skip to content

Commit e251b18

Browse files
authored
[SYCLomatic] Skip migrate the user defined vector type. (#2833)
Signed-off-by: Chen, Sheng S <sheng.s.chen@intel.com>
1 parent 6355985 commit e251b18

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

clang/lib/DPCT/RulesLang/RulesLang.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -298,15 +298,15 @@ void TypeInDeclRule::registerMatcher(MatchFinder &MF) {
298298
"dim3", "cudaError", "curandStatus", "cublasStatus", "CUstream",
299299
"CUstream_st", "thrust::complex", "thrust::device_vector",
300300
"thrust::device_ptr", "thrust::device_reference",
301-
"thrust::host_vector", "cublasHandle_t", "CUevent_st", "__half",
302-
"half", "__half2", "half2", "cudaMemoryAdvise", "cudaError_enum",
303-
"cudaDeviceProp", "cudaStreamCaptureStatus",
304-
"cudaGraphExecUpdateResult", "cudaPitchedPtr",
305-
"thrust::counting_iterator", "thrust::transform_iterator",
306-
"thrust::permutation_iterator", "thrust::iterator_difference",
307-
"cusolverDnHandle_t", "cusolverDnParams_t", "gesvdjInfo_t",
308-
"syevjInfo_t", "thrust::device_malloc_allocator",
309-
"thrust::divides", thrustNamespace() + "tuple", "thrust::maximum",
301+
"thrust::host_vector", "cublasHandle_t", "CUevent_st",
302+
"cudaMemoryAdvise", "cudaError_enum", "cudaDeviceProp",
303+
"cudaStreamCaptureStatus", "cudaGraphExecUpdateResult",
304+
"cudaPitchedPtr", "thrust::counting_iterator",
305+
"thrust::transform_iterator", "thrust::permutation_iterator",
306+
"thrust::iterator_difference", "cusolverDnHandle_t",
307+
"cusolverDnParams_t", "gesvdjInfo_t", "syevjInfo_t",
308+
"thrust::device_malloc_allocator", "thrust::divides",
309+
thrustNamespace() + "tuple", "thrust::maximum",
310310
"thrust::multiplies", "thrust::plus", "cudaDataType_t",
311311
"cudaError_t", "CUresult", "CUdevice", "cudaEvent_t",
312312
"cublasStatus_t", "cuComplex", "cuFloatComplex",
@@ -330,8 +330,7 @@ void TypeInDeclRule::registerMatcher(MatchFinder &MF) {
330330
"cufftResult_t", "cufftResult", "cufftType_t", "cufftType",
331331
thrustNamespace() + "pair", "CUdeviceptr", "cudaDeviceAttr",
332332
"CUmodule", "CUjit_option", "CUfunction", "cudaMemcpyKind",
333-
"cudaComputeMode", "__nv_bfloat16",
334-
"cooperative_groups::__v1::thread_group",
333+
"cudaComputeMode", "cooperative_groups::__v1::thread_group",
335334
"cooperative_groups::__v1::thread_block", "libraryPropertyType_t",
336335
"libraryPropertyType", "cudaDataType_t", "cudaDataType",
337336
"cublasComputeType_t", "cublasAtomicsMode_t", "cublasMath_t",
@@ -360,8 +359,8 @@ void TypeInDeclRule::registerMatcher(MatchFinder &MF) {
360359
"cublasLtMatrixTransformDesc_t", "cudaGraphicsMapFlags",
361360
"cudaGraphicsRegisterFlags", "cudaExternalMemoryHandleType",
362361
"cudaExternalSemaphoreHandleType", "CUstreamCallback",
363-
"cudaHostFn_t", "__nv_half2", "__nv_half", "cudaGraphNodeType",
364-
"CUsurfref", "CUdevice_P2PAttribute", "cudaIpcMemHandle_t"))))))
362+
"cudaHostFn_t", "cudaGraphNodeType", "CUsurfref",
363+
"CUdevice_P2PAttribute", "cudaIpcMemHandle_t"))))))
365364
.bind("cudaTypeDef"),
366365
this);
367366

@@ -1300,7 +1299,11 @@ void VectorTypeNamespaceRule::runRule(const MatchFinder::MatchResult &Result) {
13001299
if (!DpctGlobalInfo::isInCudaPath(RecDeclRepr->getBeginLoc()))
13011300
return;
13021301
}
1303-
1302+
auto TypePtr = TL->getTypePtr();
1303+
const auto *TT = dyn_cast<TypedefType>(TypePtr);
1304+
if (TT && !isRedeclInCUDAHeader(TT)) {
1305+
return;
1306+
}
13041307
auto BeginLoc =
13051308
getDefinitionRange(TL->getBeginLoc(), TL->getEndLoc()).getBegin();
13061309

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: dpct --format-range=none -in-root %S -out-root %T/skip_migrate_typedef_vec_type %s -cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
2+
// RUN: FileCheck --input-file %T/skip_migrate_typedef_vec_type/skip_migrate_typedef_vec_type.dp.cpp --match-full-lines %s
3+
// RUN: %if build_lit %{icpx -c -fsycl %T/skip_migrate_typedef_vec_type/skip_migrate_typedef_vec_type.dp.cpp -o %T/skip_migrate_typedef_vec_type/skip_migrate_typedef_vec_type.dp.o %}
4+
5+
6+
#include <cuda_fp16.h>
7+
8+
namespace mma {
9+
// CHECK: using half2 = sycl::half;
10+
using half2 = __nv_half;
11+
};
12+
template <class T>
13+
void test_t(T t) {
14+
}
15+
int main() {
16+
// CHECK: mma::half2 test;
17+
mma::half2 test;
18+
// CHECK: test_t<mma::half2>(test);
19+
test_t<mma::half2>(test);
20+
return 0;
21+
}

0 commit comments

Comments
 (0)