int main(void)
{
//  parallel_invoke(functor(1), functor(2));
//  std::cout << "\n";
//  parallel_invoke(functor(1), functor(2), functor(3));
//  std::cout << "\n";
//  parallel_invoke(functor(1), functor(2), functor(3), functor(4));
//  std::cout << "\n";
  parallel_invoke(functor(1), functor(2), functor(3), functor(4), functor(5));
  std::cout << "\n";

  return 0;
}
void parallel_bitonic_sort(T* items, int lo, int n, bool dir)
{   
   if (n > 1)
   {
      // Divide the array into two partitions and then sort 
      // the partitions in different directions.
      int m = n / 2;

      parallel_invoke(
         [&] { parallel_bitonic_sort(items, lo, m, INCREASING); },
         [&] { parallel_bitonic_sort(items, lo + m, m, DECREASING); }
      );
      
      // Merge the results.
      parallel_bitonic_merge(items, lo, n, dir);
   }
}
Exemple #3
0
    void RenderView(const CView& view)
    {
        // TODO do animations
        m_renderQueue.clear();
        auto renderQueueInserter = std::back_inserter(m_renderQueue);

        std::vector<PLight> lightsInfo;
        const auto camera = view.Camera();
        
        parallel_invoke(
            [&](){ if (camera) PGScene->RenderQueueStatics(renderQueueInserter, *camera); },
            [&](){ if (camera) PGScene->RenderQueueDynamics(renderQueueInserter, *camera); },
            [&](){ if (camera) PGScene->RenderQueueSkybox(renderQueueInserter, *camera); },
            [&](){ if (camera) PGScene->RenderQueueTerrain(renderQueueInserter, *camera); },
            [&](){ view.RenderQueueUi(renderQueueInserter); },
            // Copy lighting info.
            [&](){
                 // FIXME This is so wrong
                for (auto light : PGScene->Lights()) {
                    PLight info;
                    info.position = view.Camera()->View() * light->Position();
                    info.direction = light->Facing();
                    info.ambient = light->Ambient();
                    info.diffuse = light->Diffuse();
                    info.specular = light->Specular();
                    info.intensity = light->Intensity();
                    info.spotCutoff = light->SpotCosCutoff();
                    info.spotExponent = light->SpotExponent();
                    info.lightType = static_cast<LightType>(light->LightType());
                    lightsInfo.emplace_back(std::move(info));
                }
            }
        );

        // Sort by render state.
        std::sort(std::begin(m_renderQueue), std::end(m_renderQueue));

        // TODO here multiple passes for deferred rendering.
        // Draw scene.
        m_device->BeginScene();
        RenderQueue(*camera, lightsInfo);
        m_device->EndScene();
    }
  void operator()(void) const
  {
    std::cout << x << std::endl;

    parallel_invoke(spin(), spin(), spin());
  }