DGtal  0.9.3
testOpenMP.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
34 
35 using namespace std;
36 using namespace DGtal;
37 
39 // Functions for testing class OpenMP.
41 
45 bool testOpenMP()
46 {
47  unsigned int nbok = 0;
48  unsigned int nb = 0;
49 
50  trace.beginBlock ( "Testing basic OpenMP ..." );
51 
52 #ifdef WITH_OPENMP
53  trace.info() << "Parallel helloworld"<<std::endl;
54 #pragma omp parallel
55  trace.info()<<"Hello, world.\n";
56 #else
57  trace.info() << "no parallel helloworld"<<std::endl;
58 #endif
59 
60  nbok += true ? 1 : 0;
61  nb++;
62  trace.info() << "(" << nbok << "/" << nb << ") "
63  << "true == true" << std::endl;
64  trace.endBlock();
65 
66  return nbok == nb;
67 }
68 
70 // Standard services - public :
71 
72 int main( int argc, char** argv )
73 {
74  trace.beginBlock ( "Testing class OpenMP" );
75  trace.info() << "Args:";
76  for ( int i = 0; i < argc; ++i )
77  trace.info() << " " << argv[ i ];
78  trace.info() << endl;
79 
80  bool res = testOpenMP(); // && ... other tests
81  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
82  trace.endBlock();
83  return res ? 0 : 1;
84 }
85 // //
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
STL namespace.
double endBlock()
bool testOpenMP()
Definition: testOpenMP.cpp:45
std::ostream & emphase()
int main(int argc, char **argv)
Definition: testOpenMP.cpp:72
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & info()