next up previous contents
Next: I/O files Up: MCHF Previous: Diagonalization   Contents


Dynamic memory management

Memory management is an important factor for increasing the limits of the mchf calculation, and it has been accomplished mainly in two directions. First, between the two phases of an scf() iteration, arrays can share memory, and secondly the memory is allocated based on size and frequency of use in CPU intensive processes.

The SCF process has two phases which are totally disjoint, the array of contributions to the energy functional, and the array of integral values may share the same memory.

  1. In the orbital update phase, the appropriate view of the energy functional is given by Eq. (3). To compute the potential and/or exchange function for a specified orbital, say $a$, it is necessary to search the list for integrals involving orbital $a$. When an integral is found, its contribution needs to be determined and multiplied by $w_{ab}$ or $v_{abcd;k}$. Thus in this phase the values of the integrals themselves are not needed, only the coefficient defining their contribution to the energy. Since these coefficients depend on eigenvectors, they need to be re-computed before the orbital update phase. In the present implementation, it occurs after the diagonalization process.
  2. In the matrix diagonalization phase, the matrix elements as defined by Eq (2) need to be assembled, in order, as described earlier. Now the value of the integrals are needed but not their total contribution to the energy functional. Thus, before the diagonalization phase, all integrals need to be re-evaluated.

To maximize the memory utilization, the storage of all arrays is allocated in a stepwise fashion. Upon memory allocation failure, the remaining arrays are stored on disk. Under this scheme the order in which arrays are allocated becomes important and the arrays used most frequently at each SCF iteration are allocated first. The angular coefficient data and the interaction matrix are the two major data structures which define the memory use for each scf iteration. As the number of configurations grows the memory capacity may be exceeded thus requiring some or most of the data to be stored on disk. Disk read/write operations are then performed on each SCF and DVDSON iteration. Disk read/write access is considerably slower compared to memory access. In order to accomplish high computational efficiency it is essential to avoid disk I/O and keep all data in memory. Therefore, optimizing mchf for large scale calculations requires management of the disk/memory data storage. In general, the angular coefficients, the interaction matrix elements and the associated pointers are stored in one dimensional arrays. The arrays of angular coefficients are considerably larger than the interaction matrix.

The memory allocation process (alcsts), starts with Level 4 and upon success on each level may proceed up to Level 1. At Level 4, if no memory is available for performing Dvdson iterations on disk (vector-matrix multiplication on disk) the program exits. (This will represent a very large case beyond practical limits for serial computing: in the order of millions of cfgs). If the program cannot proceed with allocating memory for the interaction matrix of the largest block, a similar, local scheme (in diag) is used to allocate memory for each block. Blocks can vary significantly in size and in order to improve the performance mchf is designed to keep smaller blocks in memory if possible.


Table 6.2: Steps in allocating memory.
\begin{table}\begin{tabular*}{0.8\textwidth}
{@{\extracolsep{\fill}} l l l}
\...
...{\tt hmx, ih, ico} for a single column \\
\hline
\\
\end{tabular*}\end{table}


As shown in table  6.3, levels 1, 2, and 3 ico has higher priority compared to coeff and inptr because ico is used in both diag and updatc routines. However, it is important to note that updatc proceeds almost always in memory since all of the memory used in diag_hmx and dvdson is deallocated and made available.

The memory allocation procedure relies on malloc() and free(), which are C routines normally used for dynamic memory management. malloc() allocates size bytes and returns a pointer to the allocated memory. If the request fails malloc() returns a NULL pointer. The atsp2K package includes the routines alloc() and dalloc() which use a similar approach, however upon failure alloc() aborts by calling EXIT(). mchf has several levels of memory allocation requiring the returned pointer to be monitored in order to adjust the subsequent memory requests. For this purpose two routines specific only to mchf have been introduced: diag_allocate() and diag_deallocate(). If the memory is not sufficient for loading the array under consideration in the memory, then, memory for the largest column of that array is allocated and the array is stored on disk.


next up previous contents
Next: I/O files Up: MCHF Previous: Diagonalization   Contents
2001-10-11