Marked deprecated Osd::*Evaluator::SetNumThreads()

The existing implementation in Osd::TbbEvaluator has never been implemented
correctly and that implementation is incompatible with the oneTBB API.

These methods are now marked deprecated in the two places where defined
in Osd::TbbEvaluator and Osd::OmpEvaluator, but for consistency we preserve
the existing implementation when building with older versions of tbb.

We've already removed all use of these methods from the tests and examples.
This commit is contained in:
David G Yu 2023-08-25 09:33:35 -07:00
parent 6c1a309cfc
commit 67aa6e4c88
4 changed files with 13 additions and 2 deletions

View File

@ -361,6 +361,8 @@ OmpEvaluator::Synchronize(void * /*deviceContext*/) {
/* static */ /* static */
void void
OmpEvaluator::SetNumThreads(int numThreads) { OmpEvaluator::SetNumThreads(int numThreads) {
// This is deprecated functionality. We preserve the existing behavior
// for consistency.
omp_set_num_threads(numThreads); omp_set_num_threads(numThreads);
} }

View File

@ -1225,6 +1225,7 @@ public:
static void Synchronize(void *deviceContext = NULL); static void Synchronize(void *deviceContext = NULL);
/// \brief Deprecated. Client code should initialize OpenMP.
static void SetNumThreads(int numThreads); static void SetNumThreads(int numThreads);
}; };

View File

@ -25,7 +25,12 @@
#include "../osd/tbbEvaluator.h" #include "../osd/tbbEvaluator.h"
#include "../osd/tbbKernel.h" #include "../osd/tbbKernel.h"
// Get TBB version from tbb/parallel_for used by osd/tbbKernel
#include <tbb/parallel_for.h>
#if defined(TBB_INTERFACE_VERSION_MAJOR) && (TBB_INTERFACE_VERSION_MAJOR < 12)
// This is deprecated functionality.
#include <tbb/task_scheduler_init.h> #include <tbb/task_scheduler_init.h>
#endif
namespace OpenSubdiv { namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION { namespace OPENSUBDIV_VERSION {
@ -215,11 +220,15 @@ TbbEvaluator::Synchronize(void *) {
/* static */ /* static */
void void
TbbEvaluator::SetNumThreads(int numThreads) { TbbEvaluator::SetNumThreads(int numThreads) {
#if defined(TBB_INTERFACE_VERSION_MAJOR) && (TBB_INTERFACE_VERSION_MAJOR < 12)
// This is deprecated functionality. We preserve the existing behavior
// for consistency (when using older versions of tbb).
if (numThreads == -1) { if (numThreads == -1) {
tbb::task_scheduler_init init; tbb::task_scheduler_init init;
} else { } else {
tbb::task_scheduler_init init(numThreads); tbb::task_scheduler_init init(numThreads);
} }
#endif
} }
} // end namespace Osd } // end namespace Osd

View File

@ -1226,8 +1226,7 @@ public:
/// \brief synchronize all asynchronous computation invoked on this device. /// \brief synchronize all asynchronous computation invoked on this device.
static void Synchronize(void *deviceContext = NULL); static void Synchronize(void *deviceContext = NULL);
/// \brief initialize tbb task schedular /// \brief Deprecated. Client code should initialize TBB.
/// (optional: client may use tbb::task_scheduler_init)
/// ///
/// @param numThreads how many threads /// @param numThreads how many threads
/// ///