Changeset - 5d69ddcae67e
[Not reviewed]
0 5 0
MH - 4 years ago 2021-11-10 00:19:28
contact@maxhenger.nl
WIP on fixing bug in test
5 files changed with 110 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/protocol/eval/executor.rs
Show inline comments
 
@@ -953,6 +953,7 @@ impl Prompt {
 

	
 
                // Construct argument group, thereby copying heap regions
 
                let argument_group = ValueGroup::from_store(&self.store, &args);
 
                // println!("Creating {} with\n{:#?}", heap[call_expr.definition].identifier().value.as_str(), argument_group);
 

	
 
                // Clear any heap regions
 
                for arg in &args {
src/protocol/parser/pass_definitions.rs
Show inline comments
 
@@ -1888,6 +1888,23 @@ fn consume_parser_type(
 
        }
 
    }
 

	
 
    // If here then we have found the correct number of angle braces.
 

	
 
    // Check for trailing array identifiers
 
    while Some(TokenKind::OpenSquare) == iter.next() {
 
        let (array_start, _) = iter.next_positions();
 
        iter.consume();
 
        if Some(TokenKind::CloseSquare) != iter.next() {
 
            return Err(ParseError::new_error_str_at_pos(
 
                source, iter.last_valid_pos(),
 
                "unexpected token: expected ']'"
 
            ));
 
        }
 
        let (_, array_end) = iter.next_positions();
 
        iter.consume();
 
        insert_array_before(&mut elements, 0, InputSpan::from_positions(array_start, array_end))
 
    }
 

	
 
    // If here then we found the correct number of angle braces. But we still
 
    // need to make sure that each encountered type has the correct number of
 
    // embedded types.
src/protocol/tests/parser_validation.rs
Show inline comments
 
@@ -351,3 +351,25 @@ fn test_incorrect_union_instance() {
 
        .assert_msg_has(1, "has been resolved to 'bool'");
 
    });
 
}
 

	
 
#[test]
 
fn test_polymorph_array_types() {
 
    Tester::new_single_source_expect_ok(
 
        "array of polymorph in struct",
 
        "
 
        struct Foo<T> { T[] hello }
 
        struct Bar { Foo<u32>[] world }
 
        "
 
    ).for_struct("Bar", |s| { s
 
        .for_field("world", |f| { f.assert_parser_type("Foo<u32>[]"); });
 
    });
 

	
 
    Tester::new_single_source_expect_ok(
 
        "array of port in struct",
 
        "
 
        struct Bar { in<u32>[] inputs }
 
        "
 
    ).for_struct("Bar", |s| { s
 
        .for_field("inputs", |f| { f.assert_parser_type("in<u32>[]"); });
 
    });
 
}
 
\ No newline at end of file
src/runtime2/connector.rs
Show inline comments
 
@@ -354,8 +354,8 @@ impl ConnectorPDL {
 
                let (getter, putter) = sched_ctx.runtime.create_channel(comp_ctx.id);
 
                debug_assert!(getter.kind == PortKind::Getter && putter.kind == PortKind::Putter);
 
                branch.prepared_channel = Some((
 
                    Value::Input(PortId::new(putter.self_id.index)),
 
                    Value::Output(PortId::new(getter.self_id.index)),
 
                    Value::Output(PortId::new(putter.self_id.index)),
 
                    Value::Input(PortId::new(getter.self_id.index)),
 
                ));
 

	
 
                comp_ctx.push_port(putter);
src/runtime2/tests/mod.rs
Show inline comments
 
@@ -4,8 +4,8 @@ use crate::common::Id;
 
use crate::protocol::eval::*;
 

	
 
const NUM_THREADS: u32 = 1;  // number of threads in runtime
 
const NUM_INSTANCES: u32 = 4;  // number of test instances constructed
 
const NUM_LOOPS: u32 = 4;      // number of loops within a single test (not used by all tests)
 
const NUM_INSTANCES: u32 = 1;  // number of test instances constructed
 
const NUM_LOOPS: u32 = 1500;      // number of loops within a single test (not used by all tests)
 

	
 
fn create_runtime(pdl: &str) -> Runtime {
 
    let protocol = ProtocolDescription::parse(pdl.as_bytes()).expect("parse pdl");
 
@@ -73,7 +73,7 @@ fn test_put_and_get() {
 
    }
 
    ";
 

	
 
    let thing = TestTimer::new("hello");
 
    let thing = TestTimer::new("put_and_get");
 
    run_test_in_runtime(CODE, |api| {
 
        let channel = api.create_channel();
 

	
 
@@ -88,3 +88,68 @@ fn test_put_and_get() {
 
        ])).expect("create getter");
 
    });
 
}
 

	
 
#[test]
 
fn test_star_shaped_request() {
 
    const CODE: &'static str = "
 
    primitive edge(in<u32> input, out<u32> output, u32 loops) {
 
        u32 index = 0;
 
        while (index < loops) {
 
            synchronous {
 
                auto req = get(input);
 
                put(output, req * 2);
 
            }
 
            index += 1;
 
        }
 
    }
 

	
 
    primitive center(out<u32>[] requests, in<u32>[] responses, u32 loops) {
 
        u32 loop_index = 0;
 
        auto num_edges = length(requests);
 

	
 
        while (loop_index < loops) {
 
            print(\"starting loop\");
 
            synchronous {
 
                u32 edge_index = 0;
 
                u32 sum = 0;
 
                while (edge_index < num_edges) {
 
                    put(requests[edge_index], edge_index);
 
                    auto response = get(responses[edge_index]);
 
                    sum += response;
 
                    edge_index += 1;
 
                }
 

	
 
                assert(sum == num_edges * (num_edges - 1));
 
            }
 
            print(\"ending loop\");
 
            loop_index += 1;
 
        }
 
    }
 

	
 
    composite constructor(u32 num_edges, u32 num_loops) {
 
        auto requests = {};
 
        auto responses = {};
 

	
 
        u32 edge_index = 0;
 
        while (edge_index < num_edges) {
 
            channel req_put -> req_get;
 
            channel resp_put -> resp_get;
 
            new edge(req_get, resp_put, num_loops);
 
            requests @= { req_put };
 
            responses @= { resp_get };
 

	
 
            edge_index += 1;
 
        }
 

	
 
        new center(requests, responses, num_loops);
 
    }
 
    ";
 

	
 
    let thing = TestTimer::new("star_shaped_request");
 
    run_test_in_runtime(CODE, |api| {
 
        api.create_connector("", "constructor", ValueGroup::new_stack(vec![
 
            Value::UInt32(5),
 
            Value::UInt32(NUM_LOOPS),
 
        ]));
 
    });
 
}
 
\ No newline at end of file
0 comments (0 inline, 0 general)