File: ParallelEngine.hpp

package info (click to toggle)
yade 2026.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,448 kB
  • sloc: cpp: 97,645; python: 52,173; sh: 677; makefile: 162
file content (32 lines) | stat: -rw-r--r-- 1,276 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include <core/GlobalEngine.hpp>

namespace yade { // Cannot have #include directive inside.

class ParallelEngine;
shared_ptr<ParallelEngine> ParallelEngine_ctor_list(const boost::python::list& slaves);

class ParallelEngine : public Engine {
public:
	typedef vector<vector<shared_ptr<Engine>>> slaveContainer;
	void                                       action() override;
	bool                                       isActivated() override { return true; }
	// py access
	boost::python::list slaves_get();
	void                slaves_set(const boost::python::list& slaves);
	// clang-format off
	YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(ParallelEngine,Engine,"Engine for running other Engine in parallel.",
		((slaveContainer,slaves,,,"[will be overridden]"))
		,
		/*ctor*/
		ompThreads=2;
		,
		/*py*/
		.def("__init__",boost::python::make_constructor(ParallelEngine_ctor_list),"Construct from (possibly nested) list of slaves.")
		.add_property("slaves",&ParallelEngine::slaves_get,&ParallelEngine::slaves_set,"List of lists of Engines; each top-level group will be run in parallel with other groups, while Engines inside each group will be run sequentially, in given order.");
	);
	// clang-format on
};
REGISTER_SERIALIZABLE(ParallelEngine);

} // namespace yade