From 7677876c0cfd0c7d62d3e707bd8f08e9ce44a5cd Mon Sep 17 00:00:00 2001 From: Daiyaan Ahmed Date: Tue, 1 Apr 2025 08:02:11 -0400 Subject: [PATCH 1/2] [SYCLomatic] Migration of cudaGraphDebugDotPrint Signed-off-by: Daiyaan Ahmed --- clang/lib/DPCT/RulesLang/APINamesGraph.inc | 11 +++++++++++ clang/lib/DPCT/RulesLang/RulesLangGraph.cpp | 3 ++- clang/lib/DPCT/SrcAPI/APINames.inc | 2 +- clang/test/dpct/cudaGraph_test.cu | 7 +++++++ clang/test/dpct/cudaGraph_test_default_option.cu | 5 +++++ 5 files changed, 26 insertions(+), 2 deletions(-) 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..d7f1fbcaeb0f 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; } From f9c78c237bd4bc8593a19ccd821d83f0af8edbbd Mon Sep 17 00:00:00 2001 From: Daiyaan Ahmed Date: Tue, 1 Apr 2025 09:57:15 -0400 Subject: [PATCH 2/2] Fix LIT test Signed-off-by: Daiyaan Ahmed --- clang/test/dpct/cudaGraph_test.cu | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/test/dpct/cudaGraph_test.cu b/clang/test/dpct/cudaGraph_test.cu index d7f1fbcaeb0f..401bf3038652 100644 --- a/clang/test/dpct/cudaGraph_test.cu +++ b/clang/test/dpct/cudaGraph_test.cu @@ -99,9 +99,9 @@ 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); + // 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);