~ubuntu-branches/ubuntu/saucy/nwchem/saucy

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/global/testing/getmem.c

  • Committer: Package Import Robot
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2012-02-09 20:02:41 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120209200241-jgk03qfsphal4ug2
Tags: 6.1-1
* New upstream release.

[ Michael Banck ]
* debian/patches/02_makefile_flags.patch: Updated.
* debian/patches/02_makefile_flags.patch: Use internal blas and lapack code.
* debian/patches/02_makefile_flags.patch: Define GCC4 for LINUX and LINUX64
  (Closes: #632611 and LP: #791308).
* debian/control (Build-Depends): Added openssh-client.
* debian/rules (USE_SCALAPACK, SCALAPACK): Removed variables (Closes:
  #654658).
* debian/rules (LIBDIR, USE_MPIF4, ARMCI_NETWORK): New variables.
* debian/TODO: New file.
* debian/control (Build-Depends): Removed libblas-dev, liblapack-dev and
  libscalapack-mpi-dev.
* debian/patches/04_show_testsuite_diff_output.patch: New patch, shows the
  diff output for failed tests.
* debian/patches/series: Adjusted.
* debian/testsuite: Optionally run all tests if "all" is passed as option.
* debian/rules: Run debian/testsuite with "all" if DEB_BUILD_OPTIONS
  contains "checkall".

[ Daniel Leidert ]
* debian/control: Used wrap-and-sort. Added Vcs-Svn and Vcs-Browser fields.
  (Priority): Moved to extra according to policy section 2.5.
  (Standards-Version): Bumped to 3.9.2.
  (Description): Fixed a typo.
* debian/watch: Added.
* debian/patches/03_hurd-i386_define_path_max.patch: Added.
  - Define MAX_PATH if not defines to fix FTBFS on hurd.
* debian/patches/series: Adjusted.

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
#if HAVE_STDIO_H
 
6
#   include <stdio.h>
 
7
#endif
 
8
#if HAVE_MATH_H
 
9
#   include <math.h>
 
10
#endif
 
11
 
 
12
#include "ga.h"
 
13
#include "macdecls.h"
 
14
#include "mp3.h"
 
15
 
 
16
#define N 4            /* dimension of matrices */
 
17
 
 
18
 
 
19
int main( int argc, char **argv ) {
 
20
  int g_a, g_b,i;
 
21
  int n=N, type=MT_F_DBL;
 
22
  int dims[6]={N,N,N,N,N,N};
 
23
  int lo[6], hi[6];
 
24
 
 
25
  int heap=30000, stack=20000;
 
26
  int me, nproc;
 
27
 
 
28
  int datatype, elements;
 
29
  double *prealloc_mem;
 
30
 
 
31
  MP_INIT(argc,argv);
 
32
 
 
33
  GA_INIT(argc,argv);                            /* initialize GA */
 
34
  me=GA_Nodeid(); 
 
35
  nproc=GA_Nnodes();
 
36
  if(me==0) {
 
37
    if(GA_Uses_fapi())GA_Error("Program runs with C array API only",1);
 
38
    printf("Using %ld processes\n",(long)nproc);
 
39
    fflush(stdout);
 
40
  }
 
41
 
 
42
  heap /= nproc;
 
43
  stack /= nproc;
 
44
  if(! MA_init(MT_F_DBL, stack, heap)) 
 
45
    GA_Error("MA_init failed",stack+heap);  /* initialize memory allocator*/ 
 
46
 
 
47
 
 
48
  /* This is a regular matrix. */
 
49
  if(me==0)printf("Creating matrix A\n");
 
50
  g_a = NGA_Create(type, 2, dims, "A", NULL);
 
51
  if(!g_a) GA_Error("create failed: A",n); 
 
52
  if(me==0)printf("OK\n");
 
53
  NGA_Distribution( g_a, me, lo, hi );
 
54
 
 
55
#if 1
 
56
  /* This is just allocating and freeing memory. */
 
57
  datatype = type;
 
58
  elements = 1;
 
59
  for ( i=0; i<2; i++ ) {
 
60
    elements *= (hi[i] - lo[i] + 1);
 
61
  }
 
62
  prealloc_mem = GA_Getmem(datatype, elements, 0);
 
63
  for ( i=0; i<elements; i++ ) prealloc_mem[i] = 3.141592654;
 
64
  GA_Freemem(prealloc_mem);
 
65
  if(me==0){printf("getmem&freemem OK\n"); fflush(stdout); }
 
66
#endif
 
67
 
 
68
  /* This is a matrix using preallocated memory. */
 
69
  datatype = type;
 
70
  elements = 1;
 
71
  for ( i=0; i<2; i++ ) {
 
72
    elements *= (hi[i] - lo[i] + 1);
 
73
  }
 
74
  prealloc_mem = GA_Getmem(datatype, elements, 0);
 
75
  g_b = GA_Assemble_duplicate(g_a, "Matrix B", (void*)prealloc_mem );
 
76
  if(GA_Compare_distr(g_a,g_b)){ 
 
77
     if(me==0){printf("GA_Assemble_duplicate failed\n"); fflush(stdout); }
 
78
  }else{
 
79
     if(me==0){printf("GA_Assemble_duplicate OK\n"); fflush(stdout); }
 
80
  }
 
81
  GA_Destroy(g_b);
 
82
 
 
83
  GA_Destroy(g_a);
 
84
  if(me==0)printf("\nSuccess\n");
 
85
  GA_Terminate();
 
86
 
 
87
  MP_FINALIZE();
 
88
 
 
89
 return 0;
 
90
}
 
91