Skip to content

Commit

Permalink
Merge pull request #138 from specs-feup/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
joaobispo authored Oct 21, 2023
2 parents 4d4ece2 + c3d2b0c commit 9b3b4e6
Show file tree
Hide file tree
Showing 49 changed files with 2,171 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ant-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- name: Generate build.xml
run: |
wget -N http://specs.fe.up.pt/tools/eclipse-build.jar
wget -q -N http://specs.fe.up.pt/tools/eclipse-build.jar
java -jar eclipse-build.jar https://github.com/specs-feup/specs-java-libs https://github.com/specs-feup/lara-framework?commit=staging ./
wget -N -O /usr/share/ant/lib/ivy-2.5.0.jar specs.fe.up.pt/libs/ivy-2.5.0.jar
- name: Build with Ant
Expand Down
17 changes: 17 additions & 0 deletions ClavaAst/src/pt/up/fe/specs/clava/ast/stmt/BreakStmt.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,21 @@ public String getCode() {
return "break;";
}

/**
*
* @return the first ancestor that is either a switch or a loop, or throws exception if none is found
*/
public Stmt getEnclosingStmt() {
var currentAncestor = getParent();
while (currentAncestor != null) {
if (currentAncestor instanceof LoopStmt || currentAncestor instanceof SwitchStmt) {
return (Stmt) currentAncestor;
}

currentAncestor = currentAncestor.getParent();
}

throw new RuntimeException("Expected to find either a loop or a switch as an ancestor");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ public enum LaraApiResource implements LaraResourceProvider {

CFG_CASE_DATA("graphs/cfg/nodedata/CaseData.js"),
CFG_DATA_FACTORY("graphs/cfg/nodedata/DataFactory.js"),
CFG_GOTO_DATA("graphs/cfg/nodedata/GotoData.js"),
CFG_HEADER_DATA("graphs/cfg/nodedata/HeaderData.js"),
CFG_IF_DATA("graphs/cfg/nodedata/IfData.js"),
CFG_INST_LIST_NODE_DATA("graphs/cfg/nodedata/InstListNodeData.js"),
CFG_LABEL_DATA("graphs/cfg/nodedata/LabelData.js"),
CFG_LOOP_DATA("graphs/cfg/nodedata/LoopData.js"),
CFG_SCOPE_NODE_DATA("graphs/cfg/nodedata/ScopeNodeData.js"),
CFG_SWITCH_DATA("graphs/cfg/nodedata/SwitchData.js"),
Expand All @@ -123,6 +125,11 @@ public enum LaraApiResource implements LaraResourceProvider {
HLS_MATH("hls/MathAnalysis.lara"),
HLS_MATH_H("hls/MathHInfo.lara"),

// LIVENESS
LIVENESS_ANALYSIS("liveness/LivenessAnalysis.js"),
LIVENESS_ANALYSER("liveness/LivenessAnalyser.js"),
LIVENESS_UTILS("liveness/LivenessUtils.js"),

// MPI
MPI_ACCESS_PATTERN("mpi/MpiAccessPattern.lara"),
MPI_SCATTER_GATHER_LOOP("mpi/MpiScatterGatherLoop.js"),
Expand Down Expand Up @@ -150,6 +157,7 @@ public enum LaraApiResource implements LaraResourceProvider {
PASS_SIMPLIFY_LOOPS("pass/SimplifyLoops.js"),
PASS_SIMPLIFY_RETURN("pass/SimplifyReturnStmts.js"),
PASS_SIMPLIFY_SELECTION_STMTS("pass/SimplifySelectionStmts.js"),
TRANSFORM_SWITCH_TO_IF("pass/TransformSwitchToIf.js"),

// Stats
OPS_BLOCK("stats/OpsBlock.lara"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ aspectdef ret_IF_Clause

var loopindex = GetLoopIndex($ForStmt);
var loopControlVarname = LoopOmpAttributes[loopindex].loopControlVarname;
IF_Clause_str = 'if(abs(';
this.IF_Clause_str = 'if(abs(';

var cloneJP = null;

Expand Down Expand Up @@ -142,7 +142,7 @@ aspectdef ret_IF_Clause
$cast.replaceWith(child);
}

IF_Clause_str += cloneJP.code + ' - ';
this.IF_Clause_str += cloneJP.code + ' - ';


cloneJP = null;
Expand Down Expand Up @@ -180,10 +180,10 @@ aspectdef ret_IF_Clause
}


IF_Clause_str += cloneJP.code;
this.IF_Clause_str += cloneJP.code;


IF_Clause_str += ')>500)';
this.IF_Clause_str += ')>500)';
end


Expand All @@ -194,7 +194,7 @@ aspectdef ret_NUM_THREADS_Clause

var loopindex = GetLoopIndex($ForStmt);
var loopControlVarname = LoopOmpAttributes[loopindex].loopControlVarname;
NUM_THREADS_Clause_str = 'num_threads((abs(';
this.NUM_THREADS_Clause_str = 'num_threads((abs(';

var cloneJP = null;

Expand Down Expand Up @@ -225,7 +225,7 @@ aspectdef ret_NUM_THREADS_Clause
$cast.replaceWith(child);
}

NUM_THREADS_Clause_str += cloneJP.code + ' - ';
this.NUM_THREADS_Clause_str += cloneJP.code + ' - ';


cloneJP = null;
Expand Down Expand Up @@ -263,8 +263,8 @@ aspectdef ret_NUM_THREADS_Clause
}


NUM_THREADS_Clause_str += cloneJP.code;
this.NUM_THREADS_Clause_str += cloneJP.code;


NUM_THREADS_Clause_str += ')<500)?1:omp_get_max_threads())';
this.NUM_THREADS_Clause_str += ')<500)?1:omp_get_max_threads())';
end
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ aspectdef CovertLoopToPetitForm
input $ForStmt, tabOP end
output loopPetitForm end

loopPetitForm = tabOP.join('') + 'for ';
this.loopPetitForm = tabOP.join('') + 'for ';
var loopindex = GetLoopIndex($ForStmt);
//println("DEBUG - Loop Index: " + loopindex);
//println("DEBUG - For Stmt: " + $ForStmt.location);
Expand Down Expand Up @@ -250,7 +250,7 @@ aspectdef CovertLoopToPetitForm

var str_init = cloneJP.code;

loopPetitForm += loopControlVarname + ' = ' + str_init + ' to ';
this.loopPetitForm += loopControlVarname + ' = ' + str_init + ' to ';

cloneJP = null;
var binaryOpleft = null;
Expand Down Expand Up @@ -294,7 +294,7 @@ aspectdef CovertLoopToPetitForm
str_cond = '9999';
}

loopPetitForm += str_cond;
this.loopPetitForm += str_cond;

var stepOp = null;
cloneJP = null;
Expand All @@ -313,15 +313,15 @@ aspectdef CovertLoopToPetitForm

if (stepOp === 'post_inc' || stepOp === 'pre_inc')
{
loopPetitForm += ' do';
this.loopPetitForm += ' do';
}
else if (stepOp === 'pre_dec' || stepOp === 'post_dec')
{
loopPetitForm += ' by -1 do';
this.loopPetitForm += ' by -1 do';
}
else if (stepOp === 'assign')
{
loopPetitForm += ' do';
this.loopPetitForm += ' do';
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aspectdef FindReductionArrays
output isReductionArrays end
var reduction = [];

isReductionArrays = false;
this.isReductionArrays = false;

var check1 = (isdependentInnerloop === true) && (isdependentCurrentloop === false) && (isdependentOuterloop === false);
var check2 = (isdependentInnerloop === false) && (isdependentCurrentloop === false) && (isdependentOuterloop === true);
Expand Down Expand Up @@ -63,7 +63,7 @@ aspectdef FindReductionArrays
{
LoopOmpAttributes[loopindex].reduction = LoopOmpAttributes[loopindex].reduction.concat(reduction);
LoopOmpAttributes[loopindex].Reduction_listVars.push(candidateArrayName);
isReductionArrays = true;
this.isReductionArrays = true;
}
return;

Expand All @@ -82,7 +82,7 @@ aspectdef retReductionOpArray
output reduction end
//println("Heello");

reduction = [];
this.reduction = [];
var candidateVarUse = null;

var exprvarrefset = orderedVarrefs3($expr);
Expand Down Expand Up @@ -168,21 +168,21 @@ aspectdef retReductionOpArray

var findOpflag = true;
if ( ['pre_dec', 'post_dec', 'sub', 'sub_assign'].indexOf(op) !== -1 )
reduction.push('reduction (-:' + arraysizeStr + ')');
this.reduction.push('reduction (-:' + arraysizeStr + ')');
else if ( ['pre_inc', 'post_inc', 'add', 'add_assign'].indexOf(op) !== -1 )
reduction.push('reduction (+:' + arraysizeStr + ')');
this.reduction.push('reduction (+:' + arraysizeStr + ')');
else if ( ['mul' , 'mul_assign'].indexOf(op) !== -1 )
reduction.push('reduction (*:' + arraysizeStr + ')');
this.reduction.push('reduction (*:' + arraysizeStr + ')');
else if ( ['and' , 'and_assign'].indexOf(op) !== -1 )
reduction.push('reduction (&:' + arraysizeStr + ')');
this.reduction.push('reduction (&:' + arraysizeStr + ')');
else if ( ['xor' , 'xor_assign'].indexOf(op) !== -1 )
reduction.push('reduction (^:' + arraysizeStr + ')');
this.reduction.push('reduction (^:' + arraysizeStr + ')');
else if ( ['or' , 'or_assign'].indexOf(op) !== -1 )
reduction.push('reduction (|:' + arraysizeStr + ')');
this.reduction.push('reduction (|:' + arraysizeStr + ')');
else if ( ['l_and'].indexOf(op) !== -1 )
reduction.push('reduction (&&:' + arraysizeStr + ')');
this.reduction.push('reduction (&&:' + arraysizeStr + ')');
else if ( ['l_or'].indexOf(op) !== -1 )
reduction.push('reduction (||:' + arraysizeStr + ')');
this.reduction.push('reduction (||:' + arraysizeStr + ')');
else
findOpflag = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ end
aspectdef find_func_call
input $loop end
output func_names end
func_names = [];
this.func_names = [];

select $loop.body.call end
apply
func_names.push($call.name);
this.func_names.push($call.name);
end
condition $call.astName === 'CallExpr' end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ aspectdef inlinePreparation
input func_name, callStmt, exprStmt end
output replacedCallStr, $newStmts end

replacedCallStr = '';
this.replacedCallStr = '';

this.$newStmts = [];

Expand Down Expand Up @@ -480,17 +480,12 @@ aspectdef inlinePreparation
select funcJP.body.childStmt end
apply
this.$newStmts.push($childStmt.copy());
replacedCallStr += $childStmt.code + '\n';
this.replacedCallStr += $childStmt.code + '\n';
//changedReplacedCall = true;
//println("ADDING: " + $childStmt.code);
end
/*
if(changedReplacedCall) {
println("REPLACE CALL: " + replacedCallStr);
}
*/

replacedCallStr = replacedCallStr.allReplace({' const ':' '});
this.replacedCallStr = this.replacedCallStr.allReplace({' const ':' '});

funcJP.detach();
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,3 @@ aspectdef SetMemberAccessOpenMPscoping
print_obj(varreflist, 'aspectdef SetMemberAccessOpenMPscoping : varAccess for For#' + $ForStmt.line);
end

/*
aspectdef getVarrefobj end
input stmt, varname end
output varrefObj end

select stmt.varref end
apply

end
condition $varref.name
end
*/
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ aspectdef SetVariableAccess
(varTypeAccess === 'varref' && (innerloopsControlVarname.indexOf($varref.name) !== -1 || loopControlVarname === $varref.name)) // is loop control variable
)
continue;

if ($varref.isFunctionArgument === true)
{
var callJP = $varref.ancestor('call');
Expand Down Expand Up @@ -330,14 +329,14 @@ aspectdef retsubscriptcurrentloop
input $varref, loopControlVarname end
output subscriptstr end

subscriptstr = '';
this.subscriptstr = '';

select $varref.subscript end
apply
for($varref of $subscript.descendantsAndSelf("varref"))
if ( $varref.name === loopControlVarname)
{
subscriptstr += '[' + $subscript.code +']';
this.subscriptstr += '[' + $subscript.code +']';
break;
}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ aspectdef additionalConditionsCheck
}

call o : checkForFunctionCalls($ForStmt);

if (o.FunctionCalls.length > 0)
{
Add_msgError(LoopOmpAttributes, $ForStmt, 'Variables Access as passed arguments Can not be traced inside of function calls : \n' + o.FunctionCalls.join('\n'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
aspectdef checkForFunctionCalls
input $ForStmt end
output FunctionCalls end
FunctionCalls = [];

this.FunctionCalls = [];

// check for calling functions

Expand All @@ -18,26 +19,8 @@ aspectdef checkForFunctionCalls
(userSafeFunctions !== undefined && userSafeFunctions.indexOf($call.name) !== -1);

if (!isSafe)
FunctionCalls.push($call.name + '#' + $call.line + '{' + $call.code +'}');
this.FunctionCalls.push($call.name + '#' + $call.line + '{' + $call.code +'}');
end
condition $call.astName === 'CallExpr' end

end

/*
aspectdef checkForFunctionCalls
input $ForStmt end
output FunctionCalls end
FunctionCalls = [];

// check for calling functions

select $ForStmt.call end
apply
if (safefunctionCallslist.indexOf($call.name) === -1)
FunctionCalls.push($call.name + '#' + $call.line + '{' + $call.code +'}');
end
condition $call.astName === 'CallExpr' end

end
*/
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
aspectdef checkForInvalidStmts
input $ForStmt end
output InvalidStmts end
InvalidStmts = [];

// Initialize output
this.InvalidStmts = [];

// check for [exit] at any subregion
select $ForStmt.call{'exit'} end
apply
InvalidStmts.push($call.name + '#' + $call.line);
this.InvalidStmts.push($call.name + '#' + $call.line);
return;
end

Expand All @@ -23,7 +25,7 @@ aspectdef checkForInvalidStmts
($stmt.astName === 'BreakStmt' && $stmt.astAncestor('ForStmt').line === $ForStmt.line)
)
{
InvalidStmts.push($stmt.astName + '#' + $stmt.line);
this.InvalidStmts.push($stmt.astName + '#' + $stmt.line);
return;
}
end
Expand Down
Loading

0 comments on commit 9b3b4e6

Please sign in to comment.