~ubuntu-branches/ubuntu/vivid/psicode/vivid

« back to all changes in this revision

Viewing changes to src/lib/libdpd/contract444.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2008-06-07 16:49:57 UTC
  • mfrom: (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080607164957-8pifvb133yjlkagn
Tags: 3.3.0-3
* debian/rules (DEB_MAKE_CHECK_TARGET): Do not abort test suite on
  failures.
* debian/rules (DEB_CONFIGURE_EXTRA_FLAGS): Set ${bindir} to /usr/lib/psi.
* debian/rules (install/psi3): Move psi3 file to /usr/bin.
* debian/patches/07_464867_move_executables.dpatch: New patch, add
  /usr/lib/psi to the $PATH, so that the moved executables are found.
  (closes: #464867)
* debian/patches/00list: Adjusted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
  long int size_Y, size_Z, size_file_X_row;
31
31
  int incore, nbuckets;
32
32
  long int memoryd, core, rows_per_bucket, rows_left, memtotal;
33
 
#ifdef DPD_DEBUG
 
33
#if DPD_DEBUG
34
34
  int *xrow, *xcol, *yrow, *ycol, *zrow, *zcol;
35
35
  double byte_conv;
36
36
#endif
98
98
    }
99
99
    else incore = 1;
100
100
 
101
 
#ifdef DPD_DEBUG
102
 
    fprintf(stderr, "Contract444: memory information.\n");
103
 
    fprintf(stderr, "Contract444: h = %d, row = %d, col = %d, tot = %d\n", 
104
 
            Hx, X->params->rowtot[Hx], X->params->coltot[Hx^GX],
105
 
            X->params->rowtot[Hx] * X->params->coltot[Hx^GX]);
 
101
#if DPD_DEBUG
106
102
    if(!incore) {
 
103
      fprintf(stderr, "Contract444: memory information.\n");
 
104
      fprintf(stderr, "Contract444: h = %d, row = %d, col = %d, tot = %d\n", 
 
105
              Hx, X->params->rowtot[Hx], X->params->coltot[Hx^GX],
 
106
              X->params->rowtot[Hx] * X->params->coltot[Hx^GX]);
 
107
 
107
108
      fprintf(stderr, "Contract444: nbuckets = %d\n", nbuckets);
108
109
      fprintf(stderr, "Contract444: rows_per_bucket = %d\n",rows_per_bucket);
109
110
      fprintf(stderr, "Contract444: rows_left = %d\n",rows_left);
114
115
      fprintf(stderr, "Contract444: Need %5.2f MB to run in memory.\n",
115
116
              ((double) memtotal)*byte_conv);
116
117
      dpd_file4_cache_print(stderr);
 
118
      fflush(stderr);
117
119
    }
118
 
    fflush(stderr);
119
120
#endif
120
121
 
121
 
    if(!incore && Xtrans) {
 
122
    /*
 
123
      if(!incore && Xtrans) {
122
124
      dpd_file4_cache_print(stderr);
123
125
      dpd_error("out-of-core contract444 Xtrans=1 not coded", stderr);
124
 
    }
 
126
      }
 
127
    */
125
128
 
126
129
    if(incore) {
127
130
      dpd_buf4_mat_irrep_init(X, Hx);
143
146
                &(Z->matrix[Hz][0][0]), Z->params->coltot[Hz^GZ]);
144
147
      }
145
148
 
146
 
      /*
147
 
        newmm(X->matrix[Hx], Xtrans, Y->matrix[Hy], Ytrans,
148
 
        Z->matrix[Hz], Z->params->rowtot[Hz], numlinks[Hx^symlink],
149
 
        Z->params->coltot[Hz^GZ], alpha, beta);
150
 
      */
151
 
 
152
149
      dpd_buf4_mat_irrep_close(X, Hx);
153
150
 
154
151
      dpd_buf4_mat_irrep_wrt(Z, Hz);
157
154
    }
158
155
    else {
159
156
 
160
 
      if(!Ytrans) { 
161
 
        fprintf(stderr, "Contract444: Problem!  Out-of-core algorithm used, but Ytrans == 0!\n");
162
 
        exit(PSI_RETURN_FAILURE);
 
157
      /* out-of-core algorithm coded only for NT and TN arrangements, not NN or TT */
 
158
      if(!Ytrans && !Xtrans || Ytrans && Xtrans) { 
 
159
        fprintf(stderr, "Out-of-core algorithm not yet coded for NN or TT DGEMM.\n");
 
160
        dpd_error("contract444", stderr);
163
161
      }
164
162
 
165
163
      dpd_buf4_mat_irrep_init_block(X, Hx, rows_per_bucket);
173
171
 
174
172
        dpd_buf4_mat_irrep_rd_block(X, Hx, n*rows_per_bucket, rows_per_bucket);
175
173
 
176
 
        C_DGEMM('n', 't', rows_per_bucket, Z->params->coltot[Hz^GZ],
177
 
                numlinks[Hx^symlink], alpha, &(X->matrix[Hx][0][0]), numlinks[Hx^symlink],
178
 
                &(Y->matrix[Hy][0][0]), numlinks[Hx^symlink], beta,
179
 
                &(Z->matrix[Hz][n*rows_per_bucket][0]), Z->params->coltot[Hz^GZ]);
 
174
        if(!Xtrans && Ytrans) {
 
175
          if(Z->params->coltot[Hz^GZ] && rows_per_bucket && numlinks[Hx^symlink])
 
176
            C_DGEMM('n', 't', rows_per_bucket, Z->params->coltot[Hz^GZ],
 
177
                    numlinks[Hx^symlink], alpha, &(X->matrix[Hx][0][0]), numlinks[Hx^symlink],
 
178
                    &(Y->matrix[Hy][0][0]), numlinks[Hx^symlink], beta,
 
179
                    &(Z->matrix[Hz][n*rows_per_bucket][0]), Z->params->coltot[Hz^GZ]);
 
180
        }
 
181
        else if(Xtrans && !Ytrans) {
 
182
          /* CAUTION: We need to accumulate the results of DGEMM for
 
183
             each bucket in this case.  So, we set beta="user value"
 
184
             on the first bucket, but beta=1 for every bucket
 
185
             thereafter. */
 
186
          if(Z->params->coltot[Hz^GZ] && Z->params->rowtot[Hz] && rows_per_bucket)
 
187
            C_DGEMM('t', 'n', Z->params->rowtot[Hz], Z->params->coltot[Hz^GZ],
 
188
                    rows_per_bucket, alpha, &(X->matrix[Hx][0][0]), X->params->coltot[Hx^GX],
 
189
                    &(Y->matrix[Hy][n*rows_per_bucket][0]), Y->params->coltot[Hy^GY], (n==0 ? beta : 1.0),
 
190
                    &(Z->matrix[Hz][0][0]), Z->params->coltot[Hz^GZ]);
 
191
        }
180
192
 
181
193
      }
182
194
 
184
196
 
185
197
        dpd_buf4_mat_irrep_rd_block(X, Hx, n*rows_per_bucket, rows_left);
186
198
 
187
 
        C_DGEMM('n', 't', rows_left, Z->params->coltot[Hz^GZ],
188
 
                numlinks[Hx^symlink], alpha, &(X->matrix[Hx][0][0]), numlinks[Hx^symlink],
189
 
                &(Y->matrix[Hy][0][0]), numlinks[Hx^symlink], beta,
190
 
                &(Z->matrix[Hz][n*rows_per_bucket][0]), Z->params->coltot[Hz^GZ]);
 
199
        if(!Xtrans && Ytrans) {
 
200
          if(Z->params->coltot[Hz^GZ] && rows_left && numlinks[Hx^symlink])
 
201
            C_DGEMM('n', 't', rows_left, Z->params->coltot[Hz^GZ],
 
202
                    numlinks[Hx^symlink], alpha, &(X->matrix[Hx][0][0]), numlinks[Hx^symlink],
 
203
                    &(Y->matrix[Hy][0][0]), numlinks[Hx^symlink], beta,
 
204
                    &(Z->matrix[Hz][n*rows_per_bucket][0]), Z->params->coltot[Hz^GZ]);
 
205
        }
 
206
        else if(Xtrans && !Ytrans) {
 
207
          if(Z->params->coltot[Hz^GZ] && Z->params->rowtot[Hz] && rows_left)
 
208
            C_DGEMM('t', 'n', Z->params->rowtot[Hz], Z->params->coltot[Hz^GZ],
 
209
                    rows_left, alpha, &(X->matrix[Hx][0][0]), X->params->coltot[Hx^GX],
 
210
                    &(Y->matrix[Hy][n*rows_per_bucket][0]), Y->params->coltot[Hy^GY], 1.0,
 
211
                    &(Z->matrix[Hz][0][0]), Z->params->coltot[Hz^GZ]);
 
212
        }
191
213
 
192
214
      }
193
 
              
 
215
 
194
216
      dpd_buf4_mat_irrep_close_block(X, Hx, rows_per_bucket);
195
217
 
196
218
      dpd_buf4_mat_irrep_close(Y, Hy);