This commit is contained in:
parent
7925b87f09
commit
12afc6633e
@ -29,8 +29,8 @@ steps:
|
|||||||
- cd build
|
- cd build
|
||||||
- conan install .. --build=missing
|
- conan install .. --build=missing
|
||||||
- cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DWITH_TESTS=OFF
|
- cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DWITH_TESTS=OFF
|
||||||
- ninja
|
- ninja op-finder
|
||||||
- cp -r ../testcases ./testcases
|
- cp -r ../testcases ./testcases
|
||||||
- cd ./testcases
|
- cd ./testcases
|
||||||
- mv ../op-finder ./
|
- ln ../op-finder/op-finder ./op-finder
|
||||||
- python3 ../../op-summarizer/tests.py
|
- python3 ../../op-summarizer/tests.py
|
||||||
|
|||||||
53
op-summarizer/data/gcov.json
Normal file
53
op-summarizer/data/gcov.json
Normal file
File diff suppressed because one or more lines are too long
213
op-summarizer/data/opfinder.json
Normal file
213
op-summarizer/data/opfinder.json
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
{
|
||||||
|
"matrix.c": [
|
||||||
|
{
|
||||||
|
"branch_number": 1,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "=",
|
||||||
|
"type_lhs": "int",
|
||||||
|
"type_result": "int",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 2,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "<",
|
||||||
|
"type_lhs": "int",
|
||||||
|
"type_result": "int",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 2,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "++",
|
||||||
|
"type_lhs": "int",
|
||||||
|
"type_result": "int",
|
||||||
|
"type_rhs": ""
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 1,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "=",
|
||||||
|
"type_lhs": "int",
|
||||||
|
"type_result": "int",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 22
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 2,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "<",
|
||||||
|
"type_lhs": "int",
|
||||||
|
"type_result": "int",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 22
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 2,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "++",
|
||||||
|
"type_lhs": "int",
|
||||||
|
"type_result": "int",
|
||||||
|
"type_rhs": ""
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 22
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 0,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "=",
|
||||||
|
"type_lhs": "unsigned short",
|
||||||
|
"type_result": "unsigned short",
|
||||||
|
"type_rhs": "unsigned short"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 24
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 0,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "subscript",
|
||||||
|
"type_lhs": "volatile UInt16 *",
|
||||||
|
"type_result": "unsigned short",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 24
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 0,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "subscript",
|
||||||
|
"type_lhs": "volatile UInt16 (*)[5]",
|
||||||
|
"type_result": "volatile UInt16 [5]",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 24
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 1,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "=",
|
||||||
|
"type_lhs": "int",
|
||||||
|
"type_result": "int",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 2,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "<",
|
||||||
|
"type_lhs": "int",
|
||||||
|
"type_result": "int",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 2,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "++",
|
||||||
|
"type_lhs": "int",
|
||||||
|
"type_result": "int",
|
||||||
|
"type_rhs": ""
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 0,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "subscript",
|
||||||
|
"type_lhs": "volatile UInt16 *",
|
||||||
|
"type_result": "unsigned short",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 27
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 0,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "subscript",
|
||||||
|
"type_lhs": "volatile UInt16 (*)[5]",
|
||||||
|
"type_result": "volatile UInt16 [5]",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 27
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 0,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "*",
|
||||||
|
"type_lhs": "int",
|
||||||
|
"type_result": "int",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 27
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 0,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "subscript",
|
||||||
|
"type_lhs": "const UInt16 *",
|
||||||
|
"type_result": "unsigned short",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 27
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 0,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "subscript",
|
||||||
|
"type_lhs": "const UInt16 (*)[4]",
|
||||||
|
"type_result": "const UInt16 [4]",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 27
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 0,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "subscript",
|
||||||
|
"type_lhs": "const UInt16 *",
|
||||||
|
"type_result": "unsigned short",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 27
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"branch_number": 0,
|
||||||
|
"entry": {
|
||||||
|
"operation_name": "subscript",
|
||||||
|
"type_lhs": "const UInt16 (*)[5]",
|
||||||
|
"type_result": "const UInt16 [5]",
|
||||||
|
"type_rhs": "int"
|
||||||
|
},
|
||||||
|
"entry_type": "basic_operation",
|
||||||
|
"line": 27
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -1,10 +1,10 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from dataclasses import asdict
|
from dataclasses import asdict
|
||||||
from typing import Dict, List
|
from typing import Dict, List, Tuple
|
||||||
|
|
||||||
from gcovreader import GCovFile
|
from gcovreader import GCovFile
|
||||||
from opfinderreader import OperationLogReader, UniqueOperation
|
from opfinderreader import OperationLogReader, UniqueOperation, OperationLog
|
||||||
|
|
||||||
|
|
||||||
class OpSummarizer:
|
class OpSummarizer:
|
||||||
@ -15,6 +15,25 @@ class OpSummarizer:
|
|||||||
self.gcov.read()
|
self.gcov.read()
|
||||||
self.ops.read()
|
self.ops.read()
|
||||||
|
|
||||||
|
self.model: Dict[UniqueOperation, Tuple[float, float]] = None
|
||||||
|
self.uncounted_estimates: Dict[UniqueOperation, int] = {}
|
||||||
|
self.energy_consumption_estimation = 0.0
|
||||||
|
self.execution_time_estimation = 0.0
|
||||||
|
|
||||||
|
def add_model(self, model_path: str) -> None:
|
||||||
|
with open(model_path, "r") as model_file:
|
||||||
|
data = json.load(model_file)
|
||||||
|
|
||||||
|
assert type(data) == list, "Model file did not contain a JSON list."
|
||||||
|
|
||||||
|
self.model = {}
|
||||||
|
for entry in data:
|
||||||
|
unique_op = OperationLog(**entry["unique_operation"]).entry
|
||||||
|
energy = entry["energy_consumption"]
|
||||||
|
time = entry["execution_time"]
|
||||||
|
|
||||||
|
self.model[unique_op] = [energy, time]
|
||||||
|
|
||||||
def count_operations(self, file: str) -> Dict[UniqueOperation, int]:
|
def count_operations(self, file: str) -> Dict[UniqueOperation, int]:
|
||||||
if file not in self.gcov.files or file not in self.ops.files:
|
if file not in self.gcov.files or file not in self.ops.files:
|
||||||
print(f"Gcov files: {self.gcov.files.keys()}")
|
print(f"Gcov files: {self.gcov.files.keys()}")
|
||||||
@ -40,6 +59,18 @@ class OpSummarizer:
|
|||||||
|
|
||||||
return op_counter
|
return op_counter
|
||||||
|
|
||||||
|
def update_estimations(self, uops: Dict[UniqueOperation, int]) -> None:
|
||||||
|
assert self.model, "Model not populated."
|
||||||
|
for unique_op, op_count in uops.items():
|
||||||
|
if unique_op in self.model:
|
||||||
|
energy, time = self.model[unique_op]
|
||||||
|
self.energy_consumption_estimation += energy * op_count
|
||||||
|
self.execution_time_estimation += time * op_count
|
||||||
|
elif unique_op in self.uncounted_estimates:
|
||||||
|
self.uncounted_estimates[unique_op] += op_count
|
||||||
|
else:
|
||||||
|
self.uncounted_estimates[unique_op] = op_count
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def operation_count_to_json_dict(unique_ops: Dict[UniqueOperation, int]) -> List[Dict]:
|
def operation_count_to_json_dict(unique_ops: Dict[UniqueOperation, int]) -> List[Dict]:
|
||||||
out = []
|
out = []
|
||||||
@ -64,16 +95,24 @@ if __name__ == "__main__":
|
|||||||
help="The op-finder json file to use.")
|
help="The op-finder json file to use.")
|
||||||
parser.add_argument("--output", type=str, default=None, required=False,
|
parser.add_argument("--output", type=str, default=None, required=False,
|
||||||
help="The file to output the data to.")
|
help="The file to output the data to.")
|
||||||
|
parser.add_argument("--model", type=str, default=None, required=False,
|
||||||
|
help="The JSON file containing the system model.")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
summarizer = OpSummarizer(args.gcov, args.finder)
|
summarizer = OpSummarizer(args.gcov, args.finder)
|
||||||
|
|
||||||
total_count = {}
|
if args.model:
|
||||||
|
summarizer.add_model(args.model)
|
||||||
|
|
||||||
|
uops_dictionary = {}
|
||||||
total_num = 0
|
total_num = 0
|
||||||
|
|
||||||
for file_name in args.files:
|
for file_name in args.files:
|
||||||
ops = summarizer.count_operations(file_name)
|
ops = summarizer.count_operations(file_name)
|
||||||
total_count[file_name] = summarizer.operation_count_to_json_dict(ops)
|
uops_dictionary[file_name] = summarizer.operation_count_to_json_dict(ops)
|
||||||
|
|
||||||
|
if args.model:
|
||||||
|
summarizer.update_estimations(ops)
|
||||||
|
|
||||||
print(f"Unique operations for file {file_name}:")
|
print(f"Unique operations for file {file_name}:")
|
||||||
for uop, count in ops.items():
|
for uop, count in ops.items():
|
||||||
@ -86,4 +125,16 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
if args.output:
|
if args.output:
|
||||||
with open(args.output, "w") as outfile:
|
with open(args.output, "w") as outfile:
|
||||||
json.dump(total_count, outfile)
|
json.dump(uops_dictionary, outfile)
|
||||||
|
|
||||||
|
if args.model:
|
||||||
|
power_usage_estimate = summarizer.energy_consumption_estimation
|
||||||
|
time_estimate = summarizer.execution_time_estimation
|
||||||
|
print("---------")
|
||||||
|
print(f"Total energy usage estimation: {power_usage_estimate} mJ\nTotal execution time estimation: {time_estimate} ms")
|
||||||
|
if summarizer.uncounted_estimates:
|
||||||
|
print("Operations not accounted for (missing from the model):")
|
||||||
|
for uop, count in summarizer.uncounted_estimates.items():
|
||||||
|
print(f"\t{uop}: {count}")
|
||||||
|
else:
|
||||||
|
print("No operations missing from the model.")
|
||||||
|
|||||||
@ -12,8 +12,8 @@ from opsummarizer import OpSummarizer
|
|||||||
class Compiler:
|
class Compiler:
|
||||||
def __init__(self, root_file: str) -> None:
|
def __init__(self, root_file: str) -> None:
|
||||||
self.root_file = root_file
|
self.root_file = root_file
|
||||||
self.gcov_file = f"{root_file}_gcov.json"
|
self.gcov_file = f"./{root_file}_gcov.json"
|
||||||
self.opfinder_file = f"{root_file}_opfinder.json"
|
self.opfinder_file = f"./{root_file}_opfinder.json"
|
||||||
|
|
||||||
def compile_and_profile(self) -> None:
|
def compile_and_profile(self) -> None:
|
||||||
output_file = f"{self.root_file}.out"
|
output_file = f"{self.root_file}.out"
|
||||||
@ -69,8 +69,8 @@ if __name__ == "__main__":
|
|||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
|
|
||||||
suite.addTest(SummarizerCreatesExpectedOutput("test_summarizer_output", "matrix"))
|
suite.addTest(SummarizerCreatesExpectedOutput("test_summarizer_output", "matrix"))
|
||||||
suite.addTest(SummarizerCreatesExpectedOutput("test_summarizer_output", "gauss_blur"))
|
# suite.addTest(SummarizerCreatesExpectedOutput("test_summarizer_output", "gauss_blur"))
|
||||||
suite.addTest(SummarizerCreatesExpectedOutput("test_summarizer_output", "for_loop"))
|
# suite.addTest(SummarizerCreatesExpectedOutput("test_summarizer_output", "for_loop"))
|
||||||
suite.addTest(SummarizerCreatesExpectedOutput("test_summarizer_output", "fir"))
|
# suite.addTest(SummarizerCreatesExpectedOutput("test_summarizer_output", "fir"))
|
||||||
|
|
||||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||||
|
|||||||
235
testcases/Dhrystone.c
Normal file
235
testcases/Dhrystone.c
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
*
|
||||||
|
* Name : Dhrystone
|
||||||
|
* Purpose : Benchmark the Dhrystone code. This benchmark is used to gauge
|
||||||
|
* the performance of the microcontroller in handling pointers,
|
||||||
|
* structures and strings.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define LOOPS 100 /* Use this for slow or 16 bit machines */
|
||||||
|
#define structassign(d, s) d = s
|
||||||
|
typedef enum {
|
||||||
|
Ident1, Ident2, Ident3, Ident4, Ident5
|
||||||
|
} Enumeration;
|
||||||
|
typedef int OneToThirty;
|
||||||
|
typedef int OneToFifty;
|
||||||
|
typedef unsigned char CapitalLetter;
|
||||||
|
typedef unsigned char String30[31];
|
||||||
|
typedef int Array1Dim[51];
|
||||||
|
typedef int Array2Dim[10][10];
|
||||||
|
struct Record
|
||||||
|
{
|
||||||
|
struct Record *PtrComp;
|
||||||
|
Enumeration Discr;
|
||||||
|
Enumeration EnumComp;
|
||||||
|
OneToFifty IntComp;
|
||||||
|
String30 StringComp;
|
||||||
|
};
|
||||||
|
typedef struct Record RecordType;
|
||||||
|
typedef RecordType * RecordPtr;
|
||||||
|
typedef int boolean;
|
||||||
|
//#define NULL 0
|
||||||
|
#define TRUE 1
|
||||||
|
#define FALSE 0
|
||||||
|
#define REG register
|
||||||
|
int IntGlob;
|
||||||
|
boolean BoolGlob;
|
||||||
|
unsigned char Char1Glob;
|
||||||
|
unsigned char Char2Glob;
|
||||||
|
Array1Dim Array1Glob;
|
||||||
|
Array2Dim Array2Glob;
|
||||||
|
RecordPtr PtrGlb;
|
||||||
|
RecordPtr PtrGlbNext;
|
||||||
|
RecordType rec1, rec2;
|
||||||
|
Enumeration Func1(CapitalLetter CharPar1, CapitalLetter CharPar2) {
|
||||||
|
REG CapitalLetter CharLoc1;
|
||||||
|
REG CapitalLetter CharLoc2;
|
||||||
|
CharLoc1 = CharPar1;
|
||||||
|
CharLoc2 = CharLoc1;
|
||||||
|
if (CharLoc2 != CharPar2)
|
||||||
|
return (Ident1);
|
||||||
|
else
|
||||||
|
return (Ident2);
|
||||||
|
}
|
||||||
|
boolean Func2(String30 StrParI1, String30 StrParI2) {
|
||||||
|
REG OneToThirty IntLoc;
|
||||||
|
REG CapitalLetter CharLoc;
|
||||||
|
IntLoc = 1;
|
||||||
|
while (IntLoc <= 1)
|
||||||
|
if (Func1(StrParI1[IntLoc], StrParI2[IntLoc + 1]) == Ident1) {
|
||||||
|
CharLoc = 'A';
|
||||||
|
++IntLoc;
|
||||||
|
}
|
||||||
|
if (CharLoc >= 'W' && CharLoc <= 'Z')
|
||||||
|
IntLoc = 7;
|
||||||
|
if (CharLoc == 'X')
|
||||||
|
return (TRUE);
|
||||||
|
else {
|
||||||
|
if (strcmp(StrParI1, StrParI2) > 0) {
|
||||||
|
IntLoc += 7;
|
||||||
|
return (TRUE);
|
||||||
|
} else
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean Func3(Enumeration EnumParIn) {
|
||||||
|
REG Enumeration EnumLoc;
|
||||||
|
EnumLoc = EnumParIn;
|
||||||
|
if (EnumLoc == Ident3)
|
||||||
|
return (TRUE);
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
void Proc7(OneToFifty IntParI1, OneToFifty IntParI2, OneToFifty *IntParOut) {
|
||||||
|
REG OneToFifty IntLoc;
|
||||||
|
IntLoc = IntParI1 + 2;
|
||||||
|
*IntParOut = IntParI2 + IntLoc;
|
||||||
|
}
|
||||||
|
void Proc4(void) {
|
||||||
|
REG boolean BoolLoc;
|
||||||
|
BoolLoc = Char1Glob == 'A';
|
||||||
|
BoolLoc |= BoolGlob;
|
||||||
|
Char2Glob = 'B';
|
||||||
|
}
|
||||||
|
void Proc5(void) {
|
||||||
|
Char1Glob = 'A';
|
||||||
|
BoolGlob = FALSE;
|
||||||
|
}
|
||||||
|
void Proc6(Enumeration EnumParIn, Enumeration *EnumParOut) {
|
||||||
|
*EnumParOut = EnumParIn;
|
||||||
|
if (!Func3(EnumParIn))
|
||||||
|
*EnumParOut = Ident4;
|
||||||
|
switch (EnumParIn) {
|
||||||
|
case Ident1:
|
||||||
|
*EnumParOut = Ident1;
|
||||||
|
break;
|
||||||
|
case Ident2:
|
||||||
|
if (IntGlob > 100)
|
||||||
|
*EnumParOut = Ident1;
|
||||||
|
else
|
||||||
|
*EnumParOut = Ident4;
|
||||||
|
break;
|
||||||
|
case Ident3:
|
||||||
|
*EnumParOut = Ident2;
|
||||||
|
break;
|
||||||
|
case Ident4:
|
||||||
|
break;
|
||||||
|
case Ident5:
|
||||||
|
*EnumParOut = Ident3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Proc3(RecordPtr *PtrParOut) {
|
||||||
|
if (PtrGlb != NULL)
|
||||||
|
*PtrParOut = PtrGlb->PtrComp;
|
||||||
|
else
|
||||||
|
IntGlob = 100;
|
||||||
|
Proc7(10, IntGlob, &PtrGlb->IntComp);
|
||||||
|
}
|
||||||
|
void Proc1(RecordPtr PtrParIn) {
|
||||||
|
#define NextRecord (*(PtrParIn->PtrComp))
|
||||||
|
structassign(NextRecord, *PtrGlb);
|
||||||
|
PtrParIn->IntComp = 5;
|
||||||
|
NextRecord.IntComp = PtrParIn->IntComp;
|
||||||
|
NextRecord.PtrComp = PtrParIn->PtrComp;
|
||||||
|
Proc3(&NextRecord.PtrComp);
|
||||||
|
if (NextRecord.Discr == Ident1) {
|
||||||
|
NextRecord.IntComp = 6;
|
||||||
|
Proc6(PtrParIn->EnumComp, &NextRecord.EnumComp);
|
||||||
|
NextRecord.PtrComp = PtrGlb->PtrComp;
|
||||||
|
Proc7(NextRecord.IntComp, 10, &NextRecord.IntComp);
|
||||||
|
} else
|
||||||
|
structassign(*PtrParIn, NextRecord);
|
||||||
|
#undef NextRecord
|
||||||
|
}
|
||||||
|
void Proc2(OneToFifty *IntParIO) {
|
||||||
|
REG OneToFifty IntLoc;
|
||||||
|
REG Enumeration EnumLoc;
|
||||||
|
IntLoc = *IntParIO + 10;
|
||||||
|
for (;;) {
|
||||||
|
if (Char1Glob == 'A') {
|
||||||
|
--IntLoc;
|
||||||
|
*IntParIO = IntLoc - IntGlob;
|
||||||
|
EnumLoc = Ident1;
|
||||||
|
}
|
||||||
|
if (EnumLoc == Ident1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Proc8(Array1Dim Array1Par, Array2Dim Array2Par, OneToFifty IntParI1,
|
||||||
|
OneToFifty IntParI2) {
|
||||||
|
REG OneToFifty IntLoc;
|
||||||
|
REG OneToFifty IntIndex;
|
||||||
|
IntLoc = IntParI1 + 5;
|
||||||
|
Array1Par[IntLoc] = IntParI2;
|
||||||
|
Array1Par[IntLoc + 1] = Array1Par[IntLoc];
|
||||||
|
Array1Par[IntLoc + 30] = IntLoc;
|
||||||
|
for (IntIndex = IntLoc; IntIndex <= (IntLoc + 1); ++IntIndex)
|
||||||
|
Array2Par[IntLoc][IntIndex] = IntLoc;
|
||||||
|
++Array2Par[IntLoc][IntLoc - 1];
|
||||||
|
Array2Par[IntLoc + 20][IntLoc] = Array1Par[IntLoc];
|
||||||
|
IntGlob = 5;
|
||||||
|
}
|
||||||
|
void Proc0(void) {
|
||||||
|
OneToFifty IntLoc1;
|
||||||
|
REG OneToFifty IntLoc2;
|
||||||
|
OneToFifty IntLoc3;
|
||||||
|
REG unsigned char CharLoc;
|
||||||
|
REG unsigned char CharIndex;
|
||||||
|
Enumeration EnumLoc;
|
||||||
|
String30 String1Loc;
|
||||||
|
String30 String2Loc;
|
||||||
|
//extern unsigned char *malloc();
|
||||||
|
long time(long *);
|
||||||
|
long starttime;
|
||||||
|
long benchtime;
|
||||||
|
long nulltime;
|
||||||
|
register unsigned int i;
|
||||||
|
for (i = 0; i < LOOPS; ++i)
|
||||||
|
;
|
||||||
|
PtrGlbNext = &rec1; /* (RecordPtr) malloc(sizeof(RecordType)); */
|
||||||
|
PtrGlb = &rec2; /* (RecordPtr) malloc(sizeof(RecordType)); */
|
||||||
|
PtrGlb->PtrComp = PtrGlbNext;
|
||||||
|
PtrGlb->Discr = Ident1;
|
||||||
|
PtrGlb->EnumComp = Ident3;
|
||||||
|
PtrGlb->IntComp = 40;
|
||||||
|
strcpy(PtrGlb->StringComp, "DHRYSTONE PROGRAM, SOME STRING");
|
||||||
|
strcpy(String1Loc, "DHRYSTONE PROGRAM, 1'ST STRING"); /*GOOF*/
|
||||||
|
Array2Glob[8][7] = 10; /* Was missing in published program */
|
||||||
|
for (i = 0; i < LOOPS; ++i) {
|
||||||
|
Proc5();
|
||||||
|
Proc4();
|
||||||
|
IntLoc1 = 2;
|
||||||
|
IntLoc2 = 3;
|
||||||
|
strcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
|
||||||
|
EnumLoc = Ident2;
|
||||||
|
BoolGlob = !Func2(String1Loc, String2Loc);
|
||||||
|
while (IntLoc1 < IntLoc2) {
|
||||||
|
IntLoc3 = 5 * IntLoc1 - IntLoc2;
|
||||||
|
Proc7(IntLoc1, IntLoc2, &IntLoc3);
|
||||||
|
++IntLoc1;
|
||||||
|
}
|
||||||
|
Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3);
|
||||||
|
Proc1(PtrGlb);
|
||||||
|
for (CharIndex = 'A'; CharIndex <= Char2Glob; ++CharIndex)
|
||||||
|
if (EnumLoc == Func1(CharIndex, 'C'))
|
||||||
|
Proc6(Ident1, &EnumLoc);
|
||||||
|
IntLoc3 = IntLoc2 * IntLoc1;
|
||||||
|
IntLoc2 = IntLoc3 / IntLoc1;
|
||||||
|
IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1;
|
||||||
|
Proc2(&IntLoc1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int main(void) {
|
||||||
|
// TRISG = 0;
|
||||||
|
//PORTG = 0;
|
||||||
|
int i;
|
||||||
|
//while(1){
|
||||||
|
// LATGINV = 0x0001;
|
||||||
|
for(i = 0; i < 100; i++){
|
||||||
|
Proc0();
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
241
testcases/Whetstone.c
Normal file
241
testcases/Whetstone.c
Normal file
@ -0,0 +1,241 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Name : Whetstone
|
||||||
|
* Purpose : Benchmark the Whetstone code. The code focuses on scientific
|
||||||
|
* functions such as sine, cosine, exponents and logarithm on
|
||||||
|
* fixed and floating point numbers.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
/* List of changes (since TI slaa205b.pdf):
|
||||||
|
- void type of PA(), P0(), P3()
|
||||||
|
- dummy functions to prevent optimization
|
||||||
|
- float (not double) variants of math funcions and constants (this
|
||||||
|
is no matter for AVR)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __AVR__
|
||||||
|
# define atanf(x) atan(x)
|
||||||
|
# define cosf(x) cos(x)
|
||||||
|
# define expf(x) exp(x)
|
||||||
|
# define logf(x) log(x)
|
||||||
|
# define sinf(x) sin(x)
|
||||||
|
# define sqrtf(x) sqrt(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Extern functions. To prevent compiler's optimization. */
|
||||||
|
void dummy1 (float x ){}
|
||||||
|
void dummy2 (float x , float y){}
|
||||||
|
|
||||||
|
void PA (float E[5]);
|
||||||
|
void P0 (void);
|
||||||
|
void P3 (float *X, float *Y, float *Z);
|
||||||
|
|
||||||
|
float T, T1, T2, E1[5];
|
||||||
|
int J, K, L;
|
||||||
|
float X1, X2, X3, X4;
|
||||||
|
long ptime, time0;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
//TRISG = 0;
|
||||||
|
//PORTG = 0;
|
||||||
|
int i;
|
||||||
|
//while(1){
|
||||||
|
//LATGINV = 0x0001;
|
||||||
|
for(i = 0; i < 100; i++){
|
||||||
|
|
||||||
|
int LOOP, I, II, JJ, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11;
|
||||||
|
float X, Y, Z;
|
||||||
|
T = .499975;
|
||||||
|
T1 = 0.50025;
|
||||||
|
T2 = 2.0;
|
||||||
|
LOOP = 1;
|
||||||
|
II = 1;
|
||||||
|
|
||||||
|
for (JJ = 1; JJ <= II; JJ++) {
|
||||||
|
N1 = 0;
|
||||||
|
N2 = 2 * LOOP;
|
||||||
|
N3 = 2 * LOOP;
|
||||||
|
N4 = 2 * LOOP;
|
||||||
|
N5 = 0;
|
||||||
|
N6 = 2 * LOOP;
|
||||||
|
N7 = 2 * LOOP;
|
||||||
|
N8 = 2 * LOOP;
|
||||||
|
N9 = 2 * LOOP;
|
||||||
|
N10 = 0;
|
||||||
|
N11 = 2 * LOOP;
|
||||||
|
|
||||||
|
/* Module 1: Simple identifiers */
|
||||||
|
X1 = 1.0;
|
||||||
|
X2 = -1.0;
|
||||||
|
X3 = -1.0;
|
||||||
|
X4 = -1.0;
|
||||||
|
if (N1 != 0) {
|
||||||
|
for (I = 1; I <= N1; I++) {
|
||||||
|
X1 = (X1 + X2 + X3 - X4) * T;
|
||||||
|
X2 = (X1 + X2 - X3 + X4) * T;
|
||||||
|
X3 = (X1 - X2 + X3 + X4) * T;
|
||||||
|
X4 = (-X1 + X2 + X3 + X4) * T;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Module 2: Array elements */
|
||||||
|
E1[1] = 1.0;
|
||||||
|
E1[2] = -1.0;
|
||||||
|
E1[3] = -1.0;
|
||||||
|
E1[4] = -1.0;
|
||||||
|
if (N2 != 0) {
|
||||||
|
for (I = 1; I <= N2; I++) {
|
||||||
|
E1[1] = (E1[1] + E1[2] + E1[3] - E1[4]) * T;
|
||||||
|
E1[2] = (E1[1] + E1[2] - E1[3] + E1[4]) * T;
|
||||||
|
E1[3] = (E1[1] - E1[2] + E1[3] + E1[4]) * T;
|
||||||
|
E1[4] = (-E1[1] + E1[2] + E1[3] + E1[4]) * T;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Module 3: Array as parameter */
|
||||||
|
if (N3 != 0) {
|
||||||
|
for (I = 1; I <= N3; I++) {
|
||||||
|
PA (E1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Module 4: Conditional jumps */
|
||||||
|
J = 1;
|
||||||
|
if (N4 != 0) {
|
||||||
|
for (I = 1; I <= N4; I++) {
|
||||||
|
if (J == 1)
|
||||||
|
goto L51;
|
||||||
|
J = 3;
|
||||||
|
goto L52;
|
||||||
|
L51:
|
||||||
|
J = 2;
|
||||||
|
L52:
|
||||||
|
if (J > 2)
|
||||||
|
goto L53;
|
||||||
|
J = 1;
|
||||||
|
goto L54;
|
||||||
|
L53:
|
||||||
|
J = 0;
|
||||||
|
L54:
|
||||||
|
if (J < 1)
|
||||||
|
goto L55;
|
||||||
|
J = 0;
|
||||||
|
goto L60;
|
||||||
|
L55:
|
||||||
|
J = 1;
|
||||||
|
L60: ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Module 5: Integer arithmetic */
|
||||||
|
J = 1;
|
||||||
|
K = 2;
|
||||||
|
L = 3;
|
||||||
|
if (N6 != 0) { /* ??? Where is N5? */
|
||||||
|
for (I = 1; I <= N6; I++) {
|
||||||
|
J = J * (K - J) * (L - K);
|
||||||
|
K = L * K - (L - J) * K;
|
||||||
|
L = (L - K) * (K + J);
|
||||||
|
E1[L - 1] = J + K + L;
|
||||||
|
E1[K - 1] = J * K * L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Module 6: Trigonometric functions */
|
||||||
|
X = 0.5;
|
||||||
|
Y = 0.5;
|
||||||
|
if (N7 != 0) {
|
||||||
|
for (I = 1; I <= N7; I++) {
|
||||||
|
X = T * atanf (T2 * sinf (X) * cosf (X) /
|
||||||
|
(cosf (X + Y) + cosf (X - Y) - 1.0f));
|
||||||
|
Y = T * atanf (T2 * sinf (Y) * cosf (Y) /
|
||||||
|
(cosf (X + Y) + cosf (X - Y) - 1.0f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dummy2 (X, Y);
|
||||||
|
|
||||||
|
/* Module 7: Procedure calls */
|
||||||
|
X = 1.0;
|
||||||
|
Y = 1.0;
|
||||||
|
Z = 1.0;
|
||||||
|
if (N8 != 0) {
|
||||||
|
for (I = 1; I <= N8; I++) {
|
||||||
|
P3 (&X, &Y, &Z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Module 8: Array references */
|
||||||
|
J = 1;
|
||||||
|
K = 2;
|
||||||
|
L = 3;
|
||||||
|
E1[1] = 1.0;
|
||||||
|
E1[2] = 2.0;
|
||||||
|
E1[3] = 3.0;
|
||||||
|
if (N9 != 0) {
|
||||||
|
for (I = 1; I <= N9; I++) {
|
||||||
|
P0 ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Module 9: Integer arithmetic */
|
||||||
|
J = 2;
|
||||||
|
K = 3;
|
||||||
|
if (N10 != 0) { /* TI skips this strange test. */
|
||||||
|
for (I = 1; I <= N10; I++) {
|
||||||
|
J = J + K;
|
||||||
|
K = J + K;
|
||||||
|
J = K - J;
|
||||||
|
K = K - J - J;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Module 10: Standard functions */
|
||||||
|
X = 0.75;
|
||||||
|
if (N11 != 0) {
|
||||||
|
for (I = 1; I <= N11; I++) {
|
||||||
|
X = sqrtf (expf (logf (X) / T1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dummy1 (X);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void PA (float E[5])
|
||||||
|
{
|
||||||
|
int J1;
|
||||||
|
J1 = 0;
|
||||||
|
L10:
|
||||||
|
E[1] = (E[1] + E[2] + E[3] - E[4]) * T;
|
||||||
|
E[2] = (E[1] + E[2] - E[3] + E[4]) * T;
|
||||||
|
E[3] = (E[1] - E[2] + E[3] + E[4]) * T;
|
||||||
|
E[4] = (-E[1] + E[2] + E[3] + E[4]) / T2;
|
||||||
|
J1 = J1 + 1;
|
||||||
|
if ((J1 - 6) < 0)
|
||||||
|
goto L10;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void P0 ()
|
||||||
|
{
|
||||||
|
E1[J] = E1[K];
|
||||||
|
E1[K] = E1[L];
|
||||||
|
E1[L] = E1[J];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void P3 (float *X, float *Y, float *Z)
|
||||||
|
{
|
||||||
|
float Y1;
|
||||||
|
X1 = *X;
|
||||||
|
Y1 = *Y;
|
||||||
|
X1 = T * (X1 + Y1);
|
||||||
|
Y1 = T * (X1 + Y1);
|
||||||
|
*Z = (X1 + Y1) / T2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
54
testcases/if_sentences.c
Normal file
54
testcases/if_sentences.c
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int a, b, c;
|
||||||
|
b = 10;
|
||||||
|
c = 15;
|
||||||
|
|
||||||
|
|
||||||
|
// F
|
||||||
|
if (c == 10)
|
||||||
|
{
|
||||||
|
a = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// F
|
||||||
|
if (c == 10)
|
||||||
|
{
|
||||||
|
a = 10;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
a = 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
// F T
|
||||||
|
if (c == 10 || b == 10)
|
||||||
|
{
|
||||||
|
a = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// T T (not taken)
|
||||||
|
if (c == 15 || b == 10)
|
||||||
|
{
|
||||||
|
a = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// T T
|
||||||
|
if (c == 15 && b == 10)
|
||||||
|
{
|
||||||
|
a = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// T F
|
||||||
|
if (c == 15 && b == 15)
|
||||||
|
{
|
||||||
|
a = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// F T
|
||||||
|
if (c == 10 && b == 15)
|
||||||
|
{
|
||||||
|
a = 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -17,12 +17,12 @@ int main(void)
|
|||||||
{
|
{
|
||||||
int m, n, p;
|
int m, n, p;
|
||||||
volatile UInt16 m3[3][5];
|
volatile UInt16 m3[3][5];
|
||||||
for(m = 0; m < 3; m++) // 1
|
for(m = 0; m < 3; m++) // 1 + 3 * 2 // 3 * 3
|
||||||
{
|
{
|
||||||
for(p = 0; p < 5; p++) // 3
|
for(p = 0; p < 5; p++) // 3 + 15 * 2 // 15 * 3
|
||||||
{
|
{
|
||||||
m3[m][p] = 0; // 15: BasicOperation(operation_name='=', type_lhs='unsigned short', type_rhs='unsigned short', type_result='unsigned short')
|
m3[m][p] = 0; // 15: BasicOperation(operation_name='=', type_lhs='unsigned short', type_rhs='unsigned short', type_result='unsigned short')
|
||||||
for(n = 0; n < 4; n++) // 15
|
for(n = 0; n < 4; n++) // 15 + 60 * 2 // 60 * 3
|
||||||
{
|
{
|
||||||
m3[m][p] += m1[m][n] * m2[n][p];
|
m3[m][p] += m1[m][n] * m2[n][p];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user