Files
@ 36cc1fe490f7
Branch filter:
Location: CSY/reowolf/src/runtime2/tests/basics.rs - annotation
36cc1fe490f7
2.6 KiB
application/rls-services+xml
Merge branch 'feat-api-cmds-and-branching'
Implements the programmer-facing API to allow programmatic
specification of a synchronous round. The way in which these put/get
interactions are performed is in an initial shape. Perhaps this will
change in the future.
The second main set of changes is the addion of a 'fork' statement,
which allows explicit forking, and allowing multiple puts/gets over the
same transport link within a single sync round.
Implements the programmer-facing API to allow programmatic
specification of a synchronous round. The way in which these put/get
interactions are performed is in an initial shape. Perhaps this will
change in the future.
The second main set of changes is the addion of a 'fork' statement,
which allows explicit forking, and allowing multiple puts/gets over the
same transport link within a single sync round.
cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 cb4c9d11dfe6 |
use super::*;
#[test]
fn test_single_put_and_get() {
const CODE: &'static str = "
primitive putter(out<bool> sender, u32 loops) {
u32 index = 0;
while (index < loops) {
sync {
put(sender, true);
}
index += 1;
}
}
primitive getter(in<bool> receiver, u32 loops) {
u32 index = 0;
while (index < loops) {
sync {
auto result = get(receiver);
assert(result);
}
index += 1;
}
}
";
let thing = TestTimer::new("single_put_and_get");
run_test_in_runtime(CODE, |api| {
let channel = api.create_channel().unwrap();
api.create_connector("", "putter", ValueGroup::new_stack(vec![
Value::Output(PortId(Id{ connector_id: 0, u32_suffix: channel.putter_id.index })),
Value::UInt32(NUM_LOOPS)
])).expect("create putter");
api.create_connector("", "getter", ValueGroup::new_stack(vec![
Value::Input(PortId(Id{ connector_id: 0, u32_suffix: channel.getter_id.index })),
Value::UInt32(NUM_LOOPS)
])).expect("create getter");
});
}
#[test]
fn test_multi_put_and_get() {
const CODE: &'static str = "
primitive putter_static(out<u8> vals, u32 num_loops) {
u32 index = 0;
while (index < num_loops) {
sync {
put(vals, 0b00000001);
put(vals, 0b00000100);
put(vals, 0b00010000);
put(vals, 0b01000000);
}
index += 1;
}
}
primitive getter_dynamic(in<u8> vals, u32 num_loops) {
u32 loop_index = 0;
while (loop_index < num_loops) {
sync {
u32 recv_index = 0;
u8 expected = 1;
while (recv_index < 4) {
auto gotten = get(vals);
assert(gotten == expected);
expected <<= 2;
recv_index += 1;
}
}
loop_index += 1;
}
}
";
let thing = TestTimer::new("multi_put_and_get");
run_test_in_runtime(CODE, |api| {
let channel = api.create_channel().unwrap();
api.create_connector("", "putter_static", ValueGroup::new_stack(vec![
Value::Output(PortId::new(channel.putter_id.index)),
Value::UInt32(NUM_LOOPS),
])).unwrap();
api.create_connector("", "getter_dynamic", ValueGroup::new_stack(vec![
Value::Input(PortId::new(channel.getter_id.index)),
Value::UInt32(NUM_LOOPS),
])).unwrap();
})
}
|