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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1567 - (hide annotations)
Thu May 22 22:52:41 2008 UTC (11 years, 4 months ago) by ksteube
File size: 1528 byte(s)
scons all_tests passes on Savanna with OMP=1 and OMP=4.
New boost for Savanna.
A few more cases of #s -> %s.

1 gross 391
2 ksteube 1312 /* $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 jgs 474 #include "Utils.h"
17 gross 797 #include "DataVector.h"
18 gross 391
19 jgs 478 #ifdef _OPENMP
20     #include <omp.h>
21     #endif
22    
23 ksteube 1561 #ifdef PASO_MPI
24     #include <mpi.h>
25     #endif
26    
27 gross 391 namespace escript {
28    
29 ksteube 1247 int getSvnVersion()
30     {
31     #ifdef SVN_VERSION
32     return SVN_VERSION;
33     #else
34     return 0;
35     #endif
36     }
37    
38 ksteube 1561 void printParallelThreadCnt()
39     {
40     int mpi_iam=0, mpi_num=1;
41 ksteube 1567 char hname[HOST_NAME_MAX];
42 ksteube 1561
43 ksteube 1567 gethostname(hname, HOST_NAME_MAX);
44    
45 ksteube 1561 #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 ksteube 1567 printf("printParallelThreadCounts: OpenMP=%d/%d MPI=%d/%d running on %s\n", omp_iam, omp_num, mpi_iam, mpi_num, hname);
60 ksteube 1561 }
61     }
62    
63 gross 391 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