Changes between Initial Version and Version 1 of cypress/Programming/CppExamples/OpenMpCpp


Ignore:
Timestamp:
05/15/15 09:50:32 (10 years ago)
Author:
cmaggio
Comment:

migrated content from ccs wiki

Legend:

Unmodified
Added
Removed
Modified
  • cypress/Programming/CppExamples/OpenMpCpp

    v1 v1  
     1= OpenMP C++ =
     2== Hello World ==
     3{{{#!cpp
     4//
     5//  hellp_omp.cpp: display a message on the screen
     6//
     7#include <iostream>
     8#include <omp.h>
     9 
     10int main () {
     11  int id;
     12  std::cout << "C++ Start" << std::endl;
     13#pragma omp parallel private(id)
     14  {
     15    id = omp_get_thread_num();
     16    std::cout <<  "hello from " << id << std::endl;
     17#pragma omp barrier
     18    if ( id == 0 ) {
     19      int nthreads = omp_get_num_threads();
     20      std::cout <<  nthreads << " threads said hello!" << std::endl;
     21    }
     22  }
     23  std::cout << "End" << std::endl;
     24}
     25}}}
     26== Compile with GNU C++ ==
     27{{{g++ hello_omp.c -fopemp}}}
     28== Compile with PGI C++ ==
     29{{{pgcpp hello_omp.c -mp}}}
     30== Compile with Intel C++ ==
     31i{{{cpc hello_omp.c -openmp}}}
     32== Example of Jobscript ==
     33See