Skip to content
Snippets Groups Projects
Commit 06c27bd8 authored by Cookiebowser's avatar Cookiebowser
Browse files

updated Java-MC benchmark files

also fixed some issues in the readme and added rust as an option to the base makefile
parent 619f4ab6
Branches
No related tags found
1 merge request!28Rust support
Showing
with 5188 additions and 6532 deletions
...@@ -7,6 +7,7 @@ JAVA_DEPENDENCIES= :btypes.jar ...@@ -7,6 +7,7 @@ JAVA_DEPENDENCIES= :btypes.jar
CPP_CODE_GEN_FLAGS=-l cpp -mc true CPP_CODE_GEN_FLAGS=-l cpp -mc true
CPPC ?= clang++ CPPC ?= clang++
CPPFLAGS ?= -std=c++14 -O1 -flto CPPFLAGS ?= -std=c++14 -O1 -flto
RS_CODE_GEN_FLAGS=-l rs -mc true
STRATEGY=mixed STRATEGY=mixed
THREADS=1 THREADS=1
CACHING=false CACHING=false
...@@ -42,6 +43,13 @@ ifeq ($(LANGUAGE), cpp) ...@@ -42,6 +43,13 @@ ifeq ($(LANGUAGE), cpp)
$(CPPC) $(CPPFLAGS) -o $@.exec $@.cpp $(CPPC) $(CPPFLAGS) -o $@.exec $@.cpp
./$@.exec $(STRATEGY) $(THREADS) $(CACHING) ./$@.exec $(STRATEGY) $(THREADS) $(CACHING)
endif endif
ifneq (,$(findstring $(LANGUAGE), rs|RS|rust|Rust))
%:
java -jar B2Program-all-0.1.0-SNAPSHOT.jar $(RS_CODE_GEN_FLAGS) -f $(DIRECTORY)/$@.mch
mv $(DIRECTORY)/$@.rs ./btypes_primitives/src/main/rust/bmachine/src/main.rs
mv $(DIRECTORY)/*.rs ./btypes_primitives/src/main/rust/bmachine/src/
cargo run --release --manifest-path ./btypes_primitives/src/main/rust/bmachine/Cargo.toml -- $(STRATEGY) $(THREADS) $(CACHING)
endif
endif endif
# Usage: # Usage:
......
...@@ -122,7 +122,7 @@ P is a conjunction of n conjuncts where the i-th conjunct must constraint xi for ...@@ -122,7 +122,7 @@ P is a conjunction of n conjuncts where the i-th conjunct must constraint xi for
| Predicate | Meaning | | Predicate | Meaning |
|-----------------------|------------| |-----------------------|------------|
| E = F | equality | | E = F | equality |
| E \= F | inequality | | E \\= F | inequality |
### Booleans: ### Booleans:
...@@ -141,7 +141,7 @@ P is a conjunction of n conjuncts where the i-th conjunct must constraint xi for ...@@ -141,7 +141,7 @@ P is a conjunction of n conjuncts where the i-th conjunct must constraint xi for
| {} | Empty Set | | {} | Empty Set |
| {E} | Singleton Set | | {E} | Singleton Set |
| {E,F,...} | Set Enumeration | | {E,F,...} | Set Enumeration |
| {x1,...,xn\ |P} | Set Comprehension | | {x1,...,xn|P} | Set Comprehension |
| POW(S) | Power Set | | POW(S) | Power Set |
| POW1(S) | Set of Non-Empty Subsets | | POW1(S) | Set of Non-Empty Subsets |
| FIN(S) | Set of All Finite Subsets | | FIN(S) | Set of All Finite Subsets |
...@@ -235,7 +235,7 @@ Restriction: Set of Relation mostly grows up very fast. They are only supported ...@@ -235,7 +235,7 @@ Restriction: Set of Relation mostly grows up very fast. They are only supported
### Functions: ### Functions:
| Function Expression | Meaning | | Function Expression | Meaning |
|---------------------|-----------------------------------| |--------------------------|-----------------------------------|
| S +-> T | Partial Function | | S +-> T | Partial Function |
| S --> T | Total Function | | S --> T | Total Function |
| S +->> T | Partial Surjection | | S +->> T | Partial Surjection |
...@@ -243,7 +243,7 @@ Restriction: Set of Relation mostly grows up very fast. They are only supported ...@@ -243,7 +243,7 @@ Restriction: Set of Relation mostly grows up very fast. They are only supported
| S >+> T | Partial Injection | | S >+> T | Partial Injection |
| S >+>> T | Partial Bijection | | S >+>> T | Partial Bijection |
| S >->> T | Total Bijection | | S >->> T | Total Bijection |
| %(x1,...,xn).(P\|E) | Lambda Abstraction | | %(x1,...,xn).(P|E) | Lambda Abstraction |
| f(E) | Function Application | | f(E) | Function Application |
| f(E1,...,EN) | Function Application with Couples | | f(E1,...,EN) | Function Application with Couples |
......
import statistics
import sys
from datetime import timedelta
file = sys.argv[1]
print('opening file: ', file)
# {machine: { (mode: str, threads: int, caching: bool): {times: [], memory: []} }}
data = {}
with open(file, 'r') as lines:
for line in lines:
#print('parsing line: ', line)
stripped_line = line.strip()
if stripped_line == '' or stripped_line.startswith('-'):
continue
machine, mode, threads, caching, time, memory = stripped_line.split(' ')
if machine not in data:
data[machine] = {}
params = (mode, int(threads), caching == 'true')
if params not in data[machine]:
data[machine][params] = {'times': [], 'memory': []}
data[machine][params]['times'] += [time]
data[machine][params]['memory'] += [int(memory)]
for machine in data.keys():
for params in data[machine]:
times = data[machine][params]['times']
avg_time = timedelta()
number_of_datapoints = 0
for time in times:
number_of_datapoints += 1
minutes = 0
if ':' in time:
split = time.split(':')
minutes = int(split[0])
time = split[1]
millis = 0
if '.' in time:
split = time.split('.')
millis = int(split[1].ljust(3, '0'))
time = split[0]
seconds = int(time)
avg_time += timedelta(minutes=minutes, seconds=seconds, milliseconds=millis)
if number_of_datapoints > 0:
avg_time /= number_of_datapoints
memories = data[machine][params]['memory']
print(f'{machine} {params[0]} {params[1]} {params[2]} {round(avg_time.total_seconds(), 2)} {round(statistics.fmean(memories))}')
This diff is collapsed.
...@@ -12,6 +12,7 @@ import java.util.Map; ...@@ -12,6 +12,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
...@@ -813,7 +814,7 @@ public class Cruise_finite1_deterministic_MC { ...@@ -813,7 +814,7 @@ public class Cruise_finite1_deterministic_MC {
private final boolean isDebug; private final boolean isDebug;
private final LinkedList<Cruise_finite1_deterministic_MC> unvisitedStates = new LinkedList<>(); private final LinkedList<Cruise_finite1_deterministic_MC> unvisitedStates = new LinkedList<>();
private final Set<Cruise_finite1_deterministic_MC> states = new HashSet<>(); private final Set<Cruise_finite1_deterministic_MC> states = ConcurrentHashMap.newKeySet();
private AtomicInteger transitions = new AtomicInteger(0); private AtomicInteger transitions = new AtomicInteger(0);
private ThreadPoolExecutor threadPool; private ThreadPoolExecutor threadPool;
private Object waitLock = new Object(); private Object waitLock = new Object();
...@@ -906,9 +907,7 @@ public class Cruise_finite1_deterministic_MC { ...@@ -906,9 +907,7 @@ public class Cruise_finite1_deterministic_MC {
Set<Cruise_finite1_deterministic_MC> nextStates = generateNextStates(state); Set<Cruise_finite1_deterministic_MC> nextStates = generateNextStates(state);
nextStates.forEach(nextState -> { nextStates.forEach(nextState -> {
synchronized (states) { if(states.add(nextState)) {
if(!states.contains(nextState)) {
states.add(nextState);
synchronized (unvisitedStates) { synchronized (unvisitedStates) {
unvisitedStates.add(nextState); unvisitedStates.add(nextState);
} }
...@@ -918,7 +917,6 @@ public class Cruise_finite1_deterministic_MC { ...@@ -918,7 +917,6 @@ public class Cruise_finite1_deterministic_MC {
System.out.println("-------------------"); System.out.println("-------------------");
} }
} }
}
}); });
synchronized (unvisitedStates) { synchronized (unvisitedStates) {
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -10,6 +10,7 @@ import java.util.Map; ...@@ -10,6 +10,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
...@@ -141,7 +142,7 @@ public class Lift_MC_Large { ...@@ -141,7 +142,7 @@ public class Lift_MC_Large {
private final boolean isDebug; private final boolean isDebug;
private final LinkedList<Lift_MC_Large> unvisitedStates = new LinkedList<>(); private final LinkedList<Lift_MC_Large> unvisitedStates = new LinkedList<>();
private final Set<Lift_MC_Large> states = new HashSet<>(); private final Set<Lift_MC_Large> states = ConcurrentHashMap.newKeySet();
private AtomicInteger transitions = new AtomicInteger(0); private AtomicInteger transitions = new AtomicInteger(0);
private ThreadPoolExecutor threadPool; private ThreadPoolExecutor threadPool;
private Object waitLock = new Object(); private Object waitLock = new Object();
...@@ -234,9 +235,7 @@ public class Lift_MC_Large { ...@@ -234,9 +235,7 @@ public class Lift_MC_Large {
Set<Lift_MC_Large> nextStates = generateNextStates(state); Set<Lift_MC_Large> nextStates = generateNextStates(state);
nextStates.forEach(nextState -> { nextStates.forEach(nextState -> {
synchronized (states) { if(states.add(nextState)) {
if(!states.contains(nextState)) {
states.add(nextState);
synchronized (unvisitedStates) { synchronized (unvisitedStates) {
unvisitedStates.add(nextState); unvisitedStates.add(nextState);
} }
...@@ -246,7 +245,6 @@ public class Lift_MC_Large { ...@@ -246,7 +245,6 @@ public class Lift_MC_Large {
System.out.println("-------------------"); System.out.println("-------------------");
} }
} }
}
}); });
synchronized (unvisitedStates) { synchronized (unvisitedStates) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -20,6 +20,8 @@ impl Display for BString { ...@@ -20,6 +20,8 @@ impl Display for BString {
impl BObject for BString {} impl BObject for BString {}
impl BString { impl BString {
#![allow(non_snake_case, dead_code)]
pub fn new(init: &str) -> BString { pub fn new(init: &str) -> BString {
return BString { val: String::from(init) } return BString { val: String::from(init) }
} }
......
...@@ -7,7 +7,6 @@ import de.hhu.stups.codegenerator.generators.CodeGenerationException; ...@@ -7,7 +7,6 @@ import de.hhu.stups.codegenerator.generators.CodeGenerationException;
import de.hhu.stups.codegenerator.generators.MachineGenerator; import de.hhu.stups.codegenerator.generators.MachineGenerator;
import de.hhu.stups.codegenerator.generators.MachineReferenceGenerator; import de.hhu.stups.codegenerator.generators.MachineReferenceGenerator;
import de.hhu.stups.codegenerator.generators.VisualisationGenerator; import de.hhu.stups.codegenerator.generators.VisualisationGenerator;
import de.hhu.stups.codegenerator.json.JSONASTBuilder;
import de.hhu.stups.codegenerator.json.modelchecker.ModelCheckingInfo; import de.hhu.stups.codegenerator.json.modelchecker.ModelCheckingInfo;
import de.hhu.stups.codegenerator.json.simb.SimulationRewriter; import de.hhu.stups.codegenerator.json.simb.SimulationRewriter;
import de.hhu.stups.codegenerator.json.visb.VisBFileHandler; import de.hhu.stups.codegenerator.json.visb.VisBFileHandler;
...@@ -114,6 +113,7 @@ public class CodeGenerator { ...@@ -114,6 +113,7 @@ public class CodeGenerator {
DefaultParser parser = new DefaultParser(); DefaultParser parser = new DefaultParser();
return parser.parse(options, args); return parser.parse(options, args);
} catch (ParseException e) { } catch (ParseException e) {
System.out.println(e.getMessage());
new HelpFormatter().printHelp("{-l <language> -bi <use_big_integer> -min <minint> -max <maxint> -dss <deferred_set_size> -cs <use_constraint_solving> -mc <forModelChecking> -f <filename> -v <visualisation> -a <additionalMain>} | -sim <simb_file>", options); new HelpFormatter().printHelp("{-l <language> -bi <use_big_integer> -min <minint> -max <maxint> -dss <deferred_set_size> -cs <use_constraint_solving> -mc <forModelChecking> -f <filename> -v <visualisation> -a <additionalMain>} | -sim <simb_file>", options);
} }
return null; return null;
...@@ -142,7 +142,7 @@ public class CodeGenerator { ...@@ -142,7 +142,7 @@ public class CodeGenerator {
} else if("rs".equals(languageOption)) { } else if("rs".equals(languageOption)) {
mode = GeneratorMode.RS; mode = GeneratorMode.RS;
} else { } else {
throw new RuntimeException("Wrong argument for language (must be java, python, c, cpp, clojure, ts)"); throw new RuntimeException(String.format("Wrong argument '%s' for language (must be java, python, c, cpp, clojure, ts, rs)", languageOption));
} }
return mode; return mode;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment