diff --git a/clang/lib/DPCT/APINames.inc b/clang/lib/DPCT/APINames.inc index b47051e76d35..d5f9855968f3 100644 --- a/clang/lib/DPCT/APINames.inc +++ b/clang/lib/DPCT/APINames.inc @@ -1779,7 +1779,7 @@ ENTRY(cuDriverGetVersion, cuDriverGetVersion, true, NO_FLAG, P4, "DPCT1043") ENTRY(cuEventCreateFromEGLSync, cuEventCreateFromEGLSync, false, NO_FLAG, P4, "comment") ENTRY(cuStreamWaitValue64, cuStreamWaitValue64_v2, false, NO_FLAG, P4, "comment") ENTRY(cuStreamWriteValue64, cuStreamWriteValue64_v2, false, NO_FLAG, P4, "comment") -ENTRY(cuFuncSetAttribute, cuFuncSetAttribute, false, NO_FLAG, P4, "comment") +ENTRY(cuFuncSetAttribute, cuFuncSetAttribute, true, API_CALL_REMOVED, P4, "DPCT1026") ENTRY(cuLaunchCooperativeKernel, cuLaunchCooperativeKernel, false, NO_FLAG, P4, "comment") ENTRY(cuLaunchCooperativeKernelMultiDevice, cuLaunchCooperativeKernelMultiDevice, false, NO_FLAG, P4, "comment") diff --git a/clang/lib/DPCT/APINamesMisc.inc b/clang/lib/DPCT/APINamesMisc.inc index efe0161fb2d4..efba461d9b59 100644 --- a/clang/lib/DPCT/APINamesMisc.inc +++ b/clang/lib/DPCT/APINamesMisc.inc @@ -124,5 +124,9 @@ CONDITIONAL_FACTORY_ENTRY( REMOVE_API_FACTORY_ENTRY_WITH_MSG("cudaProfilerStart", getRemovedAPIWarningMessage("cudaProfilerStart")) + REMOVE_API_FACTORY_ENTRY_WITH_MSG("cudaProfilerStop", getRemovedAPIWarningMessage("cudaProfilerStop")) + +REMOVE_API_FACTORY_ENTRY_WITH_MSG("cuFuncSetAttribute", + getRemovedAPIWarningMessage("cuFuncSetAttribute")) diff --git a/clang/lib/DPCT/APINames_removed.inc b/clang/lib/DPCT/APINames_removed.inc index b6ca2a8499c5..2436811bdd80 100644 --- a/clang/lib/DPCT/APINames_removed.inc +++ b/clang/lib/DPCT/APINames_removed.inc @@ -40,3 +40,4 @@ ENTRY(cuMemHostUnregister, "SYCL currently does not support register ENTRY(cudaProfilerStart, "SYCL currently does not support this function. Remove the profiler API will not impact the outcome.") ENTRY(cudaProfilerStop, "SYCL currently does not support this function. Remove the profiler API will not impact the outcome.") +ENTRY(cuFuncSetAttribute, "SYCL currently does not support setting kernel function attributes") diff --git a/clang/lib/DPCT/ASTTraversal.cpp b/clang/lib/DPCT/ASTTraversal.cpp index 192bd8023b37..e7cf928372cf 100644 --- a/clang/lib/DPCT/ASTTraversal.cpp +++ b/clang/lib/DPCT/ASTTraversal.cpp @@ -12302,6 +12302,10 @@ void KernelFunctionInfoRule::registerMatcher(MatchFinder &MF) { hasType(recordDecl(hasName("cudaFuncAttributes")))))) .bind("member"), this); + + MF.addMatcher(callExpr(callee(functionDecl(hasName("cuFuncSetAttribute")))) + .bind("cuFuncSetAttribute"), + this); } void KernelFunctionInfoRule::runRule(const MatchFinder::MatchResult &Result) { @@ -12329,6 +12333,20 @@ void KernelFunctionInfoRule::runRule(const MatchFinder::MatchResult &Result) { if (NameMap != AttributesNamesMap.end()) emplaceTransformation(new ReplaceToken(MemberName.getBeginLoc(), std::string(NameMap->second))); + + } else if (auto *CallNode = + getNodeAsType(Result, "cuFuncSetAttribute")) { + std::string FuncName = + CallNode->getDirectCallee()->getNameInfo().getName().getAsString(); + auto Msg = MapNames::RemovedAPIWarningMessage.find(FuncName); + + std::string CallReplacement{""}; + if (isAssigned(CallNode)) { + CallReplacement = "0"; + } + report(CallNode->getBeginLoc(), Diagnostics::FUNC_CALL_REMOVED, false, + MapNames::ITFName.at(FuncName), Msg->second); + emplaceTransformation(new ReplaceStmt(CallNode, CallReplacement)); } } diff --git a/clang/test/dpct/kernel-function-unsupported-cuda-8.cu b/clang/test/dpct/kernel-function-unsupported-cuda-8.cu new file mode 100644 index 000000000000..5b194456ec4f --- /dev/null +++ b/clang/test/dpct/kernel-function-unsupported-cuda-8.cu @@ -0,0 +1,20 @@ +// UNSUPPORTED: cuda-8.0 +// UNSUPPORTED: v8.0 +// RUN: dpct -out-root %T/kernel-function-unsupported-cuda-8 %s --cuda-include-path="%cuda-path/include" +// RUN: FileCheck --match-full-lines --input-file %T/kernel-function-unsupported-cuda-8/kernel-function-unsupported-cuda-8.dp.cpp %s +// RUN: %if build_lit %{icpx -c -fsycl %T/kernel-function-unsupported-cuda-8/kernel-function-unsupported-cuda-8.dp.cpp -o %T/kernel-function-unsupported-cuda-8/kernel-function-unsupported-cuda-8.dp.o %} + +void foo(void) { + CUfunction f; + // CHECK: /* + // CHECK-NEXT: DPCT1026:{{[0-9]+}}: The call to cuFuncSetAttribute was removed because SYCL currently does not support setting kernel function attributes + // CHECK-NEXT: */ + cuFuncSetAttribute(f, CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT, 1024); + + // CHECK: /* + // CHECK-NEXT: DPCT1026:{{[0-9]+}}: The call to cuFuncSetAttribute was removed because SYCL currently does not support setting kernel function attributes + // CHECK-NEXT: */ + // CHECK-NEXT: int result = 0; + CUresult result = cuFuncSetAttribute(f, CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT, 1024); + if (result == CUDA_SUCCESS) {;} +}