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

Diff of /branches/arrayview_from_1695_trunk/escript/src/Utils.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1568 by ksteube, Sat May 24 03:15:08 2008 UTC revision 1620 by ksteube, Fri Jun 27 02:30:18 2008 UTC
# Line 35  int getSvnVersion() Line 35  int getSvnVersion()
35  #endif  #endif
36  }  }
37    
38    /* This is probably not very robust, but it works on Savanna today and is useful for performance analysis */
39    int get_core_id() {
40      int processor_num=-1;
41    #ifdef CORE_ID1
42      FILE *fp;
43      int i, count_spaces=0;
44      char fname[100];
45      char buf[1000];
46    
47      sprintf(fname, "/proc/%d/stat", getpid());
48      fp = fopen(fname, "r");
49      if (fp == NULL) return(-1);
50      fgets(buf, 1000, fp);
51      fclose(fp);
52    
53      for (i=strlen(buf)-1; i>=0; i--) {
54        if (buf[i] == ' ') count_spaces++;
55        if (count_spaces == 4) break;
56      }
57      processor_num = atoi(&buf[i+1]);
58    #endif
59      return(processor_num);
60    }
61    
62    
63  void printParallelThreadCnt()  void printParallelThreadCnt()
64  {  {
65    int mpi_iam=0, mpi_num=1;    int mpi_iam=0, mpi_num=1;
# Line 56  void printParallelThreadCnt() Line 81  void printParallelThreadCnt()
81      omp_iam = omp_get_thread_num(); /* Call in a parallel region */      omp_iam = omp_get_thread_num(); /* Call in a parallel region */
82      omp_num = omp_get_num_threads();      omp_num = omp_get_num_threads();
83      #endif      #endif
84      printf("printParallelThreadCounts: MPI=%d/%d OpenMP=%d/%d running on %s\n", mpi_iam, mpi_num, omp_iam, omp_num, hname);      printf("printParallelThreadCounts: MPI=%03d/%03d OpenMP=%03d/%03d running on %s core %d\n",
85          mpi_iam, mpi_num, omp_iam, omp_num, hname, get_core_id());
86    }    }
87  }  }
88    

Legend:
Removed from v.1568  
changed lines
  Added in v.1620

  ViewVC Help
Powered by ViewVC 1.1.26