taskschedulerppl.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2009-2021 Intel Corporation
  2. // SPDX-License-Identifier: Apache-2.0
  3. #pragma once
  4. #include "../sys/platform.h"
  5. #include "../sys/alloc.h"
  6. #include "../sys/barrier.h"
  7. #include "../sys/thread.h"
  8. #include "../sys/mutex.h"
  9. #include "../sys/condition.h"
  10. #include "../sys/ref.h"
  11. #if !defined(__WIN32__)
  12. #error PPL tasking system only available under windows
  13. #endif
  14. #include <ppl.h>
  15. namespace embree
  16. {
  17. struct TaskScheduler
  18. {
  19. /*! initializes the task scheduler */
  20. static void create(size_t numThreads, bool set_affinity, bool start_threads);
  21. /*! destroys the task scheduler again */
  22. static void destroy();
  23. /* returns the ID of the current thread */
  24. static __forceinline size_t threadID() {
  25. return GetCurrentThreadId();
  26. }
  27. /* returns the index (0..threadCount-1) of the current thread */
  28. /* FIXME: threadIndex is NOT supported by PPL! */
  29. static __forceinline size_t threadIndex() {
  30. return 0;
  31. }
  32. /* returns the total number of threads */
  33. static __forceinline size_t threadCount() {
  34. return GetMaximumProcessorCount(ALL_PROCESSOR_GROUPS) + 1;
  35. }
  36. };
  37. };