| 
									
										
										
										
											2021-02-07 10:45:07 +08:00
										 |  |  | //
 | 
					
						
							|  |  |  | //  ExecutorScopeMultiThreadTest.cpp
 | 
					
						
							|  |  |  | //  MNNTests
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //  Created by MNN on 2020/2/2.
 | 
					
						
							|  |  |  | //  Copyright © 2018, Alibaba Group Holding Limited
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <MNN/expr/ExecutorScope.hpp>
 | 
					
						
							|  |  |  | #include "MNNTestSuite.h"
 | 
					
						
							|  |  |  | #include "MNN_generated.h"
 | 
					
						
							|  |  |  | #include <thread>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using namespace MNN::Express; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ExecutorScopeMultiThreadTest : public MNNTestCase { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2021-06-11 17:17:13 +08:00
										 |  |  |     virtual bool run(int precision) { | 
					
						
							| 
									
										
										
										
											2021-02-07 10:45:07 +08:00
										 |  |  |         std::vector<std::thread> threads; | 
					
						
							|  |  |  |         for (int i = 0; i < 4; ++i) { | 
					
						
							|  |  |  |             threads.emplace_back([&]() { | 
					
						
							|  |  |  |                 ExecutorScope scope(ExecutorScope::Current()); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         for (auto& t : threads) { | 
					
						
							|  |  |  |             t.join(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MNNTestSuiteRegister(ExecutorScopeMultiThreadTest, "expr/ExecutorScopeMultiThread"); |