Skip to content

Commit

Permalink
add global_controll for tbbto control thread
Browse files Browse the repository at this point in the history
  • Loading branch information
joytsay committed Feb 12, 2020
1 parent c8cc02b commit 1235778
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions 11/src/nullImpl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ file(GLOB face_detection_sources
${CMAKE_CURRENT_SOURCE_DIR}/../../../common/src/include/cpp/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../../common/src/include/dlib/*.h
${CMAKE_CURRENT_SOURCE_DIR}/../../../common/src/include/dlib/*.cpp
#${CMAKE_CURRENT_SOURCE_DIR}/../../../common/src/include/tbb/*.h
#${CMAKE_CURRENT_SOURCE_DIR}/../../../common/src/include/tbb/*.cpp
#${CMAKE_CURRENT_SOURCE_DIR}/../../../common/src/include/dlib/image_processing/*.h
#${CMAKE_CURRENT_SOURCE_DIR}/../../../common/src/include/dlib/image_processing/*.cpp
#${CMAKE_CURRENT_SOURCE_DIR}/../../../common/src/include/dlib/image_transforms/*.h
Expand Down
9 changes: 6 additions & 3 deletions 11/src/nullImpl/GVimplfrvt11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ ReturnStatus
NullImplFRVT11::initialize(const std::string &configDir)
{
try {
tbb::global_control(tbb::global_control::max_allowed_parallelism, 1);
// imgCount = 0;
// detectFailCount = 0;
//tbbControl = new tbb::global_control(tbb::global_control::max_allowed_parallelism, 1);
m_JitterCount = FR_JITTER_COUNT;
if(!input_image){
input_image = new unsigned char [FR_IMAGE_HEIGHT * FR_IMAGE_HEIGHT *3];
Expand Down Expand Up @@ -83,10 +85,10 @@ NullImplFRVT11::initialize(const std::string &configDir)
// slog::info << "Loading device " << deviceName << slog::endl;
// std::cout << ie.GetVersions(deviceName) << std::endl;
ie.AddExtension(std::make_shared<InferenceEngine::Extensions::Cpu::CpuExtensions>(), deviceName);
ie.SetConfig({{ CONFIG_KEY(CPU_THREADS_NUM), "1" }}, deviceName);
ie.SetConfig({{ CONFIG_KEY(CPU_BIND_THREAD), CONFIG_VALUE(YES) }}, deviceName);
//ie.SetConfig({{ CONFIG_KEY(CPU_THREADS_NUM), "1" }}, deviceName); //-nthreads
//ie.SetConfig({{ CONFIG_KEY(CPU_BIND_THREAD), CONFIG_VALUE(YES) }}, deviceName);
// for CPU execution, more throughput-oriented execution via streams
ie.SetConfig({{ CONFIG_KEY(CPU_THROUGHPUT_STREAMS), "1"}}, deviceName);
//ie.SetConfig({{ CONFIG_KEY(CPU_THROUGHPUT_STREAMS), "1"}}, deviceName); //-nstreams

bFaceDetectorIsLoaded = false;
bFaceLandmarkIsLoaded = false;
Expand Down Expand Up @@ -147,6 +149,7 @@ NullImplFRVT11::createTemplate(
{
try { //---------------------------- Implement intel inference engine -------------------------------------
// clock_t begin = clock();
tbb::global_control(tbb::global_control::max_allowed_parallelism, 1);
if(!bFaceDetectorIsLoaded){
Load(*faceDetector).into(ie, deviceName, false);
bFaceDetectorIsLoaded = true;
Expand Down
5 changes: 4 additions & 1 deletion 11/src/nullImpl/GVimplfrvt11.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
#include "detectors.hpp"
#include "face.hpp"
#include "visualizer.hpp"

#include <ie_iextension.h>
#include <ext_list.hpp>
#define TBB_PREVIEW_GLOBAL_CONTROL 1
#include <tbb/global_control.h>

#include <dlib/image_processing/render_face_detections.h>
#include <dlib/image_processing.h>
Expand All @@ -58,6 +59,7 @@
#define FR_EMBEDDING_SIZE 512
#define FR_JITTER_COUNT 10


int detectFailCount = 0;
int imgCount = 0;
std::mutex mtx;
Expand Down Expand Up @@ -99,6 +101,7 @@ namespace FRVT_11 {
//unsigned char* input_image = NULL;
// std::string input_name;
// std::string output_name;
//tbb::global_control *tbbControl = NULL;
std::string deviceName;
FaceDetection *faceDetector = NULL;
FacialLandmarksDetection *facialLandmarksDetector = NULL;
Expand Down

0 comments on commit 1235778

Please sign in to comment.