Skip to content

Commit 79f7fef

Browse files
authored
Merge pull request #1654 from SCIInstitute/more-subnets
More subnets
2 parents f66613a + 4d653a3 commit 79f7fef

39 files changed

+1523
-295
lines changed

src/Core/Application/Application.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,23 @@ std::string Application::moduleList()
297297
return ostr.str();
298298
}
299299

300+
bool Application::moduleNameExists(const std::string& name)
301+
{
302+
auto map = controller()->getAllAvailableModuleDescriptions();
303+
for (const auto& p1 : map)
304+
{
305+
for (const auto& p2 : p1.second)
306+
{
307+
for (const auto& p3 : p2.second)
308+
{
309+
if (boost::iequals(name, p3.first))
310+
return true;
311+
}
312+
}
313+
}
314+
return false;
315+
}
316+
300317
boost::filesystem::path Application::configDirectory() const
301318
{
302319
return applicationHelper.configDirectory();

src/Core/Application/Application.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class SCISHARE Application : boost::noncopyable //: public EventHandler, public
8383
std::string applicationName() const;
8484
std::string version() const;
8585
std::string moduleList();
86+
bool moduleNameExists(const std::string& name);
8687

8788
void shutdown();
8889

src/Dataflow/Engine/Controller/NetworkEditorController.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,17 @@ boost::shared_ptr<boost::thread> NetworkEditorController::executeAll(const Execu
607607

608608
void NetworkEditorController::executeModule(const ModuleHandle& module, const ExecutableLookup* lookup, bool executeUpstream)
609609
{
610-
ExecuteSingleModule filter(module, *theNetwork_, executeUpstream);
611-
executeGeneric(lookup, filter);
610+
try
611+
{
612+
ExecuteSingleModule filter(module, *theNetwork_, executeUpstream);
613+
executeGeneric(lookup, filter);
614+
}
615+
catch (NetworkHasCyclesException&)
616+
{
617+
SCIRun::Core::Logging::Log::get() << SCIRun::Core::Logging::ERROR_LOG << "Cannot schedule execution: network has cycles. Please break all cycles and try again." << std::endl;
618+
ExecutionContext::executionBounds_.executeFinishes_(-1);
619+
return;
620+
}
612621
}
613622

614623
void NetworkEditorController::initExecutor()
@@ -624,6 +633,10 @@ ExecutionContextHandle NetworkEditorController::createExecutionContext(const Exe
624633
boost::shared_ptr<boost::thread> NetworkEditorController::executeGeneric(const ExecutableLookup* lookup, ModuleFilter filter)
625634
{
626635
initExecutor();
636+
637+
638+
639+
627640
auto context = createExecutionContext(lookup, filter);
628641

629642
return executionManager_.enqueueContext(context);

src/Dataflow/Engine/Scheduler/GraphNetworkAnalyzer.cc

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,40 @@ ComponentMap NetworkGraphAnalyzer::connectedComponents()
137137
return componentMap;
138138
}
139139

140+
namespace SCIRun
141+
{
142+
namespace Dataflow
143+
{
144+
namespace Engine
145+
{
146+
class ExecuteSingleModuleImpl
147+
{
148+
public:
149+
ParallelModuleExecutionOrder order_;
150+
bool isDownstreamFrom(const ModuleId& toCheckId, const ModuleId& rootId) const
151+
{
152+
return order_.groupOf(toCheckId) >= order_.groupOf(rootId);
153+
}
154+
};
155+
}
156+
}
157+
}
158+
140159
ExecuteSingleModule::ExecuteSingleModule(SCIRun::Dataflow::Networks::ModuleHandle mod,
141160
const SCIRun::Dataflow::Networks::NetworkInterface& network,
142161
bool executeUpstream) : module_(mod), network_(network), executeUpstream_(executeUpstream)
143162
{
144163
//TODO: composite with which filter?
145164
NetworkGraphAnalyzer analyze(network, ExecuteAllModules::Instance(), false);
146165
components_ = analyze.connectedComponents();
166+
167+
if (!executeUpstream_)
168+
{
169+
orderImpl_.reset(new ExecuteSingleModuleImpl);
170+
auto all = boost::lambda::constant(true);
171+
BoostGraphParallelScheduler scheduleAll(all);
172+
orderImpl_->order_ = scheduleAll.schedule(network_);
173+
}
147174
}
148175

149176
bool ExecuteSingleModule::operator()(SCIRun::Dataflow::Networks::ModuleHandle mod) const
@@ -167,11 +194,8 @@ bool ExecuteSingleModule::operator()(SCIRun::Dataflow::Networks::ModuleHandle mo
167194
}
168195
else
169196
{
170-
auto all = boost::lambda::constant(true);
171-
BoostGraphParallelScheduler scheduleAll(all);
172-
auto order = scheduleAll.schedule(network_);
173-
174197
// should execute if in same connected component, and downstream only
175-
return modIdIter->second == rootIdIter->second && order.groupOf(toCheckId) >= order.groupOf(rootId);
198+
return modIdIter->second == rootIdIter->second
199+
&& orderImpl_->isDownstreamFrom(toCheckId, rootId);
176200
}
177201
}

src/Dataflow/Engine/Scheduler/SchedulerInterfaces.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ namespace Engine {
137137
static const ModuleWaitingFilter& Instance();
138138
};
139139

140+
class ExecuteSingleModuleImpl;
141+
140142
struct SCISHARE ExecuteSingleModule
141143
{
142144
ExecuteSingleModule(SCIRun::Dataflow::Networks::ModuleHandle mod,
@@ -147,6 +149,7 @@ namespace Engine {
147149
const SCIRun::Dataflow::Networks::NetworkInterface& network_;
148150
std::map<std::string, int> components_;
149151
bool executeUpstream_;
152+
boost::shared_ptr<ExecuteSingleModuleImpl> orderImpl_;
150153
};
151154

152155
class SCISHARE WaitsForStartupInitialization

0 commit comments

Comments
 (0)