Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weejobs - integrate as new job scheduling subsystem #2443

Merged
merged 17 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set(OSGEARTH_PATCH_VERSION 0)
set(OSGEARTH_VERSION ${OSGEARTH_MAJOR_VERSION}.${OSGEARTH_MINOR_VERSION}.${OSGEARTH_PATCH_VERSION})

# Increment this each time the ABI changes
set(OSGEARTH_SOVERSION 149)
set(OSGEARTH_SOVERSION 150)

# Require C++11
set_property(GLOBAL PROPERTY CXX_STANDARD 11)
Expand Down
2 changes: 2 additions & 0 deletions CMakeModules/oe_unix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ IF(UNIX AND NOT ANDROID)
FIND_PACKAGE(X11)
# Some Unicies need explicit linkage to the Math library or the build fails.
FIND_LIBRARY(MATH_LIBRARY m)
# for ptheads in linux
find_package(Threads REQUIRED)
ENDIF(UNIX AND NOT ANDROID)
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ struct ProgressReporter : public osgEarth::ProgressCallback
unsigned totalStages,
const std::string& msg)
{
ScopedMutexLock lock(_mutex);
std::lock_guard<std::mutex> lock(_mutex);

if (_first)
{
Expand Down Expand Up @@ -388,7 +388,7 @@ struct ProgressReporter : public osgEarth::ProgressCallback
return false;
}

Threading::Mutex _mutex;
std::mutex _mutex;
bool _first;
osg::Timer_t _start;
};
Expand Down
1 change: 0 additions & 1 deletion src/applications/osgearth_clamp/osgearth_clamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ struct App
osg::ref_ptr<OGRFeatureSource> input;
osg::ref_ptr<OGRFeatureSource> output;
Threading::Mutexed<std::queue<FeatureList*> > outputQueue;
Threading::Event gate;
std::string attrName;
bool verbose;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,12 @@ void computeIntersectionsThreaded(osg::Node* node, std::vector< IntersectionQuer
}
}
}

JobArena::get("oe.intersections")->setConcurrency(num_threads);

auto pool = jobs::get_pool("oe.intersections");
pool->set_concurrency(num_threads);

// Poor man's parallel for
JobGroup intersections;
jobs::jobgroup intersections;

//unsigned int workSize = 500;
// Try to split the jobs evenly among the threads
Expand All @@ -505,12 +506,16 @@ void computeIntersectionsThreaded(osg::Node* node, std::vector< IntersectionQuer
unsigned int curSize = curStart + workSize <= queries.size() ? workSize : queries.size() - curStart;
if (curSize > 0)
{
Job job;
job.setArena("oe.intersections");
job.setGroup(&intersections);
job.dispatch_and_forget([node, curStart, curSize, &queries](Cancelable*) {
jobs::context context;
context.pool = pool;
context.group = &intersections;

jobs::dispatch([node, curStart, curSize, &queries](Cancelable&) {
computeIntersections(node, queries, curStart, curSize);
});
return true;
},
context
);
++numJobs;
}
start += workSize;
Expand Down
4 changes: 2 additions & 2 deletions src/applications/osgearth_conv/osgearth_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ struct ProgressReporter : public osgEarth::ProgressCallback
unsigned totalStages,
const std::string& msg )
{
ScopedMutexLock lock(_mutex);
std::lock_guard<std::mutex> lock(_mutex);

if (_first)
{
Expand Down Expand Up @@ -278,7 +278,7 @@ struct ProgressReporter : public osgEarth::ProgressCallback
return false;
}

Threading::Mutex _mutex;
std::mutex _mutex;
bool _first;
osg::Timer_t _start;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,11 @@ main(int argc, char** argv)
if (keys.empty())
return usage(argv[0], "No data in extent");

JobArena arena("Vegetation Export", 1u);

std::cout << "Exporting " << keys.size() << " keys.." << std::endl;

for(const auto key : keys)
{
Job(&arena).dispatch_and_forget([&app, key](Cancelable*)
{
app.exportKey(key);
}
);
jobs::dispatch([&app, key]() { app.exportKey(key); });
}


Expand Down
2 changes: 1 addition & 1 deletion src/applications/osgearth_features/osgearth_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using namespace osgEarth::Util;

int usage( const std::string& app )
{
OE_NOTICE "\n" << app << "\n"
OE_NOTICE << "\n" << app << "\n"
<< " --rasterize : draw features as rasterized image tiles \n"
<< " --drape : draw features as projected texture \n"
<< " --clamp : draw features using shader clamping \n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ using namespace osgEarth;
int
fail(const std::string& msg, char** argv)
{
OE_WARN LC << msg << std::endl;
OE_WARN LC << argv[0]
OE_WARN << LC << msg << std::endl;
OE_WARN << LC << argv[0]
<< "\n --in <filename> ; model to process"
<< "\n --out <filename> ; output texture filename"
<< "\n --size <n> ; dimension of texture"
Expand Down
6 changes: 3 additions & 3 deletions src/osgEarth/AnnotationRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ AnnotationRegistry::instance()
{
// OK to be in the local scope since this gets called at static init time
// by the OSGEARTH_REGISTER_ANNOTATION macro
static AnnotationRegistry* s_singleton =0L;
static Threading::Mutex s_singletonMutex(OE_MUTEX_NAME);
static AnnotationRegistry* s_singleton = nullptr;
static std::mutex s_singletonMutex;

if ( !s_singleton )
{
Threading::ScopedMutexLock lock(s_singletonMutex);
std::lock_guard<std::mutex> lock(s_singletonMutex);
if ( !s_singleton )
{
s_singleton = new AnnotationRegistry();
Expand Down
14 changes: 8 additions & 6 deletions src/osgEarth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,11 @@ SET(LIB_PUBLIC_HEADERS
TrackNode
WindLayer
TerrainLayer
SDF

rtree.h

FileGDBFeatureSource

SDF
weemesh.h
weejobs.h

${OSGEARTH_VERSION_HEADER}
)
Expand Down Expand Up @@ -495,7 +494,6 @@ IF (NOT TINYXML_FOUND)
${LIB_PUBLIC_HEADERS}
tinystr.h
tinyxml.h
weemesh.h
)
ENDIF (NOT TINYXML_FOUND)

Expand Down Expand Up @@ -859,7 +857,7 @@ set(TARGET_SRC
SDF.cpp

FileGDBFeatureSource.cpp

${SHADERS_CPP}
)

Expand Down Expand Up @@ -978,6 +976,10 @@ IF (TRACY_FOUND)
LINK_WITH_VARIABLES(${LIB_NAME} TRACY_LIBRARY)
ENDIF(TRACY_FOUND)

if(UNIX)
target_link_libraries(${LIB_NAME} PUBLIC Threads::Threads)
endif()

OPTION(NRL_STATIC_LIBRARIES "Link osgEarth against static GDAL and cURL, including static OpenSSL, Proj4, JPEG, PNG, and TIFF." OFF)
if(NOT NRL_STATIC_LIBRARIES)
LINK_WITH_VARIABLES(${LIB_NAME} OSG_LIBRARY OSGUTIL_LIBRARY OSGSIM_LIBRARY OSGDB_LIBRARY OSGVIEWER_LIBRARY OSGTEXT_LIBRARY OSGGA_LIBRARY OSGSHADOW_LIBRARY CURL_LIBRARY GDAL_LIBRARY OSGMANIPULATOR_LIBRARY)
Expand Down
10 changes: 4 additions & 6 deletions src/osgEarth/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ CacheSettings::toString() const

//------------------------------------------------------------------------

Cache::Cache( const CacheOptions& options ) :
_options( options ),
_bins("OE.Cache.bins")
Cache::Cache(const CacheOptions& options) :
_options(options)
{
//nop
}
Expand All @@ -140,9 +139,8 @@ Cache::~Cache()
{
}

Cache::Cache( const Cache& rhs, const osg::CopyOp& op ) :
osg::Object( rhs, op ),
_bins("OE.Cache.bins")
Cache::Cache(const Cache& rhs, const osg::CopyOp& op) :
osg::Object(rhs, op)
{
_status = rhs._status;
}
Expand Down
2 changes: 1 addition & 1 deletion src/osgEarth/CacheBin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ namespace
};


Threading::Gate<osg::Image*> WriteExternalReferencesToCache::_imageGate(OE_MUTEX_NAME);
Threading::Gate<osg::Image*> WriteExternalReferencesToCache::_imageGate;
}


Expand Down
4 changes: 2 additions & 2 deletions src/osgEarth/CascadeDrapingDecorator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ CascadeDrapingDecorator::reserveTextureImageUnit()
{
if (_unit < 0)
{
static Threading::Mutex mutex(OE_MUTEX_NAME);
Threading::ScopedMutexLock lock(mutex);
static std::mutex mutex;
std::lock_guard<std::mutex> lock(mutex);

osg::ref_ptr<TerrainResources> tr;
if (_unit < 0 && _resources.lock(tr))
Expand Down
12 changes: 6 additions & 6 deletions src/osgEarth/Chonk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ ChonkDrawable::installRenderBin(ChonkDrawable* d)
static osg::ref_ptr<VirtualProgram> s_vp;

static Mutex s_mutex;
ScopedMutexLock lock(s_mutex);
std::lock_guard<std::mutex> lock(s_mutex);

auto& ss = s_stateSets[d->getRenderBinNumber()];
if (!ss.valid())
Expand Down Expand Up @@ -860,7 +860,7 @@ ChonkDrawable::add(Chonk::Ptr chonk, const osg::Matrixf& xform, const osg::Vec2f
{
if (chonk)
{
ScopedMutexLock lock(_m);
std::lock_guard<std::mutex> lock(_m);

Instance instance;
instance.xform = xform;
Expand Down Expand Up @@ -896,7 +896,7 @@ ChonkDrawable::update_and_cull_batches(osg::State& state) const
// if something changed, we need to refresh the GPU tables.
if (globjects._dirty)
{
ScopedMutexLock lock(_m);
std::lock_guard<std::mutex> lock(_m);
globjects._gpucull = _gpucull;
globjects.update(_batches, this, _fadeNear, _fadeFar, _birthday, _alphaCutoff, state);
}
Expand All @@ -918,7 +918,7 @@ ChonkDrawable::draw_batches(osg::State& state) const
osg::BoundingBox
ChonkDrawable::computeBoundingBox() const
{
ScopedMutexLock lock(_m);
std::lock_guard<std::mutex> lock(_m);

osg::BoundingBox result;

Expand Down Expand Up @@ -974,7 +974,7 @@ ChonkDrawable::refreshProxy() const
{
if (_proxy_dirty)
{
ScopedMutexLock lock(_m);
std::lock_guard<std::mutex> lock(_m);

_proxy_verts.clear();
_proxy_indices.clear();
Expand Down Expand Up @@ -1354,7 +1354,7 @@ ChonkRenderBin::ChonkRenderBin(const ChonkRenderBin& rhs, const osg::CopyOp& op)
if (!_cullSS.valid())
{
static Mutex m;
ScopedMutexLock lock(m);
std::lock_guard<std::mutex> lock(m);

auto proto = static_cast<ChonkRenderBin*>(getRenderBinPrototype("ChonkBin"));
if (!proto->_cullSS.valid())
Expand Down
3 changes: 1 addition & 2 deletions src/osgEarth/Clamping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ ClampingCullSet::accept(osg::NodeVisitor& nv)
}
}

ClampingManager::ClampingManager() :
_sets(OE_MUTEX_NAME)
ClampingManager::ClampingManager()
{
//nop
}
Expand Down
6 changes: 3 additions & 3 deletions src/osgEarth/ColorFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ ColorFilterRegistry::instance()
{
// OK to be in the local scope since this gets called at static init time
// by the OSGEARTH_REGISTER_COLORFILTER macro
static ColorFilterRegistry* s_singleton =0L;
static Threading::Mutex s_singletonMutex(OE_MUTEX_NAME);
static ColorFilterRegistry* s_singleton = nullptr;
static std::mutex s_singletonMutex;

if ( !s_singleton )
{
Threading::ScopedMutexLock lock(s_singletonMutex);
std::lock_guard<std::mutex> lock(s_singletonMutex);
if ( !s_singleton )
{
s_singleton = new ColorFilterRegistry();
Expand Down
1 change: 1 addition & 0 deletions src/osgEarth/Common
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define OSGEARTH_COMMON_H 1

#include <osgEarth/Export>
#include <osgEarth/Notify>
#include <osg/ref_ptr>
#include <osg/Referenced>
#include <memory>
Expand Down
Loading
Loading