summaryrefslogtreecommitdiff
path: root/lib/Kratos
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Kratos')
-rw-r--r--lib/Kratos/DFADriver.pm38
-rw-r--r--lib/Kratos/DFADriver/Model.pm78
2 files changed, 77 insertions, 39 deletions
diff --git a/lib/Kratos/DFADriver.pm b/lib/Kratos/DFADriver.pm
index a3473f7..9801d99 100644
--- a/lib/Kratos/DFADriver.pm
+++ b/lib/Kratos/DFADriver.pm
@@ -469,9 +469,15 @@ sub assess_model {
$self->printf_aggr( $transition, 'energy', 'pJ' );
$self->printf_parameterized( $transition, 'energy' );
$self->printf_fit( $transition, 'energy', 'pJ' );
- $self->printf_aggr( $transition, 'rel_energy', 'pJ' );
- $self->printf_parameterized( $transition, 'rel_energy' );
- $self->printf_fit( $transition, 'rel_energy', 'pJ' );
+ $self->printf_aggr( $transition, 'rel_energy_prev', 'pJ' );
+ $self->printf_parameterized( $transition, 'rel_energy_prev' );
+ $self->printf_fit( $transition, 'rel_energy_prev', 'pJ' );
+
+ if ( exists $transition->{rel_energy_next}{median} ) {
+ $self->printf_aggr( $transition, 'rel_energy_next', 'pJ' );
+ $self->printf_parameterized( $transition, 'rel_energy_next' );
+ $self->printf_fit( $transition, 'rel_energy_next', 'pJ' );
+ }
if ( exists $transition->{timeout}{median} ) {
$self->printf_aggr( $transition, 'timeout', 'µs' );
@@ -506,12 +512,14 @@ sub assess_model_tex {
printf("\n%20s", $name);
$self->printf_aggr_tex( $transition, 'energy', '\uJ', 1e6 );
- $self->printf_aggr_tex( $transition, 'rel_energy', '\uJ', 1e6 );
+ $self->printf_aggr_tex( $transition, 'rel_energy_prev', '\uJ', 1e6 );
+ $self->printf_aggr_tex( $transition, 'rel_energy_next', '\uJ', 1e6 );
$self->printf_aggr_tex( $transition, 'duration', 'ms', 1e3 );
$self->printf_count_tex( $transition, 'energy' );
print " \\\\";
$self->printf_eval_tex( $transition, 'energy', '\uJ', 1e6 );
- $self->printf_eval_tex( $transition, 'rel_energy', '\uJ', 1e6 );
+ $self->printf_eval_tex( $transition, 'rel_energy_prev', '\uJ', 1e6 );
+ $self->printf_eval_tex( $transition, 'rel_energy_next', '\uJ', 1e6 );
$self->printf_eval_tex( $transition, 'duration', 'ms', 1e3 );
$self->printf_count_tex;
print " \\\\";
@@ -548,11 +556,14 @@ sub assess_validation {
$self->model->get_transition_by_name($name)->{energy}{static},
$transition, 'energy', 'pJ' );
$self->printf_goodness(
- $self->model->get_transition_by_name($name)->{rel_energy}{static},
- $transition, 'rel_energy', 'pJ' );
+ $self->model->get_transition_by_name($name)->{rel_energy_prev}{static},
+ $transition, 'rel_energy_prev', 'pJ' );
+ if ( exists $transition->{rel_energy_next}{median} ) {
+ $self->printf_goodness(
+ $self->model->get_transition_by_name($name)->{rel_energy_next}{static},
+ $transition, 'rel_energy_next', 'pJ' );
+ }
if ( exists $transition->{timeout}{median} ) {
-
- #$self->printf_goodness('?', $transition, 'timeout', 'µs');
$self->printf_fit( $transition, 'timeout', 'µs' );
}
}
@@ -578,9 +589,10 @@ sub update_model {
$name,
$transition->{duration}{median},
$transition->{energy}{median},
- $transition->{rel_energy}{median}
+ $transition->{rel_energy_prev}{median},
+ $transition->{rel_energy_next}{median}
);
- for my $key (qw(duration energy rel_energy timeout)) {
+ for my $key (qw(duration energy rel_energy_prev rel_energy_next timeout)) {
for my $fname ( keys %{ $transition->{$key}{function} } ) {
$self->model->set_transition_params(
$name, $key, $fname,
@@ -698,7 +710,7 @@ EOF
advice ${adv_type}("% ${class_name}::$transition->{name}(...)") ${ignore_nested} : after() {
tjp->target()->passTransition(${class_name}::statepower[tjp->target()->state],
- $transition->{rel_energy}{static}, $transition->{id},
+ $transition->{rel_energy_prev}{static}, $transition->{id},
${dest_state_id});
};
@@ -709,7 +721,7 @@ EOF
advice execution("% ${class_name}::$transition->{name}(...)") : after() {
tjp->target()->passTransition(${class_name}::statepower[tjp->target()->state],
- $transition->{rel_energy}{static}, $transition->{id},
+ $transition->{rel_energy_prev}{static}, $transition->{id},
${dest_state_id});
};
diff --git a/lib/Kratos/DFADriver/Model.pm b/lib/Kratos/DFADriver/Model.pm
index 67fb318..bf57c49 100644
--- a/lib/Kratos/DFADriver/Model.pm
+++ b/lib/Kratos/DFADriver/Model.pm
@@ -117,17 +117,18 @@ sub parse_xml {
}
my $transition = {
- name => $transition_node->getAttribute('name'),
- duration => { static => 0+($transition_node->getAttribute('duration') // 0) },
- energy => { static => 0+($transition_node->getAttribute('energy') // 0) },
- rel_energy => { static => 0+($transition_node->getAttribute('rel_energy') // 0) },
- parameters => [@parameters],
- origins => [@source_states],
- destination => $dst_node->textContent,
- level => $level_node->textContent,
- id => $transition_index,
- affects => {%affects},
- node => $transition_node,
+ name => $transition_node->getAttribute('name'),
+ duration => { static => 0+($transition_node->getAttribute('duration') // 0) },
+ energy => { static => 0+($transition_node->getAttribute('energy') // 0) },
+ rel_energy_prev => { static => 0+($transition_node->getAttribute('rel_energy_prev') // 0) },
+ rel_energy_next => { static => 0+($transition_node->getAttribute('rel_energy_next') // 0) },
+ parameters => [@parameters],
+ origins => [@source_states],
+ destination => $dst_node->textContent,
+ level => $level_node->textContent,
+ id => $transition_index,
+ affects => {%affects},
+ node => $transition_node,
};
for my $fun_node ( $transition_node->findnodes('./timeoutfunction/*') )
@@ -184,18 +185,36 @@ sub parse_xml {
}
}
- for my $fun_node ( $transition_node->findnodes('./rel_energyfunction/*') )
+ for my $fun_node ( $transition_node->findnodes('./rel_energy_prevfunction/*') )
{
my $name = $fun_node->nodeName;
my $function = $fun_node->textContent;
$function =~ s{^ \n* \s* }{}x;
$function =~ s{\s* \n* $}{}x;
- $transition->{rel_energy}{function}{$name}{raw} = $function;
- $transition->{rel_energy}{function}{$name}{node} = $fun_node;
+ $transition->{rel_energy_prev}{function}{$name}{raw} = $function;
+ $transition->{rel_energy_prev}{function}{$name}{node} = $fun_node;
my $attrindex = 0;
while ( $fun_node->hasAttribute("param${attrindex}") ) {
push(
- @{ $transition->{rel_energy}{function}{$name}{params} },
+ @{ $transition->{rel_energy_prev}{function}{$name}{params} },
+ $fun_node->getAttribute("param${attrindex}")
+ );
+ $attrindex++;
+ }
+ }
+
+ for my $fun_node ( $transition_node->findnodes('./rel_energy_nextfunction/*') )
+ {
+ my $name = $fun_node->nodeName;
+ my $function = $fun_node->textContent;
+ $function =~ s{^ \n* \s* }{}x;
+ $function =~ s{\s* \n* $}{}x;
+ $transition->{rel_energy_next}{function}{$name}{raw} = $function;
+ $transition->{rel_energy_next}{function}{$name}{node} = $fun_node;
+ my $attrindex = 0;
+ while ( $fun_node->hasAttribute("param${attrindex}") ) {
+ push(
+ @{ $transition->{rel_energy_next}{function}{$name}{params} },
$fun_node->getAttribute("param${attrindex}")
);
$attrindex++;
@@ -249,7 +268,8 @@ sub reset {
for my $transition (@{$self->{transitions}}) {
$transition->{node}->removeAttribute('duration');
$transition->{node}->removeAttribute('energy');
- $transition->{node}->removeAttribute('rel_energy');
+ $transition->{node}->removeAttribute('rel_energy_prev');
+ $transition->{node}->removeAttribute('rel_energy_next');
for my $list_node (@{$transition->{node}->findnodes('./timeoutfunction')}) {
for my $fun_name (keys %{$transition->{timeout}{function}}) {
my $fun_node = $transition->{timeout}{function}{$fun_name}{node};
@@ -366,7 +386,7 @@ sub set_transition_params {
}
sub set_transition_data {
- my ( $self, $transition_name, $duration, $energy, $rel_energy ) = @_;
+ my ( $self, $transition_name, $duration, $energy, $rel_energy_prev, $rel_energy_next ) = @_;
my $transition = $self->get_transition_by_name($transition_name);
$duration = sprintf( '%.f', $duration );
@@ -383,17 +403,23 @@ sub set_transition_data {
$transition->{energy}{static} = $energy;
$transition->{node}->setAttribute( 'energy', $energy );
- if (defined $rel_energy) {
- $rel_energy = sprintf('%.f', $rel_energy);
- printf( ", relative energy %d -> %d pJ\n",
- $transition->{rel_energy}{static}, $rel_energy );
+ if (defined $rel_energy_prev) {
+ $rel_energy_prev = sprintf('%.f', $rel_energy_prev);
+ printf( ", relative_prev energy %d -> %d pJ",
+ $transition->{rel_energy_prev}{static}, $rel_energy_prev );
- $transition->{rel_energy}{static} = $rel_energy;
- $transition->{node}->setAttribute( 'rel_energy', $rel_energy );
+ $transition->{rel_energy_prev}{static} = $rel_energy_prev;
+ $transition->{node}->setAttribute( 'rel_energy_prev', $rel_energy_prev );
}
- else {
- print("\n");
+ if (defined $rel_energy_next) {
+ $rel_energy_next = sprintf('%.f', $rel_energy_next);
+ printf( ", relative_next energy %d -> %d pJ",
+ $transition->{rel_energy_next}{static}, $rel_energy_next );
+
+ $transition->{rel_energy_next}{static} = $rel_energy_next;
+ $transition->{node}->setAttribute( 'rel_energy_next', $rel_energy_next );
}
+ print("\n");
}
sub save {
@@ -530,7 +556,7 @@ sub TO_JSON {
}
for my $val ( values %transition_copy ) {
delete $val->{node};
- for my $key (qw(duration energy rel_energy timeout)) {
+ for my $key (qw(duration energy rel_energy_prev rel_energy_next timeout)) {
if ( exists $val->{$key}{function} ) {
$val->{$key} = { %{ $val->{$key} } };
$val->{$key}{function} = { %{ $val->{$key}{function} } };