~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_create_irreg.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
/*
 
2
 * Test Program for GA
 
3
 * This is to test GA_Create_irreg (is a collective operation)
 
4
 * GA_Create -- used to create a global array of regular size
 
5
 * GA_Create_IRREG -- used to create G_array of irregular size -- helps user to define the distribution 
 
6
 * Here used GA_Inquire to verify that g_A hanle returns the right values of created_array
 
7
 */
 
8
 
 
9
#include<stdio.h>
 
10
#include<stdlib.h>
 
11
 
 
12
#include"mpi.h"
 
13
#include"ga.h"
 
14
#include"macdecls.h"
 
15
 
 
16
#define DIM 2
 
17
 
 
18
#define GSIZE 10
 
19
 
 
20
irregular_array1(int rank)
 
21
{
 
22
 
 
23
  int g_A, g_B; 
 
24
  int dims[DIM]={5,10}, dims2[DIM], ndim, type, value=5, block[DIM]={2,3}, map[5]={0,2,0,4,6}, val=7;
 
25
  int n_block[DIM], block_dims[DIM], i;
 
26
 
 
27
  g_A = NGA_Create(C_INT, DIM, dims, "array_A", NULL);
 
28
  g_B = NGA_Create_irreg(C_INT, DIM, dims, "array_B", block, map);
 
29
 
 
30
  GA_Fill(g_A, &value);
 
31
  GA_Print(g_A);
 
32
 
 
33
  GA_Fill(g_B, &val);
 
34
  GA_Print(g_B);
 
35
  GA_Sync();
 
36
 
 
37
  NGA_Inquire(g_A, &type, &ndim, dims2);
 
38
  //printf(" %d -- %d,,\n", type, ndim);
 
39
 
 
40
  /*
 
41
  GA_Get_block_info(g_B, n_block, block_dims);
 
42
  for(i=0; i<DIM; i++)
 
43
    printf(" %d:  %d ___ %d --- \n", rank, n_block[i], block_dims[i]);
 
44
  */
 
45
 
 
46
  GA_Destroy(g_A);
 
47
  GA_Destroy(g_B);
 
48
}
 
49
 
 
50
irregular_array2(int rank)
 
51
{
 
52
 
 
53
  int g_A, g_B; 
 
54
  int dims[DIM]={GSIZE,GSIZE}, dims2[DIM], block[DIM]={3,2}, map[5]={0,2,6,0,4}, val=7;
 
55
  int n_block[DIM], block_dims[DIM], i;
 
56
 
 
57
  g_A = NGA_Create(C_INT, DIM, dims, "array_A", NULL);
 
58
  g_B = NGA_Create_irreg(C_INT, DIM, dims, "array_B", block, map);
 
59
 
 
60
  GA_Fill(g_B, &val);
 
61
  GA_Print(g_B);
 
62
  GA_Sync();
 
63
 
 
64
  /*
 
65
  GA_Get_block_info(g_B, n_block, block_dims);
 
66
  for(i=0; i<DIM; i++)
 
67
    printf(" %d:  %d ___ %d --- \n", rank, n_block[i], block_dims[i]);
 
68
  */
 
69
 
 
70
  GA_Destroy(g_A);
 
71
  GA_Destroy(g_B);
 
72
}
 
73
 
 
74
/* In these function the values of blocks and maps are auto-generated number based on number of processes we use */
 
75
 
 
76
auto_number1(int rank, int nprocs)
 
77
{
 
78
 
 
79
  int g_A, g_B; 
 
80
  int dims[DIM]={GSIZE, GSIZE}, dims2[DIM], block[DIM], *map=NULL, val=7;
 
81
  int n_block[DIM], block_dims[DIM], b_temp, i;
 
82
  int b1, b2, inc=0;
 
83
 
 
84
  do{
 
85
      b1=DIM+inc;
 
86
      b2=nprocs/b1;
 
87
      inc++;
 
88
    }while(nprocs/b1>=GSIZE);
 
89
 
 
90
  block[0]=b1;
 
91
  block[1]=b2;
 
92
 
 
93
  map=(int*)malloc(nprocs*sizeof(int));
 
94
 
 
95
  for(i=0; i<b1; i++)
 
96
    map[i]=i*DIM;
 
97
 
 
98
  for(i=b1; i<(b2+b1); i++)
 
99
    map[i]=i-b1;
 
100
 
 
101
  if(rank==0)
 
102
    {
 
103
      for(i=0; i<(b1+b2); i++)
 
104
        printf("map[%d] - %d\n", i, map[i]);
 
105
      for(i=0; i<DIM; i++)
 
106
        printf("BLOCK[%d] - %d\n", i, block[i]);
 
107
    }
 
108
 
 
109
  g_B = NGA_Create_irreg(C_INT, DIM, dims, "array_B", block, map);
 
110
 
 
111
  GA_Fill(g_B, &val);
 
112
  GA_Print(g_B);
 
113
  GA_Sync();
 
114
 
 
115
  if(rank==1)
 
116
    {
 
117
      GA_Get_block_info(g_B, n_block, block_dims);
 
118
      for(i=0; i<DIM; i++)
 
119
        printf(" %d:  %d --- %d ... %d\n", rank, n_block[i], block_dims[i], b_temp);
 
120
    }
 
121
  GA_Destroy(g_B);
 
122
}
 
123
 
 
124
auto_number2(int rank, int nprocs)
 
125
{
 
126
 
 
127
  int g_A, g_B; 
 
128
  int dims[DIM]={GSIZE, GSIZE}, dims2[DIM], block[DIM], *map=NULL, val=7;
 
129
  int n_block[DIM], block_dims[DIM], b_temp, i;
 
130
  int b1, b2, inc=0;
 
131
 
 
132
  do{
 
133
    
 
134
    b2=DIM+inc;
 
135
    b1=nprocs/b2;    
 
136
      inc++;
 
137
    }while(nprocs/b2>=GSIZE);
 
138
 
 
139
  block[0]=b1;
 
140
  block[1]=b2;
 
141
 
 
142
  map=(int*)malloc(nprocs*sizeof(int));
 
143
 
 
144
  for(i=0; i<b1; i++)
 
145
    map[i]=i;
 
146
 
 
147
  for(i=b1; i<(b2+b1); i++)
 
148
    map[i]=i-b1;
 
149
 
 
150
  if(rank==0)
 
151
    {
 
152
      for(i=0; i<(b1+b2); i++)
 
153
        printf("map[%d] - %d\n", i, map[i]);
 
154
      for(i=0; i<DIM; i++)
 
155
        printf("BLOCK[%d] - %d\n", i, block[i]);
 
156
    }
 
157
 
 
158
  g_B = NGA_Create_irreg(C_INT, DIM, dims, "array_B", block, map);
 
159
 
 
160
  GA_Fill(g_B, &val);
 
161
  GA_Print(g_B);
 
162
  GA_Sync();
 
163
 
 
164
  if(rank==1)
 
165
    {
 
166
      GA_Get_block_info(g_B, n_block, block_dims);
 
167
      for(i=0; i<DIM; i++)
 
168
        printf(" %d:  %d --- %d ... %d\n", rank, n_block[i], block_dims[i], b_temp);
 
169
    }
 
170
  GA_Destroy(g_B);
 
171
}
 
172
 
 
173
main(int argc, char **argv)
 
174
{
 
175
  int rank, nprocs;
 
176
 
 
177
  MPI_Init(&argc, &argv);
 
178
 
 
179
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 
180
  MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
 
181
 
 
182
  MA_init(C_INT, 1000, 1000);
 
183
 
 
184
  GA_Initialize();
 
185
 
 
186
  //irregular_array1(rank);  
 
187
  //  irregular_array2(rank);  
 
188
 
 
189
  //  auto_number1(rank, nprocs);
 
190
  auto_number2(rank, nprocs);
 
191
 
 
192
  if(rank == 0)
 
193
    printf("Test Completed \n");
 
194
 
 
195
  GA_Terminate();
 
196
  MPI_Finalize();
 
197
  
 
198
}