int _tmain(int argc, _TCHAR* argv[]) { std::vector<SimulationEngine> engines; engines.resize(2); // Construct two simulatoin engines, representing each half of the model. PartitionedPostMaster post_master; PartitionedTopologyBuilder builder1(0, &post_master), builder2(1, &post_master); engines[0].Init(&builder1); engines[1].Init(&builder2); int iter_count = 0; int step = 0; // Process until both engines are idle. while (!(engines[0].IsIdle() && engines[1].IsIdle())) { // Every 400 iterations, extract the virtual time, and push the GVT // to the respective simulation engines. if (!(iter_count % 400)) { Time engine1 = engines[0].LocalVirtualTime(); Time engine2 = engines[1].LocalVirtualTime(); Time gvt = engine1 < engine2 ? engine1 : engine2; engines[0].ReceiveGlobalVirtualTime(gvt); engines[1].ReceiveGlobalVirtualTime(gvt); // Be horrible, and send an event at gvt. Event bogus_event; bogus_event.set_receive_time_stamp(gvt); bogus_event.set_send_time_stamp(gvt); bogus_event.set_sending_process_id(666); bogus_event.set_payload(667); bogus_event.set_type(1337); bogus_event.set_target_process_id(builder1.generator1()->id()); post_master.SendMessage(bogus_event); } // Time step the engines a differing number of times, so that // they become out of sync, and the buffers can fill up. int time_steps[] = {1, 3, 2, 5, 3, 7, 2}; for (int x = 0; x < time_steps[step%7]; ++x ) engines[0].TimeStep(); ++step; for (int x = 0; x < time_steps[step%7]; ++x ) engines[1].TimeStep(); std::cout << "Engine 1@: " << engines[0].LocalVirtualTime() << ", Engine 2@: " << engines[1].LocalVirtualTime() << std::endl; ++iter_count; } return 0; }
int main(int argc, char **argv) { CBLQRegionEncoder<2> builder(CBLQRegionEncoderConfig(true), 64); builder.push_bits(3, true); builder.push_bits(4, false); builder.push_bits(2, true); builder.push_bits(7, false); builder.push_bits(24, true); builder.push_bits(7, false); builder.push_bits(1, true); // Try consecutive 1-pushes builder.push_bits(16, true); builder.finalize(); boost::shared_ptr< CBLQRegionEncoding<2> > region = builder.to_region_encoding(); region->dump(); printf("\n\n"); // Expected: // Level 0: 2121 // Level 1: 2220 1102 // Level 2: // Dense suffix: 1110 0001 1000 0001 CBLQRegionEncoder<2> builder2(CBLQRegionEncoderConfig(true), 64); builder2.push_bits(7, true); builder2.push_bits(2, false); builder2.push_bits(7, true); builder2.push_bits(16, false); builder2.push_bits(32, false); builder2.finalize(); boost::shared_ptr< CBLQRegionEncoding<2> > region2 = builder2.to_region_encoding(); region2->dump(); printf("\n\n"); // Expected: // Level 0: 2000 // Level 1: 1221 // Level 2: // Dense suffix: 1110 0111 CBLQSetOperations<2> setops(CBLQSetOperationsConfig(false)); boost::shared_ptr< CBLQRegionEncoding<2> > uregion = setops.binary_set_op(region, region2, NArySetOperation::UNION); uregion->dump(); printf("\n\n"); // Expected: // Level 0: 2121 // Level 1: 1221 1102 // Level 2: // Dense suffix: 1111 1111 0001 uregion->compact(); uregion->dump(); printf("\n\n"); // Expected: // Level 0: 1121 // Level 1: 1102 // Level 2: // Dense suffix: 0001 boost::shared_ptr< CBLQRegionEncoding<2> > uregion2 = setops.binary_set_op(uregion, uregion, NArySetOperation::UNION); uregion2->dump(); printf("\n\n"); // Expected: // Level 0: 1121 // Level 1: 1102 // Level 2: // Dense suffix: 0001 boost::shared_ptr< CBLQRegionEncoding<2> > uregion3 = setops.binary_set_op(uregion, region, NArySetOperation::UNION); uregion3->dump(); printf("\n\n"); // Expected: // Level 0: 1121 // Level 1: 1102 // Level 2: // Dense suffix: 0001 }