Ejemplo n.º 1
0
int
main (int argc, char **argv)
{
  if (argc != 2){
      printf ("Usage: openmp_example_3 <num threads> \n");
      exit (0);
    }
  
  int thread_count = atoi (argv[1]);	// Obtain the number of threads to be created as a command variable argument


  /* Start of parallel region. The SECTIONS directive is a non-iterative work-sharing construct, specifying that the enclosed 
   * section(s) of code are to be divided among the threads in the team. Independent SECTION directives are nested within a SECTIONS 
   * directive and each SECTION is executed once by a thread in the team. Different sections may be executed by different threads. 
   * It is possible for a thead to execute more than one section if it is quick enough and the implementation permits such. */
#pragma omp parallel num_threads(thread_count)
  {
#pragma omp sections
    {
#pragma omp section
      function_a ();

#pragma omp section
      function_b ();

#pragma omp section
      function_c();
    }
  } /* End of parallel region. */               
  return 0;
}
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: CCJY/coliru
int main() {
    function_a();
    function_b();
}