~ubuntu-branches/ubuntu/trusty/nwchem/trusty-proposed

« back to all changes in this revision

Viewing changes to src/tools/ga-5-2/global/testing/unit-tests/ga_elem_multiply.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
#include "ga.h"
 
2
#include "mock.h"
 
3
#include "ga_unit.h"
 
4
 
 
5
static int test(int shape_idx, int type_idx, int dist_idx)
 
6
{
 
7
    int type = TYPES[type_idx];
 
8
    int *dims = SHAPES[shape_idx];
 
9
    int ndim = SHAPES_NDIM[shape_idx];
 
10
    mock_ga_t *mock_a, *mock_b, *mock_c, *mock_r;
 
11
    int g_a, g_b, g_c;
 
12
    int buffer[100];
 
13
    int lo[GA_MAX_DIM], hi[GA_MAX_DIM], ld[GA_MAX_DIM], shape[GA_MAX_DIM];
 
14
    int result=0, error_index=-1, error_proc=-1;
 
15
 
 
16
    mock_a = Mock_Create(type, ndim, dims, "mock", NULL);
 
17
    mock_b = Mock_Create(type, ndim, dims, "mock", NULL);
 
18
    mock_c = Mock_Create(type, ndim, dims, "mock", NULL);
 
19
    mock_r = Mock_Create(type, ndim, dims, "mock", NULL);
 
20
 
 
21
    g_a = create_function[dist_idx](type, ndim, dims);
 
22
    g_b = create_function[dist_idx](type, ndim, dims);
 
23
    g_c = create_function[dist_idx](type, ndim, dims);
 
24
 
 
25
    /* create meaningful data for local array */
 
26
    mock_data(mock_a, g_a);
 
27
    mock_data(mock_b, g_b);
 
28
 
 
29
    /* init global array with same data as local array */
 
30
    mock_to_global(mock_a, g_a);
 
31
    mock_to_global(mock_b, g_b);
 
32
 
 
33
    /* call the local routine */
 
34
    Mock_Elem_multiply(mock_a, mock_b, mock_c);
 
35
 
 
36
    /* call the global routine */
 
37
    GA_Elem_multiply(g_a, g_b, g_c);
 
38
 
 
39
    /* get the results from the global array */
 
40
    global_to_mock(g_c, mock_r);
 
41
 
 
42
    /* compare the results */
 
43
    result = neq_mock(mock_c, mock_r, &error_index);
 
44
    if (0 != result) {
 
45
        error_proc = GA_Nodeid();
 
46
    }
 
47
    /* make sure all procs get same result so they can die gracefully */
 
48
    GA_Igop(&result, 1, "+");
 
49
    /* if error occured, find the highest failing node ID */
 
50
    GA_Igop(&error_proc, 1, "max");
 
51
    /* clear the error index for all but the highest failing node ID */
 
52
    if (error_proc != GA_Nodeid()) {
 
53
        error_index = 0;
 
54
    }
 
55
    /* make sure all procs get the error index on the highest failing node ID */
 
56
    GA_Igop(&error_index, 1, "+");
 
57
    if (0 != result) {
 
58
        if (error_proc == GA_Nodeid()) {
 
59
            printf("ERROR: local result failed to compare to global result\n");
 
60
            printf("\terror_proc=%d\n", error_proc);
 
61
            printf("\terror_index=%d\n", error_index);
 
62
            printf("***LOCAL RESULT***\n");
 
63
            Mock_Print(mock_a);
 
64
            printf("***GLOBAL RESULT***\n");
 
65
            Mock_Print(mock_r);
 
66
            printf("\tprinting array distribution\n");
 
67
        }
 
68
        GA_Sync();
 
69
        GA_Print(g_a);
 
70
        GA_Print_distribution(g_a);
 
71
        return 1;
 
72
    }
 
73
 
 
74
    /* clean up */
 
75
    Mock_Destroy(mock_a);
 
76
    Mock_Destroy(mock_r);
 
77
    GA_Destroy(g_a);
 
78
 
 
79
    return 0;
 
80
 
 
81
}
 
82
 
 
83
int main(int argc, char **argv)
 
84
{
 
85
    TEST_SETUP;
 
86
 
 
87
    int shape_idx=0, type_idx=0, dist_idx=0;
 
88
    int return_code=0;
 
89
 
 
90
    for (shape_idx=0; shape_idx < NUM_SHAPES; ++shape_idx) {
 
91
      for (type_idx=0; type_idx < NUM_TYPES; ++type_idx) {
 
92
            for (dist_idx=0; dist_idx < NUM_DISTS; ++dist_idx) {
 
93
                if (0 == GA_Nodeid()) {
 
94
                    printf("%s\t%s\t%s\n",
 
95
                            SHAPE_NAMES[shape_idx],
 
96
                            TYPE_NAMES[type_idx],
 
97
                            DIST_NAMES[dist_idx]
 
98
                            );
 
99
                }
 
100
                GA_Sync();
 
101
                return_code = test(shape_idx, type_idx, dist_idx);
 
102
                if (0 != return_code) {
 
103
                    break;
 
104
                }
 
105
            }
 
106
            if (0 != return_code) {
 
107
                break;
 
108
            }
 
109
        }
 
110
        if (0 != return_code) {
 
111
            break;
 
112
        }
 
113
    }
 
114
 
 
115
    TEST_TEARDOWN;
 
116
    return return_code;
 
117
}