Skip to content

Commit 35da461

Browse files
committed
schedule inner our outer parallelism based on number of poses that needs to be simulated
1 parent 234de18 commit 35da461

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/rmagine_embree/include/rmagine/simulation/O1DnSimulatorEmbree.tcc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "O1DnSimulatorEmbree.hpp"
22
#include <rmagine/simulation/SimulationResults.hpp>
33
#include <limits>
4+
#include <omp.h>
45

56
#include "embree_common.h"
67

@@ -52,7 +53,7 @@ void O1DnSimulatorEmbree::simulate(
5253
const float range_min = m_model->range.min;
5354
const float range_max = m_model->range.max;
5455

55-
#pragma omp parallel for
56+
#pragma omp parallel for if(Tbm.size() >= omp_get_max_threads())
5657
for(size_t pid = 0; pid < Tbm.size(); pid++)
5758
{
5859
const Transform Tbm_ = Tbm[pid];
@@ -63,6 +64,7 @@ void O1DnSimulatorEmbree::simulate(
6364

6465
const unsigned int glob_shift = pid * m_model->size();
6566

67+
#pragma omp parallel for if(Tbm.size() < omp_get_max_threads())
6668
for(unsigned int vid = 0; vid < m_model->getHeight(); vid++)
6769
{
6870
for(unsigned int hid = 0; hid < m_model->getWidth(); hid++)

src/rmagine_embree/include/rmagine/simulation/OnDnSimulatorEmbree.tcc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "OnDnSimulatorEmbree.hpp"
22
#include <rmagine/simulation/SimulationResults.hpp>
33
#include <limits>
4+
#include <omp.h>
45

56
#include "embree_common.h"
67

@@ -53,7 +54,7 @@ void OnDnSimulatorEmbree::simulate(
5354
const float range_min = m_model->range.min;
5455
const float range_max = m_model->range.max;
5556

56-
#pragma omp parallel for
57+
#pragma omp parallel for if(Tbm.size() >= omp_get_max_threads())
5758
for(size_t pid = 0; pid < Tbm.size(); pid++)
5859
{
5960
const Transform Tbm_ = Tbm[pid];
@@ -64,6 +65,7 @@ void OnDnSimulatorEmbree::simulate(
6465

6566
const unsigned int glob_shift = pid * m_model->size();
6667

68+
#pragma omp parallel for if(Tbm.size() < omp_get_max_threads())
6769
for(unsigned int vid = 0; vid < m_model->getHeight(); vid++)
6870
{
6971
for(unsigned int hid = 0; hid < m_model->getWidth(); hid++)

src/rmagine_embree/include/rmagine/simulation/PinholeSimulatorEmbree.tcc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "PinholeSimulatorEmbree.hpp"
22
#include <rmagine/simulation/SimulationResults.hpp>
33
#include <limits>
4+
#include <omp.h>
45

56
#include "embree_common.h"
67

@@ -53,7 +54,7 @@ void PinholeSimulatorEmbree::simulate(
5354
const float range_min = m_model->range.min;
5455
const float range_max = m_model->range.max;
5556

56-
#pragma omp parallel for
57+
#pragma omp parallel for if(Tbm.size() >= omp_get_max_threads())
5758
for(size_t pid = 0; pid < Tbm.size(); pid++)
5859
{
5960
const Transform Tbm_ = Tbm[pid];
@@ -64,6 +65,7 @@ void PinholeSimulatorEmbree::simulate(
6465

6566
const unsigned int glob_shift = pid * m_model->size();
6667

68+
#pragma omp parallel for if(Tbm.size() < omp_get_max_threads())
6769
for(unsigned int vid = 0; vid < m_model->getHeight(); vid++)
6870
{
6971
for(unsigned int hid = 0; hid < m_model->getWidth(); hid++)

src/rmagine_embree/include/rmagine/simulation/SphereSimulatorEmbree.tcc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "SphereSimulatorEmbree.hpp"
22
#include <rmagine/simulation/SimulationResults.hpp>
33
#include <limits>
4+
#include <omp.h>
45

56
#include "embree_common.h"
67

@@ -54,7 +55,7 @@ void SphereSimulatorEmbree::simulate(
5455
const float range_max = m_model->range.max;
5556

5657

57-
// #pragma omp parallel for
58+
#pragma omp parallel for if(Tbm.size() >= omp_get_max_threads())
5859
for(size_t pid = 0; pid < Tbm.size(); pid++)
5960
{
6061
const Transform Tbm_ = Tbm[pid];
@@ -65,6 +66,7 @@ void SphereSimulatorEmbree::simulate(
6566

6667
const unsigned int glob_shift = pid * m_model->size();
6768

69+
#pragma omp parallel for if(Tbm.size() < omp_get_max_threads())
6870
for(unsigned int vid = 0; vid < m_model->getHeight(); vid++)
6971
{
7072
for(unsigned int hid = 0; hid < m_model->getWidth(); hid++)

0 commit comments

Comments
 (0)