Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
6004CEM_Week_3_Lab_Tasks/guided_scheduling.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
37 lines (33 sloc)
1.03 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "omp.h" | |
#include <iostream> | |
#include <cmath> | |
#include <cstdlib> | |
#include <unistd.h> | |
#include <chrono> | |
#include <thread> | |
#include <time.h> | |
#define THREADS 4 | |
#define N 16 | |
/** | |
* This scheduling policy is similar to a dynamic schedule, except that | |
* the chunk size changes as the program runs. It begins with big chunks, | |
* but then adjusts to smaller chunk sizes if the workload is imbalanced. | |
*/ | |
/** | |
* @brief A function that showcases how threads and guided scheduling work | |
* @note Makes use of OpenMP | |
*/ | |
int main ( ) | |
{ | |
int i; | |
/** | |
* @TODO: Make a loop that prints the iteration and the thread that executed it. | |
* @note Use one directive that combines 'schedule' and 'num_threads'. | |
* ! Make sure that you use guided scheduling! | |
* Here is an example print statement: | |
* std::cout<<"Thread"<<" "<<omp_get_thread_num()<<" "<<"has completed iteration"<<" "<<i<<std::endl; | |
*/ | |
/* all threads done */ | |
std::cout<<"All threads done"<<std::endl; | |
return 0; | |
} |