Skip to content

Commit 7931111

Browse files
committed
Merge branch 'master' into hide-non-working-widgets
Conflicts: src/Interface/Modules/Visualization/ShowFieldDialog.cc
2 parents 5435760 + 6c73ccf commit 7931111

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2035
-1235
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ https://github.com/SCIInstitute/SCIRun
2525
|:--------:|:-------------------------------------------------------------------------------------:|
2626

2727
###Goals
28-
SCIRun 5 is a complete rewrite of the GUI front end and graphical components of SCIRun 4, including a more stable and
28+
SCIRun 5 is a complete rewrite of the GUI front end and graphical components of SCIRun 4, including a more stable and
2929
efficient middle layer, with support for Python scripting.
3030

3131
### Documentation
@@ -39,11 +39,11 @@ For documentation, please see: http://sciinstitute.github.io/SCIRun/
3939
+ Download from http://releases.qt-project.org/qt4/source/qt-mac-opensource-4.8.4.dmg.
4040
* Windows (tested on Windows 7, 8)
4141
- Visual Studio 2013
42-
- Qt 4.8
42+
- Qt 4.8
4343
+ Build from source (see http://scirundocwiki.sci.utah.edu/SCIRunDocs/index.php/CIBC:Seg3D2:Building_Releases#Installing_Qt_on_your_system_and_building_from_scratch for instructions), but be sure to download http://releases.qt-project.org/qt4/source/qt-everywhere-opensource-src-4.8.4.tar.gz.
4444
* Linux (tested on Ubuntu 12.10)
4545
- gcc 4.6, 4.7
46-
- Qt 4.8
46+
- Qt 4.8
4747
+ Build from source (http://releases.qt-project.org/qt4/source/qt-everywhere-opensource-src-4.8.4.tar.gz), or use system libraries if available.
4848
* All platforms
4949
- CMake 2.8
@@ -56,8 +56,8 @@ For documentation, please see: http://sciinstitute.github.io/SCIRun/
5656
* Windows
5757
- Visual Studio 2013
5858
* OS X (tested on 10.7 and 10.8 and 10.10)
59-
- Unix Makefiles
60-
- Xcode
59+
- Unix Makefiles
60+
- Xcode
6161
* Linux (tested on Ubuntu 12.10)
6262
- Unix Makefiles
6363

@@ -71,23 +71,23 @@ For help, email the testing mailing list at [email protected].
7171

7272
### License and Credits
7373
For more information, please see: http://software.sci.utah.edu
74-
74+
7575
The MIT License
76-
77-
Copyright (c) 2013 Scientific Computing and Imaging Institute,
76+
77+
Copyright (c) 2015 Scientific Computing and Imaging Institute,
7878
University of Utah.
79-
80-
79+
80+
8181
Permission is hereby granted, free of charge, to any person obtaining a
8282
copy of this software and associated documentation files (the "Software"),
8383
to deal in the Software without restriction, including without limitation
8484
the rights to use, copy, modify, merge, publish, distribute, sublicense,
8585
and/or sell copies of the Software, and to permit persons to whom the
8686
Software is furnished to do so, subject to the following conditions:
87-
87+
8888
The above copyright notice and this permission notice shall be included
8989
in all copies or substantial portions of the Software.
90-
90+
9191
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9292
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9393
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL

src/Core/Algorithms/Math/GetMatrixSliceAlgo.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,20 @@ using namespace SCIRun::Core::Algorithms::Math;
4343
ALGORITHM_PARAMETER_DEF(Math, IsSliceColumn);
4444
ALGORITHM_PARAMETER_DEF(Math, SliceIndex);
4545
ALGORITHM_PARAMETER_DEF(Math, MaxIndex);
46-
ALGORITHM_PARAMETER_DEF(Math, PlayMode);
46+
ALGORITHM_PARAMETER_DEF(Math, PlayModeActive);
47+
ALGORITHM_PARAMETER_DEF(Math, PlayModeType);
48+
ALGORITHM_PARAMETER_DEF(Math, SliceIncrement);
49+
ALGORITHM_PARAMETER_DEF(Math, PlayModeDelay);
4750

4851
GetMatrixSliceAlgo::GetMatrixSliceAlgo()
4952
{
5053
addParameter(Parameters::IsSliceColumn, true);
5154
addParameter(Parameters::SliceIndex, 0);
52-
addParameter(Parameters::PlayMode, false);
55+
addParameter(Parameters::PlayModeActive, false);
56+
//TODO DAN: make overload to handle const char*
57+
add_option(Parameters::PlayModeType, "looponce", "looponce|loopforever"); //TODO add more play options
58+
addParameter(Parameters::SliceIncrement, 1);
59+
addParameter(Parameters::PlayModeDelay, 0);
5360
}
5461

5562
AlgorithmOutput GetMatrixSliceAlgo::run_generic(const AlgorithmInput& input) const

src/Core/Algorithms/Math/GetMatrixSliceAlgo.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ namespace SCIRun {
4242
ALGORITHM_PARAMETER_DECL(IsSliceColumn);
4343
ALGORITHM_PARAMETER_DECL(SliceIndex);
4444
ALGORITHM_PARAMETER_DECL(MaxIndex);
45-
ALGORITHM_PARAMETER_DECL(PlayMode);
45+
ALGORITHM_PARAMETER_DECL(PlayModeActive);
46+
ALGORITHM_PARAMETER_DECL(PlayModeType);
47+
ALGORITHM_PARAMETER_DECL(SliceIncrement);
48+
ALGORITHM_PARAMETER_DECL(PlayModeDelay);
4649

4750
class SCISHARE GetMatrixSliceAlgo : public AlgorithmBase
4851
{

src/Dataflow/Engine/Controller/NetworkEditorController.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ void NetworkEditorController::clear()
335335

336336
// TODO:
337337
// - [X] refactor duplication
338-
// - [ ] set up execution context queue
339-
// - [ ] separate threads for looping through queue: another producer/consumer pair
338+
// - [X] set up execution context queue
339+
// - [X] separate threads for looping through queue: another producer/consumer pair
340340

341341
void NetworkEditorController::executeAll(const ExecutableLookup* lookup)
342342
{
@@ -356,7 +356,6 @@ void NetworkEditorController::initExecutor()
356356

357357
ExecutionContextHandle NetworkEditorController::createExecutionContext(const ExecutableLookup* lookup, ModuleFilter filter)
358358
{
359-
theNetwork_->setModuleExecutionState(ModuleInterface::Waiting, filter);
360359
return boost::make_shared<ExecutionContext>(*theNetwork_, lookup ? *lookup : *theNetwork_, filter);
361360
}
362361

src/Dataflow/Engine/Scheduler/BasicMultithreadedNetworkExecutor.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ namespace
4242
{
4343
struct ParallelExecution : public WaitsForStartupInitialization
4444
{
45-
ParallelExecution(const ExecutableLookup* lookup, const ParallelModuleExecutionOrder& order, const ExecutionBounds& bounds) : lookup_(lookup), order_(order), bounds_(bounds)
45+
ParallelExecution(const ExecutableLookup* lookup, const ParallelModuleExecutionOrder& order, const ExecutionBounds& bounds, Mutex* executionLock)
46+
: lookup_(lookup), order_(order), bounds_(bounds), executionLock_(executionLock)
4647
{}
4748

4849
void operator()() const
4950
{
5051
waitForStartupInit(*lookup_);
52+
Guard g(executionLock_->get());
5153
/// @todo ESSENTIAL: scoped start/finish signaling
5254
bounds_.executeStarts_();
5355
for (int group = order_.minGroup(); group <= order_.maxGroup(); ++group)
@@ -70,12 +72,13 @@ namespace
7072
const ExecutableLookup* lookup_;
7173
ParallelModuleExecutionOrder order_;
7274
const ExecutionBounds& bounds_;
75+
Mutex* executionLock_;
7376
};
7477

7578
}
7679

77-
void BasicMultithreadedNetworkExecutor::execute(const ExecutionContext& context, ParallelModuleExecutionOrder order)
80+
void BasicMultithreadedNetworkExecutor::execute(const ExecutionContext& context, ParallelModuleExecutionOrder order, Mutex& executionLock)
7881
{
79-
ParallelExecution runner(&context.lookup, order, context.bounds());
82+
ParallelExecution runner(&context.lookup, order, context.bounds(), &executionLock);
8083
boost::thread execution(runner);
8184
}

src/Dataflow/Engine/Scheduler/BasicMultithreadedNetworkExecutor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace Engine {
4242
class SCISHARE BasicMultithreadedNetworkExecutor : public NetworkExecutor<ParallelModuleExecutionOrder>
4343
{
4444
public:
45-
virtual void execute(const ExecutionContext& context, ParallelModuleExecutionOrder order) override;
45+
virtual void execute(const ExecutionContext& context, ParallelModuleExecutionOrder order, Core::Thread::Mutex& executionLock) override;
4646
};
4747

4848
}}}

src/Dataflow/Engine/Scheduler/BasicParallelExecutionStrategy.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@
3434

3535
using namespace SCIRun::Dataflow::Engine;
3636
using namespace SCIRun::Dataflow::Networks;
37+
using namespace SCIRun::Core::Thread;
3738

38-
void BasicParallelExecutionStrategy::execute(const ExecutionContext& context)
39+
void BasicParallelExecutionStrategy::execute(const ExecutionContext& context, Mutex& executionLock)
3940
{
4041
auto filter = context.addAdditionalFilter(ExecuteAllModules::Instance());
4142
BoostGraphParallelScheduler scheduler(filter);
4243
BasicMultithreadedNetworkExecutor executor;
43-
executeWithCycleCheck(scheduler, executor, context);
44+
executeWithCycleCheck(scheduler, executor, context, executionLock);
4445
}

src/Dataflow/Engine/Scheduler/BasicParallelExecutionStrategy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace SCIRun {
4040
class SCISHARE BasicParallelExecutionStrategy : public ExecutionStrategy
4141
{
4242
public:
43-
virtual void execute(const ExecutionContext& context) override;
43+
virtual void execute(const ExecutionContext& context, Core::Thread::Mutex& executionLock) override;
4444
};
4545

4646
}

src/Dataflow/Engine/Scheduler/DynamicExecutor/WorkUnitProducer.h

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,16 @@ namespace SCIRun {
4949
public:
5050
ModuleProducer(const Networks::ModuleFilter& filter,
5151
const Networks::NetworkInterface* network, Core::Thread::Mutex* lock, ModuleWorkQueuePtr work, size_t numModules) :
52-
scheduler_(filter), network_(network), lock_(lock),
53-
work_(work), doneCount_(0), shouldLog_(SCIRun::Core::Logging::Log::get().verbose()), numModules_(numModules)
52+
scheduler_(filter), network_(network), enqueueLock_(lock),
53+
work_(work), doneCount_(0), badGroup_(false),
54+
shouldLog_(SCIRun::Core::Logging::Log::get().verbose()), numModules_(numModules)
5455
{
5556
log_.setVerbose(shouldLog_);
5657
}
5758

5859
virtual void enqueueReadyModules() const
5960
{
60-
Core::Thread::Guard g(lock_->get());
61+
Core::Thread::Guard g(enqueueLock_->get());
6162
if (!isDone())
6263
{
6364
auto order = scheduler_.schedule(*network_);
@@ -68,6 +69,10 @@ namespace SCIRun {
6869
log_ << Core::Logging::DEBUG_LOG << ostr.str() << std::endl;
6970
log_ << Core::Logging::DEBUG_LOG << "Producer processing min group " << order.minGroup();
7071
}
72+
if (order.minGroup() < 0)
73+
{
74+
badGroup_ = true;
75+
}
7176
auto groupIter = order.getGroup(order.minGroup());
7277
BOOST_FOREACH(const ParallelModuleExecutionOrder::ModulesByGroup::value_type& mod, groupIter)
7378
{
@@ -81,7 +86,7 @@ namespace SCIRun {
8186
if (doneIds_.find(mod.second) != doneIds_.end())
8287
{
8388
if (shouldLog_)
84-
SCIRun::Core::Logging::Log::get() << SCIRun::Core::Logging::INFO << "Module producer: wants to enqueue module " << mod.second << " a second time." << std::endl;
89+
SCIRun::Core::Logging::Log::get() << SCIRun::Core::Logging::INFO << "Module producer: wants to enqueue module " << mod.second << " a second time." << id_ << " " << std::endl;
8590
}
8691
else
8792
{
@@ -90,7 +95,7 @@ namespace SCIRun {
9095
doneCount_.fetch_add(1);
9196

9297
if (shouldLog_)
93-
log_ << Core::Logging::DEBUG_LOG << "Producer status: " << doneCount_ << " out of " << numModules_ << std::endl;
98+
log_ << Core::Logging::DEBUG_LOG << "Producer status: " << id_ << " " << doneCount_ << " out of " << numModules_ << std::endl;
9499
}
95100
}
96101
}
@@ -99,16 +104,23 @@ namespace SCIRun {
99104

100105
void operator()() const
101106
{
107+
id_ = boost::this_thread::get_id();
102108
if (shouldLog_)
103-
log_ << Core::Logging::DEBUG_LOG << "Producer started" << std::endl;
109+
log_ << Core::Logging::DEBUG_LOG << "Producer started " << id_ << std::endl;
104110

105111
enqueueReadyModules();
106112

107-
while (!isDone())
108-
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
113+
while (!badGroup_ && !isDone())
114+
{
115+
boost::this_thread::sleep(boost::posix_time::milliseconds(100));
116+
//std::cout << "producer thread waiting " << id_ << std::endl;
117+
}
118+
119+
if (badGroup_)
120+
std::cerr << "producer is done with bad group, something went wrong. probably a race condition..." << std::endl;
109121

110122
if (shouldLog_)
111-
log_ << Core::Logging::DEBUG_LOG << "Producer is done." << std::endl;
123+
log_ << Core::Logging::DEBUG_LOG << "Producer is done. " << id_ << std::endl;
112124
}
113125

114126
bool isDone() const
@@ -118,13 +130,15 @@ namespace SCIRun {
118130
private:
119131
BoostGraphParallelScheduler scheduler_;
120132
const Networks::NetworkInterface* network_;
121-
Core::Thread::Mutex* lock_;
133+
Core::Thread::Mutex* enqueueLock_;
122134
ModuleWorkQueuePtr work_;
123135
mutable boost::atomic<int> doneCount_;
136+
mutable bool badGroup_;
124137
mutable std::set<Networks::ModuleId> doneIds_;
125138
static Core::Logging::Log& log_;
126139
bool shouldLog_;
127140
size_t numModules_;
141+
mutable boost::thread::id id_;
128142
};
129143

130144
typedef boost::shared_ptr<ModuleProducer> ModuleProducerPtr;

src/Dataflow/Engine/Scheduler/DynamicMultithreadedNetworkExecutor.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,21 @@ namespace SCIRun {
5151
class DynamicMultithreadedNetworkExecutorImpl : public WaitsForStartupInitialization
5252
{
5353
public:
54-
DynamicMultithreadedNetworkExecutorImpl(const ExecutionContext& context, const NetworkInterface* network, Mutex* lock, size_t numModules) :
54+
DynamicMultithreadedNetworkExecutorImpl(const ExecutionContext& context, const NetworkInterface* network, Mutex* lock, size_t numModules, Mutex* executionLock) :
5555
executeThreads_(new boost::thread_group),
5656
lookup_(&context.lookup),
5757
bounds_(&context.bounds()),
5858
work_(new DynamicExecutor::ModuleWorkQueue(numModules)),
5959
producer_(new DynamicExecutor::ModuleProducer(context.addAdditionalFilter(ModuleWaitingFilter::Instance()),
6060
network, lock, work_, numModules)),
6161
consumer_(new DynamicExecutor::ModuleConsumer(work_, lookup_, producer_, *executeThreads_)),
62-
network_(network)
62+
network_(network),
63+
executionLock_(executionLock)
6364
{
6465
}
6566
void operator()() const
6667
{
68+
Guard g(executionLock_->get());
6769
ScopedExecutionBoundsSignaller signaller(bounds_, [=]() { return lookup_->errorCode(); });
6870

6971
waitForStartupInit(*network_);
@@ -82,19 +84,20 @@ namespace SCIRun {
8284
DynamicExecutor::ModuleProducerPtr producer_;
8385
DynamicExecutor::ModuleConsumerPtr consumer_;
8486
const NetworkInterface* network_;
87+
Mutex* executionLock_;
8588
};
8689
}}}
8790

8891
DynamicMultithreadedNetworkExecutor::DynamicMultithreadedNetworkExecutor(const NetworkInterface& network) : network_(network) {}
8992

90-
void DynamicMultithreadedNetworkExecutor::execute(const ExecutionContext& context, ParallelModuleExecutionOrder order)
93+
void DynamicMultithreadedNetworkExecutor::execute(const ExecutionContext& context, ParallelModuleExecutionOrder order, Mutex& executionLock)
9194
{
9295
static Mutex lock("live-scheduler");
9396

9497
if (Log::get().verbose())
9598
LOG_DEBUG("DMTNE::executeAll order received: " << order << std::endl);
9699

97-
DynamicMultithreadedNetworkExecutorImpl runner(context, &network_, &lock, order.size());
100+
DynamicMultithreadedNetworkExecutorImpl runner(context, &network_, &lock, order.size(), &executionLock);
98101
boost::thread execution(runner);
99102
}
100103

0 commit comments

Comments
 (0)