Skip to content

Instantly share code, notes, and snippets.

@sat0b
Created June 11, 2017 01:01
Show Gist options
  • Select an option

  • Save sat0b/57ce05d85b114b9dabb1fc0feea9f900 to your computer and use it in GitHub Desktop.

Select an option

Save sat0b/57ce05d85b114b9dabb1fc0feea9f900 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <omp.h>
#include <thread>
using namespace std;
void sleep(int num) {
std::this_thread::sleep_for(std::chrono::seconds(3));
}
int main() {
#ifdef _OPENMP
#pragma omp parallel for
for (int i = 0; i < 10; ++i) {
printf("%d\n", i);
sleep(i);
}
#else
cout << "OpenMP is not used" << endl;
#endif
return 0;
}
@sat0b

sat0b commented Jun 11, 2017

Copy link
Copy Markdown
Author

clang-omp++ test_openmp.cpp -o test_openmp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment