Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement new "-explain" command to print the generated code to the console #2153

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/org/apache/sysds/api/DMLOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ else if (lineageType.equalsIgnoreCase("debugger"))
else if (explainType.equalsIgnoreCase("runtime")) dmlOptions.explainType = ExplainType.RUNTIME;
else if (explainType.equalsIgnoreCase("recompile_hops")) dmlOptions.explainType = ExplainType.RECOMPILE_HOPS;
else if (explainType.equalsIgnoreCase("recompile_runtime")) dmlOptions.explainType = ExplainType.RECOMPILE_RUNTIME;
else if (explainType.equalsIgnoreCase("codegen_hops")) dmlOptions.explainType = ExplainType.CODEGEN_HOPS;
else if (explainType.equalsIgnoreCase("codegen_runtime")) dmlOptions.explainType = ExplainType.CODEGEN_RUNTIME;
else throw new org.apache.commons.cli.ParseException("Invalid argument specified for -hops option, must be one of [hops, runtime, recompile_hops, recompile_runtime]");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,12 @@ public static ArrayList<Hop> optimize(ArrayList<Hop> roots, boolean recompile)
if( cla == null ) {
String src_cuda = "";
String src = tmp.getValue().codegen(false, GeneratorAPI.JAVA);
if(DMLScript.EXPLAIN.isCodegenType()) {
System.out.println("# SHOW GENERATED CODE");
System.out.println("-----------------------------");
System.out.println(src);
System.out.println("-----------------------------");
}
cla = CodegenUtils.compileClass("codegen." + tmp.getValue().getClassname(), src);

if(API == GeneratorAPI.CUDA) {
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/org/apache/sysds/utils/Explain.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ public enum ExplainType {
HOPS, // explain program and hops
RUNTIME, // explain runtime program (default)
RECOMPILE_HOPS, // explain hops, incl recompile
RECOMPILE_RUNTIME; // explain runtime program, incl recompile
RECOMPILE_RUNTIME, // explain runtime program, incl recompile
CODEGEN_HOPS, // show generated code, incl hops explanation
CODEGEN_RUNTIME; // show generated code, incl runtime explanation

public boolean isHopsType(boolean recompile) {
return (this==RECOMPILE_HOPS || (!recompile && this==HOPS));
return (this==RECOMPILE_HOPS || (!recompile && this==HOPS) || (this==CODEGEN_HOPS));
}
public boolean isRuntimeType(boolean recompile) {
return (this==RECOMPILE_RUNTIME || (!recompile && this==RUNTIME));
return (this==RECOMPILE_RUNTIME || (!recompile && this==RUNTIME) || (this==CODEGEN_RUNTIME));
}
public boolean isCodegenType() {
return (this == CODEGEN_HOPS || this == CODEGEN_RUNTIME);
}
}

Expand Down
Loading