diff --git a/clang/lib/DPCT/RulesLang/APINamesGraph.inc b/clang/lib/DPCT/RulesLang/APINamesGraph.inc index 75996e10fe90..566460c831b6 100644 --- a/clang/lib/DPCT/RulesLang/APINamesGraph.inc +++ b/clang/lib/DPCT/RulesLang/APINamesGraph.inc @@ -97,3 +97,10 @@ ASSIGNABLE_FACTORY(CONDITIONAL_FACTORY_ENTRY( Diagnostics::TRY_EXPERIMENTAL_FEATURE, ARG("cudaGraphGetRootNodes"), ARG("--use-experimental-features=graph")))) + +ASSIGNABLE_FACTORY(CONDITIONAL_FACTORY_ENTRY( + UseExtGraph, DELETE_FACTORY_ENTRY("cudaGraphDestroy", ARG(0)), + UNSUPPORT_FACTORY_ENTRY("cudaGraphDestroy", + Diagnostics::TRY_EXPERIMENTAL_FEATURE, + ARG("cudaGraphDestroy"), + ARG("--use-experimental-features=graph")))) diff --git a/clang/lib/DPCT/RulesLang/RulesLangGraph.cpp b/clang/lib/DPCT/RulesLang/RulesLangGraph.cpp index de375dc51b36..892a71e34d9c 100644 --- a/clang/lib/DPCT/RulesLang/RulesLangGraph.cpp +++ b/clang/lib/DPCT/RulesLang/RulesLangGraph.cpp @@ -34,7 +34,7 @@ void GraphRule::registerMatcher(MatchFinder &MF) { "cudaGraphExecDestroy", "cudaGraphAddEmptyNode", "cudaGraphAddDependencies", "cudaGraphExecUpdate", "cudaGraphNodeGetType", "cudaGraphGetNodes", - "cudaGraphGetRootNodes"); + "cudaGraphGetRootNodes", "cudaGraphDestroy"); }; MF.addMatcher( callExpr(callee(functionDecl(functionName()))).bind("FunctionCall"), diff --git a/clang/lib/DPCT/SrcAPI/APINames.inc b/clang/lib/DPCT/SrcAPI/APINames.inc index 41d9349f38d5..266afea31cf9 100644 --- a/clang/lib/DPCT/SrcAPI/APINames.inc +++ b/clang/lib/DPCT/SrcAPI/APINames.inc @@ -419,7 +419,7 @@ ENTRY(cudaGraphClone, cudaGraphClone, false, NO_FLAG, P4, "comment") ENTRY(cudaGraphConditionalHandleCreate, cudaGraphConditionalHandleCreate, false, NO_FLAG, P4, "comment") ENTRY(cudaGraphCreate, cudaGraphCreate, false, NO_FLAG, P4, "comment") ENTRY(cudaGraphDebugDotPrint, cudaGraphDebugDotPrint, false, NO_FLAG, P4, "comment") -ENTRY(cudaGraphDestroy, cudaGraphDestroy, false, NO_FLAG, P4, "comment") +ENTRY(cudaGraphDestroy, cudaGraphDestroy, true, NO_FLAG, P4, "Successful/DPCT1119") ENTRY(cudaGraphDestroyNode, cudaGraphDestroyNode, false, NO_FLAG, P4, "comment") ENTRY(cudaGraphEventRecordNodeGetEvent, cudaGraphEventRecordNodeGetEvent, false, NO_FLAG, P4, "comment") ENTRY(cudaGraphEventRecordNodeSetEvent, cudaGraphEventRecordNodeSetEvent, false, NO_FLAG, P4, "comment") diff --git a/clang/test/dpct/cudaGraph_test.cu b/clang/test/dpct/cudaGraph_test.cu index 2b02f4c4f24e..f0b5742386f7 100644 --- a/clang/test/dpct/cudaGraph_test.cu +++ b/clang/test/dpct/cudaGraph_test.cu @@ -141,5 +141,12 @@ int main() { cudaGraphExecDestroy(**execGraph3); CUDA_CHECK_THROW(cudaGraphExecDestroy(**execGraph3)); + // CHECK: delete (graph); + // CHECK-NEXT: delete (*graph2); + // CHECK-NEXT: CUDA_CHECK_THROW(DPCT_CHECK_ERROR(delete (**graph3))); + cudaGraphDestroy(graph); + cudaGraphDestroy(*graph2); + CUDA_CHECK_THROW(cudaGraphDestroy(**graph3)); + return 0; } diff --git a/clang/test/dpct/cudaGraph_test_default_option.cu b/clang/test/dpct/cudaGraph_test_default_option.cu index f17d48f5da3e..79029603d65c 100644 --- a/clang/test/dpct/cudaGraph_test_default_option.cu +++ b/clang/test/dpct/cudaGraph_test_default_option.cu @@ -121,6 +121,11 @@ int main() { // CHECK-NEXT: */ nodeType = cudaGraphNodeTypeKernel; + // CHECK: /* + // CHECK-NEXT: DPCT1119:{{[0-9]+}}: Migration of cudaGraphDestroy is not supported, please try to remigrate with option: --use-experimental-features=graph. + // CHECK-NEXT: */ + cudaGraphDestroy(graph); + return 0; }