diff --git a/tce/src/applibs/Scheduler/ProgramRepresentations/DDG/DataDependenceGraphBuilder.cc b/tce/src/applibs/Scheduler/ProgramRepresentations/DDG/DataDependenceGraphBuilder.cc index 7b6d30435..270c1d376 100644 --- a/tce/src/applibs/Scheduler/ProgramRepresentations/DDG/DataDependenceGraphBuilder.cc +++ b/tce/src/applibs/Scheduler/ProgramRepresentations/DDG/DataDependenceGraphBuilder.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2002-2015 Tampere University. + Copyright (c) 2002-2021 Tampere University. This file is part of TTA-Based Codesign Environment (TCE). @@ -30,6 +30,7 @@ * however have been allocated. * * @author Heikki Kultala 2006-2009 (heikki.kultala-no.spam-tut.fi) + * @author Pekka Jääskeläinen 2021 (pekka.jaaskelainen tuni fi) * @note rating: red */ @@ -1641,7 +1642,7 @@ DataDependenceGraphBuilder::createTriggerDependencies( * @param mn moveNode that is the destination of the dependencies. * @param dop Operation that mn triggers. */ -void +void DataDependenceGraphBuilder::createSideEffectEdges( MoveNodeUseSet& prevMoves, const MoveNode& mn, Operation& dop) { @@ -1655,6 +1656,33 @@ DataDependenceGraphBuilder::createSideEffectEdges( if ((&dop == &o && o.hasSideEffects()) || dop.dependsOn(o) || o.dependsOn(dop)) { + // Operations forced to different FUs are independent since + // the operation state is per FU. Check if the moves have + // forced set of FUs and if the sets overlap. + if (mn.move().hasAnnotations( + TTAProgram::ProgramAnnotation::ANN_ALLOWED_UNIT_DST) && + i->mn()->move().hasAnnotations( + TTAProgram::ProgramAnnotation::ANN_ALLOWED_UNIT_DST)) { + bool alwaysDifferentFUs = true; + for (int idx = 0; idx < mn.move().annotationCount( + TTAProgram::ProgramAnnotation:: + ANN_ALLOWED_UNIT_DST); + ++idx) { + if (i->mn()->move().hasAnnotation( + TTAProgram::ProgramAnnotation:: + ANN_ALLOWED_UNIT_DST, + mn.move().annotation( + idx, + TTAProgram::ProgramAnnotation:: + ANN_ALLOWED_UNIT_DST).stringValue())) { + alwaysDifferentFUs = false; + break; + } + } + if (alwaysDifferentFUs) + return; + } + if (!currentDDG_->exclusingGuards(*(i->mn()), mn)) { DataDependenceEdge* dde = new DataDependenceEdge( diff --git a/testsuite/systemtest/bintools/Compiler/data/opswithstate.adf b/testsuite/systemtest/bintools/Compiler/data/opswithstate.adf new file mode 100644 index 000000000..9d9e65b36 --- /dev/null +++ b/testsuite/systemtest/bintools/Compiler/data/opswithstate.adf @@ -0,0 +1,1103 @@ + + + + + 32 + + + + + + + BOOL + 0 + + + + + + + BOOL + 0 + + + + + + + BOOL + 1 + + + + + + + BOOL + 1 + + + + + + + + zero + 32 + + + + + 32 + + + + + + + BOOL + 0 + + + + + + + BOOL + 0 + + + + + + + BOOL + 1 + + + + + + + BOOL + 1 + + + + + + + + zero + 32 + + + + + 32 + + + + + + + BOOL + 0 + + + + + + + BOOL + 0 + + + + + + + BOOL + 1 + + + + + + + BOOL + 1 + + + + + + + + zero + 32 + + + + + 32 + + + + + + + BOOL + 0 + + + + + + + BOOL + 0 + + + + + + + BOOL + 1 + + + + + + + BOOL + 1 + + + + + + + + zero + 32 + + + + + 32 + + + + + + + BOOL + 0 + + + + + + + BOOL + 0 + + + + + + + BOOL + 1 + + + + + + + BOOL + 1 + + + + + + + + zero + 32 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + B1 + seg1 + + + B1_1 + seg1 + + + B1_2 + seg1 + + + B1_3 + seg1 + + + B1_4 + seg1 + + + + + + lsu_i1 + 32 + + + + + lsu_o1 + 32 + + + lsu_i2 + 32 + + + ldw + in1t + out1 + + + 0 + 1 + + + 2 + 1 + + + + + ldq + in1t + out1 + + + 0 + 1 + + + 2 + 1 + + + + + ldh + in1t + out1 + + + 0 + 1 + + + 2 + 1 + + + + + stw + in1t + in2 + + + 0 + 1 + + + 0 + 1 + + + + + stq + in1t + in2 + + + 0 + 1 + + + 0 + 1 + + + + + sth + in1t + in2 + + + 0 + 1 + + + 0 + 1 + + + + + ldqu + in1t + out1 + + + 0 + 1 + + + 2 + 1 + + + + + ldhu + in1t + out1 + + + 0 + 1 + + + 2 + 1 + + + + data + + + + + ALU_i1 + 32 + + + + + ALU_i2 + 32 + + + ALU_o1 + 32 + + + add + in1t + in2 + out1 + + + 0 + 1 + + + 0 + 1 + + + 0 + 1 + + + + + and + in1t + in2 + out1 + + + 0 + 1 + + + 0 + 1 + + + 0 + 1 + + + + + eq + in1t + in2 + out1 + + + 0 + 1 + + + 0 + 1 + + + 0 + 1 + + + + + gt + in1t + in2 + out1 + + + 0 + 1 + + + 0 + 1 + + + 0 + 1 + + + + + gtu + in1t + in2 + out1 + + + 0 + 1 + + + 0 + 1 + + + 0 + 1 + + + + + ior + in1t + in2 + out1 + + + 0 + 1 + + + 0 + 1 + + + 0 + 1 + + + + + shl + in2 + in1t + out1 + + + 0 + 1 + + + 0 + 1 + + + 0 + 1 + + + + + shr + in2 + in1t + out1 + + + 0 + 1 + + + 0 + 1 + + + 0 + 1 + + + + + shru + in2 + in1t + out1 + + + 0 + 1 + + + 0 + 1 + + + 0 + 1 + + + + + sub + in1t + in2 + out1 + + + 0 + 1 + + + 0 + 1 + + + 0 + 1 + + + + + sxhw + in1t + out1 + + + 0 + 1 + + + 0 + 1 + + + + + sxqw + in1t + out1 + + + 0 + 1 + + + 0 + 1 + + + + + xor + in1t + in2 + out1 + + + 0 + 1 + + + 0 + 1 + + + 0 + 1 + + + + + + + + + IO_i1 + 8 + + + + + stdout + T + + + 0 + 1 + + + + + + + + + OUT2_i1 + 8 + + + + + stdout + T + + + 0 + 1 + + + + + + + + normal + 5 + 32 + 1 + 1 + + RF_i1 + + + RF_o1 + + + + + normal + 2 + 1 + 1 + 1 + + bool_i1 + + + bool_o1 + + + + + 8 + 0 + 16777215 + + + + 8 + 0 + 1048576 + + + + + gcu_i1 + 32 + + + + + gcu_i2 + gcu_o1 + 32 + + ra + + jump + pc + + + 0 + 1 + + + + + call + pc + + + 0 + 1 + + + + instructions + 3 + 1 + + + diff --git a/testsuite/systemtest/bintools/Compiler/data/opswithstate.c b/testsuite/systemtest/bintools/Compiler/data/opswithstate.c new file mode 100644 index 000000000..b61fdd24f --- /dev/null +++ b/testsuite/systemtest/bintools/Compiler/data/opswithstate.c @@ -0,0 +1,13 @@ +int main() { +#if SEQUENTIAL == 0 + // These should get scheduled parallel thanks to the different FUs. + _TCEFU_STDOUT("OUT1", '1'); + _TCEFU_STDOUT("OUT2", '2'); +#else + // These should be forced serial + _TCE_STDOUT('1'); + _TCE_STDOUT('2'); +#endif + return 0; +} + diff --git a/testsuite/systemtest/bintools/Compiler/tcetest_multiple_ops_with_state.sh b/testsuite/systemtest/bintools/Compiler/tcetest_multiple_ops_with_state.sh new file mode 100755 index 000000000..8401b91c0 --- /dev/null +++ b/testsuite/systemtest/bintools/Compiler/tcetest_multiple_ops_with_state.sh @@ -0,0 +1,17 @@ +#!/bin/sh +### TCE TESTCASE +### title: Multiple operations with state in different FUs +### xstdout: 1\n2 + +mach=data/opswithstate.adf +src=data/opswithstate.c +program=$(mktemp tmpXXXXXX) + +tcecc $src -llwpr -O3 -a $mach -o $program -DSEQUENTIAL=0 +tcedisasm -s $mach $program | egrep -c "OUT.*OUT" + +tcecc $src -llwpr -O3 -a $mach -o $program -DSEQUENTIAL=1 +tcedisasm -s $mach $program | egrep -c "OUT" +rm -f $program + +