diff --git a/clang/lib/DPCT/RulesLang/APINamesGraph.inc b/clang/lib/DPCT/RulesLang/APINamesGraph.inc index e72b6c3f1cfd..ac1051919ed4 100644 --- a/clang/lib/DPCT/RulesLang/APINamesGraph.inc +++ b/clang/lib/DPCT/RulesLang/APINamesGraph.inc @@ -66,3 +66,14 @@ ASSIGNABLE_FACTORY(CONDITIONAL_FACTORY_ENTRY( Diagnostics::TRY_EXPERIMENTAL_FEATURE, ARG("cudaGraphExecUpdate"), ARG("--use-experimental-features=graph")))) + +ASSIGNABLE_FACTORY(CONDITIONAL_FACTORY_ENTRY( + UseExtGraph, + MEMBER_CALL_FACTORY_ENTRY( + "cudaGraphDebugDotPrint", ARG(0), true, "print_graph", + CAST_IF_NOT_SAME(makeLiteral("std::string"), ARG(1)), + makeLiteral("true")), + UNSUPPORT_FACTORY_ENTRY("cudaGraphDebugDotPrint", + Diagnostics::TRY_EXPERIMENTAL_FEATURE, + ARG("cudaGraphDebugDotPrint"), + ARG("--use-experimental-features=graph")))) diff --git a/clang/lib/DPCT/RulesLang/RulesLangGraph.cpp b/clang/lib/DPCT/RulesLang/RulesLangGraph.cpp index 8e5c61f0b59c..947bf04ded94 100644 --- a/clang/lib/DPCT/RulesLang/RulesLangGraph.cpp +++ b/clang/lib/DPCT/RulesLang/RulesLangGraph.cpp @@ -32,7 +32,8 @@ void GraphRule::registerMatcher(MatchFinder &MF) { auto functionName = [&]() { return hasAnyName("cudaGraphInstantiate", "cudaGraphLaunch", "cudaGraphExecDestroy", "cudaGraphAddEmptyNode", - "cudaGraphAddDependencies", "cudaGraphExecUpdate"); + "cudaGraphAddDependencies", "cudaGraphExecUpdate", + "cudaGraphDebugDotPrint"); }; 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 c359481ffc56..97f53a42723a 100644 --- a/clang/lib/DPCT/SrcAPI/APINames.inc +++ b/clang/lib/DPCT/SrcAPI/APINames.inc @@ -418,7 +418,7 @@ ENTRY(cudaGraphChildGraphNodeGetGraph, cudaGraphChildGraphNodeGetGraph, false, N 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(cudaGraphDebugDotPrint, cudaGraphDebugDotPrint, true, NO_FLAG, P4, "Successful/DPCT1119") ENTRY(cudaGraphDestroy, cudaGraphDestroy, false, NO_FLAG, P4, "comment") ENTRY(cudaGraphDestroyNode, cudaGraphDestroyNode, false, NO_FLAG, P4, "comment") ENTRY(cudaGraphEventRecordNodeGetEvent, cudaGraphEventRecordNodeGetEvent, false, NO_FLAG, P4, "comment") diff --git a/clang/test/dpct/cudaGraph_test.cu b/clang/test/dpct/cudaGraph_test.cu index 8d07cf610f75..401bf3038652 100644 --- a/clang/test/dpct/cudaGraph_test.cu +++ b/clang/test/dpct/cudaGraph_test.cu @@ -99,6 +99,13 @@ int main() { CUDA_CHECK_THROW(cudaGraphLaunch(execGraph, stream)); cudaGraphLaunch(*execGraph2, *stream2); + // CHECK: graph->print_graph((std::string)"graph.dot", true); + // CHECK-NEXT: graph->print_graph((std::string)"graph.dot", true); + // CHECK-NEXT: graph->print_graph((std::string)"graph.dot", true); + cudaGraphDebugDotPrint(graph, "graph.dot", 1); + cudaGraphDebugDotPrint(graph, "graph.dot", cudaGraphDebugDotFlagsVerbose); + cudaGraphDebugDotPrint(graph, "graph.dot", cudaGraphDebugDotFlagsConditionalNodeParams); + #ifndef DNO_BUILD_TEST // CHECK: execGraph->update(*graph); cudaGraphExecUpdate(execGraph, graph, nullptr, nullptr); diff --git a/clang/test/dpct/cudaGraph_test_default_option.cu b/clang/test/dpct/cudaGraph_test_default_option.cu index f1574548cb0e..d100ccb35d5e 100644 --- a/clang/test/dpct/cudaGraph_test_default_option.cu +++ b/clang/test/dpct/cudaGraph_test_default_option.cu @@ -97,6 +97,11 @@ int main() { // CHECK-NEXT: */ cudaGraphExecDestroy(execGraph); + // CHECK: /* + // CHECK-NEXT: DPCT1119:{{[0-9]+}}: Migration of cudaGraphDebugDotPrint is not supported, please try to remigrate with option: --use-experimental-features=graph. + // CHECK-NEXT: */ + cudaGraphDebugDotPrint(graph, "graph.dot", 1); + return 0; }