taskschedulerppl.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // ======================================================================== //
  2. // Copyright 2009-2017 Intel Corporation //
  3. // //
  4. // Licensed under the Apache License, Version 2.0 (the "License"); //
  5. // you may not use this file except in compliance with the License. //
  6. // You may obtain a copy of the License at //
  7. // //
  8. // http://www.apache.org/licenses/LICENSE-2.0 //
  9. // //
  10. // Unless required by applicable law or agreed to in writing, software //
  11. // distributed under the License is distributed on an "AS IS" BASIS, //
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
  13. // See the License for the specific language governing permissions and //
  14. // limitations under the License. //
  15. // ======================================================================== //
  16. #pragma once
  17. #include "../sys/platform.h"
  18. #include "../sys/alloc.h"
  19. #include "../sys/barrier.h"
  20. #include "../sys/thread.h"
  21. #include "../sys/mutex.h"
  22. #include "../sys/condition.h"
  23. #include "../sys/ref.h"
  24. #if !defined(__WIN32__)
  25. #error PPL tasking system only available under windows
  26. #endif
  27. #include <ppl.h>
  28. namespace embree
  29. {
  30. struct TaskScheduler
  31. {
  32. /*! initializes the task scheduler */
  33. static void create(size_t numThreads, bool set_affinity, bool start_threads);
  34. /*! destroys the task scheduler again */
  35. static void destroy();
  36. /* returns the index of the current thread */
  37. static __forceinline size_t threadIndex() {
  38. return GetCurrentThreadId();
  39. }
  40. /* returns the total number of threads */
  41. static __forceinline size_t threadCount() {
  42. return GetMaximumProcessorCount(ALL_PROCESSOR_GROUPS);
  43. }
  44. };
  45. };