/[escript]/branches/windows_from_1456_trunk_1574_merged_in/escript/src/Utils.cpp
ViewVC logotype

Contents of /branches/windows_from_1456_trunk_1574_merged_in/escript/src/Utils.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1580 - (show annotations)
Tue Jun 3 14:03:40 2008 UTC (12 years, 7 months ago) by phornby
File size: 1551 byte(s)
This once again compiles and links under windows after merging to trunk version 1574. scons run_tests also passes now. py_tests still fails in the same way.  Had to link against winsock2 to get gethostname(), and had to re-do some work on eliminating unused vars. Also eliminated signed/unsigned comparisons where I saw them.
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 #ifdef _WIN32
28 #include <WinSock2.h>
29 #endif
30
31 namespace escript {
32
33 int getSvnVersion()
34 {
35 #ifdef SVN_VERSION
36 return SVN_VERSION;
37 #else
38 return 0;
39 #endif
40 }
41
42 void printParallelThreadCnt()
43 {
44 int mpi_iam=0, mpi_num=1;
45 char hname[64];
46
47 gethostname(hname, 64);
48
49 #ifdef PASO_MPI
50 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_iam);
51 MPI_Comm_size(MPI_COMM_WORLD, &mpi_num);
52 #endif
53
54 #ifdef _OPENMP
55 #pragma omp parallel
56 #endif
57 {
58 int omp_iam=0, omp_num=1;
59 #ifdef _OPENMP
60 omp_iam = omp_get_thread_num(); /* Call in a parallel region */
61 omp_num = omp_get_num_threads();
62 #endif
63 printf("printParallelThreadCounts: MPI=%d/%d OpenMP=%d/%d running on %s\n", mpi_iam, mpi_num, omp_iam, omp_num, hname);
64 }
65 }
66
67 void setNumberOfThreads(const int num_threads)
68 {
69
70 #ifdef _OPENMP
71 omp_set_num_threads(num_threads);
72 #endif
73
74 }
75
76 int getNumberOfThreads()
77 {
78 #ifdef _OPENMP
79 return omp_get_max_threads();
80 #else
81 return 1;
82 #endif
83
84 }
85
86 } // end of namespace

  ViewVC Help
Powered by ViewVC 1.1.26