VulkanRaytracingCycles 0.0.0
Cycles Render Engine With VulkanRaytracingShaderModules. ( Experiment , in progress)
NativeParallelForTask< Index, Body > Class Template Reference

For internal use by template function NativeParallelFor. More...

#include <harness_defs.h>

Public Member Functions

 NativeParallelForTask (Index index_, const Body &body_)
 
void start ()
 Start task. More...
 
void wait_to_finish ()
 Wait for task to finish. More...
 

Detailed Description

template<typename Index, typename Body>
class NativeParallelForTask< Index, Body >

For internal use by template function NativeParallelFor.

Definition at line 519 of file harness_defs.h.

Inheritance diagram for NativeParallelForTask< Index, Body >:
NoCopy

Constructor & Destructor Documentation

◆ NativeParallelForTask()

template<typename Index , typename Body >
NativeParallelForTask< Index, Body >::NativeParallelForTask ( Index  index_,
const Body &  body_ 
)
inline

Definition at line 521 of file harness_defs.h.

521 :
522 index(index_),
523 body(body_)
524 {}

Member Function Documentation

◆ start()

template<typename Index , typename Body >
void NativeParallelForTask< Index, Body >::start ( )
inline

Start task.

Definition at line 527 of file harness_defs.h.

527 {
528#if _WIN32||_WIN64
529 unsigned thread_id;
530#if __TBB_WIN8UI_SUPPORT
531 std::thread* thread_tmp = new std::thread(thread_function, this);
532 thread_handle = thread_tmp->native_handle();
533 thread_id = 0;
534#else
535 unsigned stack_size = 0;
536#if HARNESS_THREAD_STACK_SIZE
537 stack_size = HARNESS_THREAD_STACK_SIZE;
538#endif
539 thread_handle = (HANDLE)_beginthreadex(NULL, stack_size, thread_function, this, 0, &thread_id);
540#endif
541 ASSERT(thread_handle != 0, "NativeParallelFor: _beginthreadex failed");
542#else
543#if __ICC==1100
544#pragma warning (push)
545#pragma warning (disable: 2193)
546#endif /* __ICC==1100 */
547 // Some machines may have very large hard stack limit. When the test is
548 // launched by make, the default stack size is set to the hard limit, and
549 // calls to pthread_create fail with out-of-memory error.
550 // Therefore we set the stack size explicitly (as for TBB worker threads).
551#if !defined(HARNESS_THREAD_STACK_SIZE)
552#if __i386__||__i386||__arm__
553 const size_t stack_size = 1 * MByte;
554#elif __x86_64__
555 const size_t stack_size = 2 * MByte;
556#else
557 const size_t stack_size = 4 * MByte;
558#endif
559#else
560 const size_t stack_size = HARNESS_THREAD_STACK_SIZE;
561#endif /* HARNESS_THREAD_STACK_SIZE */
562 pthread_attr_t attr_stack;
563 int status = pthread_attr_init(&attr_stack);
564 ASSERT(0 == status, "NativeParallelFor: pthread_attr_init failed");
565 status = pthread_attr_setstacksize(&attr_stack, stack_size);
566 ASSERT(0 == status, "NativeParallelFor: pthread_attr_setstacksize failed");
567 status = pthread_create(&thread_id, &attr_stack, thread_function, this);
568 ASSERT(0 == status, "NativeParallelFor: pthread_create failed");
569 pthread_attr_destroy(&attr_stack);
570#if __ICC==1100
571#pragma warning (pop)
572#endif
573#endif /* _WIN32||_WIN64 */
574 }
#define ASSERT(p, message)
Definition: harness_defs.h:225
const unsigned MByte
Definition: harness_defs.h:420

◆ wait_to_finish()

template<typename Index , typename Body >
void NativeParallelForTask< Index, Body >::wait_to_finish ( )
inline

Wait for task to finish.

Definition at line 577 of file harness_defs.h.

577 {
578#if _WIN32||_WIN64
579 DWORD status = WaitForSingleObjectEx(thread_handle, INFINITE, FALSE);
580 ASSERT(status != WAIT_FAILED, "WaitForSingleObject failed");
581 CloseHandle(thread_handle);
582#else
583 int status = pthread_join(thread_id, NULL);
584 ASSERT(!status, "pthread_join failed");
585#endif
586#if HARNESS_NO_ASSERT
587 (void)status;
588#endif
589 }

The documentation for this class was generated from the following file: