Changes

Jump to: navigation, search

GPU621/NoName

118 bytes added, 01:48, 3 December 2016
Creating and executing Threads
OpenMp automatically decides what order threads will execute. C++ 11 Threads require the developer to specify in what order threads will execute. This is typically done within a for loop block. Threads are created by initializing the std::thread class and specifying a function or any other callable object within the constructor.
Native Threads After the initial creationand execution of a thread, the main thread must either detach or join the thread. The C++ 11 standard library offers these two member functions for attaching or detaching threads. * std::thread::join - allows the thread to execute in the background independently from the main thread. The thread will continue execution without blocking nor synchronizing in any way and terminate without relying on the main thread.* std::thread::detach - waits for the thread to finish execution. Once a thread is created another thread can wait for the thread to finish. Example of native thread creating and synchronization using C++ 11
int numThreads = std::thread::hardware_concurrency();
}
After the initial creation and execution of a thread, the main thread must either detach or join the thread for (int i = 0; i < threads. The Csize(); i++ 11 standard library offers these two member functions for attaching or detaching ){ threads. * std::thread::at(i).join - allows the thread to execute in the background independently from the main thread. The thread will continue execution without blocking nor synchronizing in any way and terminate without relying on the main thread.();* std::thread::detach - waits for the thread to finish execution. Once a thread is created another thread can wait for the thread to finish. }
===Parallelizing for Loops===

Navigation menu