|
| 1 | +/*************************** |
| 2 | +@Author: Chunel |
| 3 | + |
| 4 | +@File: test-functional-03.cpp |
| 5 | +@Time: 2023/12/29 22:13 |
| 6 | +@Desc: |
| 7 | +***************************/ |
| 8 | + |
| 9 | + |
| 10 | +#include "../_Materials/TestInclude.h" |
| 11 | + |
| 12 | +using namespace CGraph; |
| 13 | + |
| 14 | +void test_functional_03() { |
| 15 | + CStatus status; |
| 16 | + GPipelinePtr pipeline = GPipelineFactory::create(); |
| 17 | + GElementPtr a, b_cluster, c, d_region, e = nullptr; |
| 18 | + |
| 19 | + b_cluster = pipeline->createGGroup<GCluster>({ |
| 20 | + pipeline->createGNode<TestMaterialAdd1GNode>(GNodeInfo("nodeB1", 1)), // 创建名为nodeB1的node信息,并将其放入b_cluster中 |
| 21 | + pipeline->createGNode<TestMaterialAdd1GNode>(GNodeInfo("nodeB2", 3)), // 创建名为nodeB2且自循环3次的node信息,并将其放入b_cluster中 |
| 22 | + pipeline->createGNode<TestMaterialAdd1GNode>(GNodeInfo("nodeB3", 1)) |
| 23 | + }); |
| 24 | + |
| 25 | + GElementPtr d1, d2, d3, d4, d23_cluster = nullptr; |
| 26 | + d1 = pipeline->createGNode<TestMaterialAdd1GNode>(GNodeInfo({}, "nodeD1", 1)); |
| 27 | + d2 = pipeline->createGNode<TestMaterialAdd1GNode>(GNodeInfo("nodeD2", 1)); // 创建node,稍后放入cluster中 |
| 28 | + d3 = pipeline->createGNode<TestMaterialAdd1GNode>(GNodeInfo("nodeD3", 1)); |
| 29 | + d23_cluster = pipeline->createGGroup<GCluster>({d2, d3}, {d1}, "clusterD23", 1); |
| 30 | + d4 = pipeline->createGNode<TestMaterialAdd1GNode>(GNodeInfo({d1}, "nodeD4", 1)); |
| 31 | + d_region = pipeline->createGGroup<GRegion>({d1, d23_cluster, d4}); // 创建名为d_region的region信息,并将{d1,d23_cluster,d4}放入其中 |
| 32 | + |
| 33 | + status += pipeline->registerGElement<TestMaterialAdd1GNode>(&a, {}, "nodeA", 1); |
| 34 | + status += pipeline->registerGGroup(&b_cluster, {}, "clusterB", 1); |
| 35 | + status += pipeline->registerGElement<TestMaterialAdd1GNode>(&c, {a, b_cluster}, "nodeC", 1); |
| 36 | + status += pipeline->registerGGroup(&d_region, {a, b_cluster}, "regionD", 2); // 将名为regionD,依赖{a,b_cluster}执行且自循环2次的region信息,注册入pipeline中 |
| 37 | + status += pipeline->registerGElement<TestMaterialAdd1GNode>(&e, {c, d_region}, "nodeE", 1); |
| 38 | + if (!status.isOK()) { |
| 39 | + return; |
| 40 | + } |
| 41 | + |
| 42 | + { |
| 43 | + UTimeCounter counter("test_functional_03"); |
| 44 | + pipeline->addGAspect<TestMaterialAdd1GAspect>(); |
| 45 | + status = pipeline->process(50000); |
| 46 | + } |
| 47 | + |
| 48 | + if (g_test_node_cnt % 58 != 0) { |
| 49 | + // 58 是单次执行本测例的情况下,i++的次数。包含 aspect和 element |
| 50 | + std::cout << g_test_node_cnt << " num can not divide 58." << std::endl; |
| 51 | + } |
| 52 | + |
| 53 | + if (status.isErr()) { |
| 54 | + std::cout << status.getInfo() << std::endl; |
| 55 | + } |
| 56 | + GPipelineFactory::remove(pipeline); |
| 57 | +} |
| 58 | + |
| 59 | + |
| 60 | +int main() { |
| 61 | + test_functional_03(); |
| 62 | + return 0; |
| 63 | +} |
0 commit comments