~ubuntu-branches/ubuntu/utopic/nwchem/utopic

« back to all changes in this revision

Viewing changes to src/tools/ga-5-2/global/src/ga_trace.c

  • Committer: Package Import Robot
  • Author(s): Michael Banck, Daniel Leidert, Andreas Tille, Michael Banck
  • Date: 2013-07-04 12:14:55 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130704121455-5tvsx2qabor3nrui
Tags: 6.3-1
* New upstream release.
* Fixes anisotropic properties (Closes: #696361).
* New features include:
  + Multi-reference coupled cluster (MRCC) approaches
  + Hybrid DFT calculations with short-range HF 
  + New density-functionals including Minnesota (M08, M11) and HSE hybrid
    functionals
  + X-ray absorption spectroscopy (XAS) with TDDFT
  + Analytical gradients for the COSMO solvation model
  + Transition densities from TDDFT 
  + DFT+U and Electron-Transfer (ET) methods for plane wave calculations
  + Exploitation of space group symmetry in plane wave geometry optimizations
  + Local density of states (LDOS) collective variable added to Metadynamics
  + Various new XC functionals added for plane wave calculations, including
    hybrid and range-corrected ones
  + Electric field gradients with relativistic corrections 
  + Nudged Elastic Band optimization method
  + Updated basis sets and ECPs 

[ Daniel Leidert ]
* debian/watch: Fixed.

[ Andreas Tille ]
* debian/upstream: References

[ Michael Banck ]
* debian/upstream (Name): New field.
* debian/patches/02_makefile_flags.patch: Refreshed.
* debian/patches/06_statfs_kfreebsd.patch: Likewise.
* debian/patches/07_ga_target_force_linux.patch: Likewise.
* debian/patches/05_avoid_inline_assembler.patch: Removed, no longer needed.
* debian/patches/09_backported_6.1.1_fixes.patch: Likewise.
* debian/control (Build-Depends): Added gfortran-4.7 and gcc-4.7.
* debian/patches/10_force_gcc-4.7.patch: New patch, explicitly sets
  gfortran-4.7 and gcc-4.7, fixes test suite hang with gcc-4.8 (Closes:
  #701328, #713262).
* debian/testsuite: Added tests for COSMO analytical gradients and MRCC.
* debian/rules (MRCC_METHODS): New variable, required to enable MRCC methods.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#if HAVE_CONFIG_H
 
2
#   include "config.h"
 
3
#endif
 
4
 
 
5
 /***********************************************************************\
 
6
 * Tracing and Timing functions for the GA routines:                     *
 
7
 *   trace_init       - initialization                                   *
 
8
 *   trace_stime      - starts timing                                    *
 
9
 *   trace_etime      - ends timing                                      *
 
10
 *   trace_genrec     - generates a trace record for the calling routine *
 
11
 *   trace_end        - ends tracing & writes report to a file 'proc'    *
 
12
 * Note: the usc timer from the ALOG package is used                     *
 
13
 * Jarek Nieplocha, 10.14.93                                             *
 
14
 \***********************************************************************/
 
15
 
 
16
#include <macdecls.h>
 
17
#if HAVE_STDIO_H
 
18
#   include <stdio.h>
 
19
#endif
 
20
#if HAVE_STDLIB_H
 
21
#   include <stdlib.h>
 
22
#endif
 
23
#include "ga.h"
 
24
 
 
25
#ifndef MPI
 
26
#  include "tcgmsg.h"
 
27
#else
 
28
#  include "mpi.h"
 
29
#endif
 
30
 
 
31
#include "ga-papi.h"
 
32
#include "ga-wapi.h"
 
33
 
 
34
static double tt0, tt1;
 
35
static Integer *tlog, thandle;
 
36
static Integer *indlog, ihandle, gahandle;
 
37
static int *galog;
 
38
static unsigned long current, MAX_EVENTS=0; 
 
39
static int ganum = 0;
 
40
 
 
41
#define MAX_GAS 100
 
42
 
 
43
#define min(a,b) ((a)<(b) ? (a) : (b))
 
44
 
 
45
#if HAVE_SYS_WEAK_ALIAS_PRAGMA
 
46
#   pragma weak wnga_timer = pnga_timer
 
47
#endif
 
48
double pnga_timer()
 
49
{
 
50
#ifdef MPI
 
51
       return MPI_Wtime();
 
52
#else
 
53
       return tcg_time();
 
54
#endif
 
55
}
 
56
 
 
57
/* n is the max number of events to be traced */
 
58
void trace_init_(long *n)
 
59
{
 
60
    MA_AccessIndex index;
 
61
    long err;
 
62
    
 
63
    if(*n<=0){
 
64
        printf("trace_init>>  invalid max number of events: %ld\n",*n);
 
65
        return;
 
66
    }
 
67
    
 
68
    current = 0;
 
69
    err = 0;
 
70
    
 
71
    /*  MA_initialize(MT_INT,10000,10000); */ 
 
72
    
 
73
    MAX_EVENTS = *n;
 
74
 
 
75
    if(!MA_push_get(MT_LONGINT, *n*2, "timeLog", &thandle, &index)){
 
76
        printf("trace_init>> failed to allocate memory 1\n");
 
77
        err ++;
 
78
    }
 
79
    MA_get_pointer(thandle, &tlog);
 
80
    if(!tlog){
 
81
        printf("trace_init>> null pointer: 1\n");
 
82
        err ++;
 
83
    }
 
84
 
 
85
    if(!MA_push_get(MT_LONGINT, *n*6, "indexLog", &ihandle, &index)){
 
86
        printf("trace_init>> failed to allocate memory 2\n");
 
87
        err ++;
 
88
    }
 
89
    MA_get_pointer(ihandle, &indlog);
 
90
    if(!indlog) { 
 
91
        printf("trace_init>> null pointer: 2\n");
 
92
        err ++;
 
93
    }
 
94
 
 
95
    if(!MA_push_get(MT_INT, MAX_GAS, "gaLog", &gahandle, &index)){
 
96
        printf("trace_init>> failed to allocate memory 2\n");
 
97
        err ++;
 
98
    }
 
99
    MA_get_pointer(gahandle, &galog);
 
100
    if(!galog) { 
 
101
        printf("trace_init>> null pointer: 2\n");
 
102
        err ++;
 
103
    }
 
104
    
 
105
    ganum = 0;
 
106
    
 
107
    if(err) MAX_EVENTS = 0;
 
108
}
 
109
 
 
110
void  trace_stime_()
 
111
{
 
112
    tt0 =  pnga_timer();
 
113
}
 
114
 
 
115
void  trace_etime_()
 
116
{
 
117
    tt1 = pnga_timer();
 
118
}
 
119
 
 
120
void trace_genrec_(Integer *ga, Integer *ilo, Integer *ihi, Integer *jlo, Integer *jhi,
 
121
                   Integer *op)
 
122
{
 
123
    int i, d, has_record, counter;
 
124
    FILE *fout;
 
125
    char fname[15];
 
126
    typedef struct {
 
127
       int lo[2];
 
128
       int hi[2];
 
129
    } patch_t;
 
130
    patch_t *regions;
 
131
    int *proclist;
 
132
    int ndim, dims[2], tmp_dims[2], lo[2], hi[2], type, block[2];
 
133
    int me=GA_Nodeid(), nproc=GA_Nnodes(), proc;
 
134
    
 
135
    if(current >=  MAX_EVENTS) return;
 
136
 
 
137
    /* only node 0 does the bookkeeping */
 
138
    if(me == 0) {
 
139
        /* test if this ga has been recorded */
 
140
        has_record = 0;
 
141
        for(i=0; i<ganum; i++)
 
142
            if(*ga == (long) galog[i]) has_record = 1;
 
143
 
 
144
        if(!has_record) {
 
145
            galog[ganum++] = (int)*ga;
 
146
            
 
147
            sprintf(fname, "distrib.%d",(int) *ga);
 
148
            fout = fopen(fname,"w");
 
149
            
 
150
            NGA_Inquire((int)*ga, &type, &ndim, dims);
 
151
            
 
152
            /* get memory for arrays describing distribution */
 
153
            proclist = (int*)malloc(nproc*sizeof(int));
 
154
            if(!proclist)GA_Error("malloc failed for proclist",0);
 
155
            regions = (patch_t*)malloc(nproc*sizeof(patch_t));
 
156
            if(!regions)GA_Error("malloc failed for regions",0);
 
157
 
 
158
            for(d=0; d<ndim; d++) { lo[d] = 0; hi[d] = dims[d] -1;}
 
159
 
 
160
            proc = NGA_Locate_region((int)*ga, lo, hi, (int*)regions, proclist);
 
161
            if(proc<1) GA_Error("error in NGA_Locate_region",proc);
 
162
            
 
163
            for(d=0; d<ndim; d++) {
 
164
                tmp_dims[d] = 0; block[d] = 0;
 
165
                for(i=0; i<nproc; i++)
 
166
                    if(regions[i].hi[d] > tmp_dims[d]) {
 
167
                        block[d]++;
 
168
                        tmp_dims[d] = regions[i].hi[d];
 
169
                    }
 
170
            }
 
171
 
 
172
            /* print the number of processed */
 
173
            fprintf(fout, "%d\n", nproc);
 
174
            /* print dimensions */
 
175
            for(d=0; d<ndim; d++) fprintf(fout, "%d ", dims[d]);
 
176
            fprintf(fout, "\n");
 
177
 
 
178
            /* print number of lines to draw for each dimension */
 
179
            for(d=0; d<ndim; d++) 
 
180
                if(block[d] == 1) fprintf(fout, "%d ", block[d]);
 
181
                else fprintf(fout, "%d ", block[d]-1);
 
182
            fprintf(fout, "\n");
 
183
 
 
184
            /* print the offset for each line */
 
185
            for(d=0; d<ndim; d++) {
 
186
                if(block[d] == 1) fprintf(fout, "%d\n", dims[d]);
 
187
                else {
 
188
                    tmp_dims[d] = 0;
 
189
                    counter = 0;
 
190
                    for(i=0; i<nproc; i++)
 
191
                        if(regions[i].hi[d] > tmp_dims[d]) {
 
192
                            counter++;
 
193
                            if(counter == block[d]) break;
 
194
                            fprintf(fout, "%d\n",
 
195
                                    regions[i].hi[d]+1);
 
196
                            tmp_dims[d] = regions[i].hi[d];
 
197
                        }
 
198
                }
 
199
            }
 
200
            fclose(fout);
 
201
            free(regions); free(proclist);
 
202
        }
 
203
    }
 
204
 
 
205
    tlog[current*2]     = (unsigned long)(tt0 * 1000000);
 
206
    tlog[current*2+1]   = (unsigned long)(tt1 * 1000000);
 
207
    indlog[current*6]   = *ga;
 
208
    indlog[current*6+1] = *ilo;
 
209
    indlog[current*6+2] = *ihi;
 
210
    indlog[current*6+3] = *jlo;
 
211
    indlog[current*6+4] = *jhi;
 
212
    indlog[current*6+5] = *op;
 
213
    current++;
 
214
}
 
215
 
 
216
void trace_end_(long *proc)
 
217
{
 
218
    FILE *fout;
 
219
    char fname[10];
 
220
    unsigned long i,k;
 
221
    
 
222
    sprintf(fname,"%03d",(int)*proc);
 
223
    fout=fopen(fname,"w");
 
224
    
 
225
    for(i=0;i<min(current,MAX_EVENTS);i++){
 
226
        fprintf(fout,"%d ",(int)*proc);
 
227
        for(k=i*6;k<6*(i+1);k++)fprintf(fout,"%d ",(int)indlog[k]);
 
228
        fprintf(fout,"%ld %ld\n",(unsigned long)tlog[i*2],
 
229
                (unsigned long)tlog[i*2+1]);
 
230
    }
 
231
 
 
232
    MA_pop_stack(gahandle);
 
233
    MA_pop_stack(ihandle);
 
234
    MA_pop_stack(thandle);
 
235
    
 
236
    fclose(fout);
 
237
}