Skip to content

Instantly share code, notes, and snippets.

@rahul8590
Created July 13, 2013 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahul8590/5991529 to your computer and use it in GitHub Desktop.
Save rahul8590/5991529 to your computer and use it in GitHub Desktop.
OpenMp program. To compile this in C++ $ g++ table.cpp -fopenmp -o table #this assumes openmp is installed in your system. $ export OMP_NUM_THREADS=4 #set the number of threads needed for you.
#include<iostream>
#include <cmath>
int main()
{
const int size = 256;
double sinTable[size];
#pragma omp parallel
{
printf("hello\n");
}
#pragma omp parallel for
for(int n=0; n<size; ++n)
sinTable[n] = std::sin(2 * M_PI * n / size);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment