DGtal  0.9.3
Functions
testOpenMP.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
Include dependency graph for testOpenMP.cpp:

Go to the source code of this file.

Functions

bool testOpenMP ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2012/10/26

Functions for testing class OpenMP.

This file is part of the DGtal library.

Definition in file testOpenMP.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 72 of file testOpenMP.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testOpenMP(), and DGtal::trace.

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 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
bool testOpenMP()
Definition: testOpenMP.cpp:45
std::ostream & emphase()
std::ostream & info()

◆ testOpenMP()

bool testOpenMP ( )

Example of a test. To be completed.

Definition at line 45 of file testOpenMP.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

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 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
std::ostream & info()