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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1628 - (show annotations)
Fri Jul 11 13:12:46 2008 UTC (11 years, 4 months ago) by phornby
File size: 2157 byte(s)

Merge in /branches/windows_from_1456_trunk_1620_merged_in branch.

You will find a preserved pre-merge trunk in tags under tags/trunk_at_1625.
That will be useful for diffing & checking on my stupidity.

Here is a list of the conflicts and their resolution at this
point in time.


=================================================================================
(LLWS == looks like white space).

finley/src/Assemble_addToSystemMatrix.c - resolve to branch - unused var. may be wrong.....
finley/src/CPPAdapter/SystemMatrixAdapter.cpp - resolve to branch - LLWS
finley/src/CPPAdapter/MeshAdapter.cpp - resolve to branch - LLWS
paso/src/PCG.c - resolve to branch - unused var fixes.
paso/src/SolverFCT.c - resolve to branch - LLWS
paso/src/FGMRES.c - resolve to branch - LLWS
paso/src/Common.h - resolve to trunk version. It's omp.h's include... not sure it's needed,
but for the sake of saftey.....
paso/src/Functions.c - resolve to branch version, indentation/tab removal and return error
on bad unimplemented Paso_FunctionCall.
paso/src/SolverFCT_solve.c - resolve to branch version, unused vars
paso/src/SparseMatrix_MatrixVector.c - resolve to branch version, unused vars.
escript/src/Utils.cpp - resloved to branch, needs WinSock2.h
escript/src/DataExpanded.cpp - resolved to branch version - LLWS
escript/src/DataFactory.cpp - resolve to branch version
=================================================================================

This currently passes tests on linux (debian), but is not checked on windows or Altix yet.

This checkin is to make a trunk I can check out for windows to do tests on it.

Known outstanding problem is in the operator=() method of exceptions
causing warning messages on the intel compilers.

May the God of doughnuts have mercy on my soul.


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 /* This is probably not very robust, but it works on Savanna today and is useful for performance analysis */
43 int get_core_id() {
44 int processor_num=-1;
45 #ifdef CORE_ID1
46 FILE *fp;
47 int i, count_spaces=0;
48 char fname[100];
49 char buf[1000];
50
51 sprintf(fname, "/proc/%d/stat", getpid());
52 fp = fopen(fname, "r");
53 if (fp == NULL) return(-1);
54 fgets(buf, 1000, fp);
55 fclose(fp);
56
57 for (i=strlen(buf)-1; i>=0; i--) {
58 if (buf[i] == ' ') count_spaces++;
59 if (count_spaces == 4) break;
60 }
61 processor_num = atoi(&buf[i+1]);
62 #endif
63 return(processor_num);
64 }
65
66
67 void printParallelThreadCnt()
68 {
69 int mpi_iam=0, mpi_num=1;
70 char hname[64];
71
72 gethostname(hname, 64);
73
74 #ifdef PASO_MPI
75 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_iam);
76 MPI_Comm_size(MPI_COMM_WORLD, &mpi_num);
77 #endif
78
79 #ifdef _OPENMP
80 #pragma omp parallel
81 #endif
82 {
83 int omp_iam=0, omp_num=1;
84 #ifdef _OPENMP
85 omp_iam = omp_get_thread_num(); /* Call in a parallel region */
86 omp_num = omp_get_num_threads();
87 #endif
88 printf("printParallelThreadCounts: MPI=%03d/%03d OpenMP=%03d/%03d running on %s core %d\n",
89 mpi_iam, mpi_num, omp_iam, omp_num, hname, get_core_id());
90 }
91 }
92
93 void setNumberOfThreads(const int num_threads)
94 {
95
96 #ifdef _OPENMP
97 omp_set_num_threads(num_threads);
98 #endif
99
100 }
101
102 int getNumberOfThreads()
103 {
104 #ifdef _OPENMP
105 return omp_get_max_threads();
106 #else
107 return 1;
108 #endif
109
110 }
111
112 } // end of namespace

  ViewVC Help
Powered by ViewVC 1.1.26