diff options
| author | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
|---|---|---|
| committer | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
| commit | 386b7d3366f1359a265da207a9cafa3edf553b64 (patch) | |
| tree | c76120c2c138faed822e4ae386be6ef22a738a78 /all_pairs/source/petrinet | |
| parent | 54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff) | |
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'all_pairs/source/petrinet')
| -rw-r--r-- | all_pairs/source/petrinet/ChangeLog.txt | 63 | ||||
| -rw-r--r-- | all_pairs/source/petrinet/petrinet.c | 990 |
2 files changed, 1053 insertions, 0 deletions
diff --git a/all_pairs/source/petrinet/ChangeLog.txt b/all_pairs/source/petrinet/ChangeLog.txt new file mode 100644 index 0000000..3a02ec7 --- /dev/null +++ b/all_pairs/source/petrinet/ChangeLog.txt | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | File: petrinet.c | ||
| 2 | Original provenience: Mälardalen benchmark suite, | ||
| 3 | http://www.mrtc.mdh.se/projects/wcet/wcet_bench/nsichneu/nsichneu.c | ||
| 4 | |||
| 5 | 2016-02-02: | ||
| 6 | - Added generic TACLeBench header. | ||
| 7 | - Removed old file header (keep some information in TACLeBench | ||
| 8 | header). | ||
| 9 | - Renamed global variables: | ||
| 10 | - main_iters_dummy_i -> petrinet_main_iters_dummy_i | ||
| 11 | - main_min_dummy_i -> petrinet_main_min_dummy_i | ||
| 12 | - main_max_dummy_i -> petrinet_main_max_dummy_i | ||
| 13 | - P1_is_marked -> petrinet_P1_is_marked | ||
| 14 | - P1_marking_member_0 -> petrinet_P1_marking_member_0 | ||
| 15 | - P2_is_marked -> petrinet_P2_is_marked | ||
| 16 | - P2_marking_member_0 -> petrinet_P2_marking_member_0 | ||
| 17 | - P3_is_marked -> petrinet_P3_is_marked | ||
| 18 | - P3_marking_member_0 -> petrinet_P3_marking_member_0 | ||
| 19 | - Renamed main function to petrinet_main, set as entrypoint. | ||
| 20 | - Implemented new function main according to TACLeBench guidelines. | ||
| 21 | - Implemented function petrinet_return, calculates checksum over | ||
| 22 | petrinet_P3_marking_member_0. | ||
| 23 | - Applied code formatting according to the following rules | ||
| 24 | - Lines shall not be wider than 80 characters; whenever possible, appropriate | ||
| 25 | line breaks shall be inserted to keep lines below 80 characters | ||
| 26 | - Indentation is done using whitespaces only, no tabs. Code is indented by | ||
| 27 | two whitespaces | ||
| 28 | - Two empty lines are put between any two functions | ||
| 29 | - In non-empty lists or index expressions, opening '(' and '[' are followed by | ||
| 30 | one whitespace, closing ')' and ']' are preceded by one whitespace | ||
| 31 | - In comma- or colon-separated argument lists, one whitespace is put after | ||
| 32 | each comma/colon | ||
| 33 | - Names of functions and global variables all start with a benchmark-specific | ||
| 34 | prefix (here: bs_) followed by lowercase letter (e.g., bs_square) | ||
| 35 | - For pointer types, one whitespace is put before the '*' | ||
| 36 | - Operators within expressions shall be preceded and followed by one | ||
| 37 | whitespace | ||
| 38 | - Code of then- and else-parts of if-then-else statements shall be put in | ||
| 39 | separate lines, not in the same lines as the if-condition or the keyword | ||
| 40 | "else" | ||
| 41 | - Opening braces '{' denoting the beginning of code for some if-else or loop | ||
| 42 | body shall be put at the end of the same line where the keywords "if", | ||
| 43 | "else", "for", "while" etc. occur | ||
| 44 | - In non-empty lists or index expressions, opening '(' and '[' are followed by | ||
| 45 | one whitespace, closing ')' and ']' are preceded by one whitespace | ||
| 46 | - Operators within expressions shall be preceded and followed by one | ||
| 47 | whitespace | ||
| 48 | |||
| 49 | 2016-04-05: | ||
| 50 | - Return '0' on success | ||
| 51 | |||
| 52 | 2016-04-06: | ||
| 53 | - Fixed generation of return value | ||
| 54 | |||
| 55 | 2016-06-01: | ||
| 56 | - Changed all prefixes to lower-case | ||
| 57 | |||
| 58 | 2016-06-08: | ||
| 59 | - Prefix | ||
| 60 | - removed return from petrinet_main | ||
| 61 | |||
| 62 | 2016-06-13: | ||
| 63 | - introduced function petrinet_init | ||
diff --git a/all_pairs/source/petrinet/petrinet.c b/all_pairs/source/petrinet/petrinet.c new file mode 100644 index 0000000..7c9e1a0 --- /dev/null +++ b/all_pairs/source/petrinet/petrinet.c | |||
| @@ -0,0 +1,990 @@ | |||
| 1 | /* | ||
| 2 | |||
| 3 | This program is part of the TACLeBench benchmark suite. | ||
| 4 | Version V 2.0 | ||
| 5 | |||
| 6 | Name: Petrinet | ||
| 7 | |||
| 8 | Author: Friedhelm Stappert, C-LAB, Paderborn, Germany | ||
| 9 | |||
| 10 | Function: Simulate an extended Petri Net | ||
| 11 | Automatically generated code containing large amounts of | ||
| 12 | if-statements (more than 250) | ||
| 13 | |||
| 14 | Source: Mälardalen benchmark suite | ||
| 15 | |||
| 16 | Changes: no major functional changes | ||
| 17 | |||
| 18 | License: may be used, modified, and re-distributed freely | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | /* Remove the following #define for actual WCET analyses! */ | ||
| 23 | /* | ||
| 24 | #define PROFILING | ||
| 25 | */ | ||
| 26 | |||
| 27 | |||
| 28 | #include "../extra.h" | ||
| 29 | |||
| 30 | #ifdef PROFILING | ||
| 31 | #include <stdio.h> | ||
| 32 | #endif | ||
| 33 | |||
| 34 | #ifdef PROFILING | ||
| 35 | /* Profiling variables. Remove for actual WCET analyses. */ | ||
| 36 | int petrinet_main_iters_dummy_i = 0, | ||
| 37 | petrinet_main_min_dummy_i = 100000, | ||
| 38 | petrinet_main_max_dummy_i = 0; | ||
| 39 | #endif | ||
| 40 | |||
| 41 | /* | ||
| 42 | Forward declaration of functions | ||
| 43 | */ | ||
| 44 | void petrinet_init( void ); | ||
| 45 | int petrinet_return( void ); | ||
| 46 | void petrinet_main( void ); | ||
| 47 | //int main( void ); | ||
| 48 | |||
| 49 | |||
| 50 | volatile int petrinet_P1_is_marked; | ||
| 51 | volatile long petrinet_P1_marking_member_0[ 3 ]; | ||
| 52 | volatile int petrinet_P2_is_marked; | ||
| 53 | volatile long petrinet_P2_marking_member_0[ 5 ]; | ||
| 54 | volatile int petrinet_P3_is_marked; | ||
| 55 | volatile long petrinet_P3_marking_member_0[ 6 ]; | ||
| 56 | |||
| 57 | const long petrinet_CHECKSUM = 0; | ||
| 58 | |||
| 59 | void _Pragma ( "entrypoint" ) petrinet_main( void ) | ||
| 60 | { | ||
| 61 | int dummy_i; | ||
| 62 | /* dummy_i = 17; Takes too much time */ | ||
| 63 | dummy_i = 2; | ||
| 64 | |||
| 65 | #ifdef PROFILING | ||
| 66 | main_iters_dummy_i = 0; | ||
| 67 | #endif | ||
| 68 | _Pragma( "loopbound min 2 max 2" ) | ||
| 69 | while ( dummy_i > 0 ) { | ||
| 70 | #ifdef PROFILING | ||
| 71 | main_iters_dummy_i++; | ||
| 72 | #endif | ||
| 73 | |||
| 74 | dummy_i--; | ||
| 75 | /* Permutation for Place P1 : 0, 1, 2 */ | ||
| 76 | /* Transition T1 */ | ||
| 77 | if ( ( petrinet_P1_is_marked >= 3 ) && | ||
| 78 | ( petrinet_P3_is_marked + 3 <= 6 ) && | ||
| 79 | ( petrinet_P1_marking_member_0[ 1 ] | ||
| 80 | == petrinet_P1_marking_member_0[ 2 ] ) ) { | ||
| 81 | |||
| 82 | long x; | ||
| 83 | long y; | ||
| 84 | long z; | ||
| 85 | |||
| 86 | x = petrinet_P1_marking_member_0[ 0 ]; | ||
| 87 | y = petrinet_P1_marking_member_0[ 1 ]; | ||
| 88 | |||
| 89 | /* Transition condition */ | ||
| 90 | if ( x < y ) { | ||
| 91 | |||
| 92 | /* demarking of input places */ | ||
| 93 | petrinet_P1_is_marked -= 3; | ||
| 94 | |||
| 95 | /* preaction */ | ||
| 96 | z = x - y; | ||
| 97 | |||
| 98 | /* marking of output places */ | ||
| 99 | petrinet_P3_marking_member_0[ petrinet_P3_is_marked + 0 ] = x; | ||
| 100 | petrinet_P3_marking_member_0[ petrinet_P3_is_marked + 1 ] = y; | ||
| 101 | petrinet_P3_marking_member_0[ petrinet_P3_is_marked + 2 ] = z; | ||
| 102 | petrinet_P3_is_marked += 3; | ||
| 103 | |||
| 104 | } /* end of if (Transition condition) */ | ||
| 105 | } | ||
| 106 | |||
| 107 | /* Permutation for Place petrinet_P1 : 0, 2, 1 */ | ||
| 108 | /* Transition T1 */ | ||
| 109 | if ( ( petrinet_P1_is_marked >= 3 ) && | ||
| 110 | ( petrinet_P3_is_marked + 3 <= 6 ) && | ||
| 111 | ( petrinet_P1_marking_member_0[ 2 ] | ||
| 112 | == petrinet_P1_marking_member_0[ 1 ] ) ) { | ||
| 113 | |||
| 114 | long x; | ||
| 115 | long y; | ||
| 116 | long z; | ||
| 117 | |||
| 118 | x = petrinet_P1_marking_member_0[ 0 ]; | ||
| 119 | y = petrinet_P1_marking_member_0[ 2 ]; | ||
| 120 | |||
| 121 | /* Transition condition */ | ||
| 122 | if ( ( x < y ) ) { | ||
| 123 | |||
| 124 | /* demarking of input places */ | ||
| 125 | petrinet_P1_is_marked -= 3; | ||
| 126 | |||
| 127 | /* preaction */ | ||
| 128 | z = x - y; | ||
| 129 | |||
| 130 | /* marking of output places */ | ||
