/[escript]/trunk/escript/src/Utils.cpp
ViewVC logotype

Contents of /trunk/escript/src/Utils.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1568 - (show annotations)
Sat May 24 03:15:08 2008 UTC (10 years, 10 months ago) by ksteube
File size: 1506 byte(s)
Some testing on ac.apac.edu.au, more work needed
New pyvisi example offscreen.py for offscreen rendering

1
2 /* $Id$ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 #include "Utils.h"
17 #include "DataVector.h"
18
19 #ifdef _OPENMP
20 #include <omp.h>
21 #endif
22
23 #ifdef PASO_MPI
24 #include <mpi.h>
25 #endif
26
27 namespace escript {
28
29 int getSvnVersion()
30 {
31 #ifdef SVN_VERSION
32 return SVN_VERSION;
33 #else
34 return 0;
35 #endif
36 }
37
38 void printParallelThreadCnt()
39 {
40 int mpi_iam=0, mpi_num=1;
41 char hname[64];
42
43 gethostname(hname, 64);
44
45 #ifdef PASO_MPI
46 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_iam);
47 MPI_Comm_size(MPI_COMM_WORLD, &mpi_num);
48 #endif
49
50 #ifdef _OPENMP
51 #pragma omp parallel
52 #endif
53 {
54 int omp_iam=0, omp_num=1;
55 #ifdef _OPENMP
56 omp_iam = omp_get_thread_num(); /* Call in a parallel region */
57 omp_num = omp_get_num_threads();
58 #endif
59 printf("printParallelThreadCounts: MPI=%d/%d OpenMP=%d/%d running on %s\n", mpi_iam, mpi_num, omp_iam, omp_num, hname);
60 }
61 }
62
63 void setNumberOfThreads(const int num_threads)
64 {
65
66 #ifdef _OPENMP
67 omp_set_num_threads(num_threads);
68 #endif
69
70 }
71
72 int getNumberOfThreads()
73 {
74 #ifdef _OPENMP
75 return omp_get_max_threads();
76 #else
77 return 1;
78 #endif
79
80 }
81
82 } // end of namespace

  ViewVC Help
Powered by ViewVC 1.1.26