Пример #1
0
	RegionList ParallelSelector::getRegions(const core::NodePtr& node) const {

		RegionList res;
		auto parallel = node->getNodeManager().getLangBasic().getParallel();
		core::visitDepthFirst(core::NodeAddress(node), [&](const core::CallExprAddress& cur)->bool {
			if (*cur.getAddressedNode()->getFunctionExpr() != *parallel) {
				return false;
			}

			core::JobExprAddress job = cur->getArgument(0).as<core::JobExprAddress>();
			core::ExpressionAddress addr = job->getBody();

			if(addr->getNodeType() == core::NT_BindExpr) {
				addr = addr.as<core::BindExprAddress>()->getCall()->getFunctionExpr();
			}

			if (addr->getNodeType() == core::NT_LambdaExpr) {
				res.push_back(addr.as<core::LambdaExprAddress>()->getBody());
			}

			return true;

		}, false);

		return res;
	}
Пример #2
0
	RegionList PForSelector::getRegions(const core::NodePtr& node) const {
		RegionList res;
		auto pfor = node->getNodeManager().getLangExtension<lang::ParallelExtension>().getPFor();
		core::visitDepthFirstPrunable(core::NodeAddress(node), [&](const core::CallExprAddress& cur) -> bool {
			if(*cur.getAddressedNode()->getFunctionExpr() != *pfor) { return false; }
			res.push_back(cur);
			return true;
		}, false);

		return res;
	}
Пример #3
0
	RegionList PForBodySelector::getRegions(const core::NodePtr& node) const {
		RegionList res;
		auto pfor = node->getNodeManager().getLangExtension<lang::ParallelExtension>().getPFor();
		core::visitDepthFirstPrunable(core::NodeAddress(node), [&](const core::CallExprAddress& cur) -> bool {
			if(*cur.getAddressedNode()->getFunctionExpr() != *pfor) { return false; }
			core::ExpressionAddress body = cur->getArgument(4);
			if(body->getNodeType() == core::NT_BindExpr) { body = body.as<core::BindExprAddress>()->getCall()->getFunctionExpr(); }
			if(body->getNodeType() == core::NT_LambdaExpr) { res.push_back(body.as<core::LambdaExprAddress>()->getBody()); }
			return true;
		}, false);

		return res;
	}