2D_Scalar_CheckEquality_ReadAfterWrite.exa4 5.58 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// domain declarations

Domain global< [0.0, 0.0] to [1.0, 1.0] >

// field layout declarations

Layout NodeWithComm < Real, Node >@all {
  duplicateLayers = [1, 1] with communication
  ghostLayers     = [1, 1] with communication
}

// field declarations

Field src< global, NodeWithComm, None >@all
Field dest< global, NodeWithComm, None >@all

// globals

Globals {
  Val condition : Bool = true
  //Val condition : Bool = sqrt(4) == 2
  //Val condition : Bool = (i0+i1) % 2 == 0
}

// external field declarations

// stencil declarations

// stencil field declarations

// functions

Function compareFields@all () : Int {
  // check for equality
35
  loop over dest sequentially {
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
    Var diff : Real = fabs(dest - src)
    if( condition && diff > 0.001 ) {
      print("fields are not equal! src=", src, " dest=", dest)
      print("Error occurred at idx: i0 =", i0, ",i1 =", i1)
      return -1
    }
  }

  // reset dest
  loop over dest {
    dest = -1.0
  }
    
  return 0
}

Function initSRC@finest {
  loop over src {
    src = vf_nodePos_x**2 - vf_nodePos_y**2
  }
  
  loop over src only dup [0, 0, 0] {
    src = vf_nodePos_x**2 - vf_nodePos_y**2
  }
}

Function checkEquality@finest () : Unit {
  Val ret : Int = compareFields@finest ()
  if( ret == -1 ) {
    exit(1)
  }
}

Function Application {
  // init
  startTimer ( "setup" )
  initGlobals ( )
  initDomain ( )
  initFieldsWithZero ( )
  initGeometry ( )
  initSRC@finest ( )
  stopTimer ( "setup" )
  
  // arguments
  Val useGhost : Bool = true
  Val useBin : Bool = true
  Val useCanonicalLayout : Bool = true
  Val separator : String = ","
    
  // toggle I/O modes here
  Val lockingIO : Bool = true
  Val fppIO     : Bool = true
  Val hdfIO     : Bool = true
  Val mpiIO     : Bool = true
  Val ncIO      : Bool = true
  Val sionIO    : Bool = true
       
  if (lockingIO) {
    startTimer ("Lock: writeField")
95
    writeField_lock ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src_lock.txt", src@finest, useGhost, !useBin, condition, separator)
96
97
98
    stopTimer ("Lock: writeField")

    startTimer ("Lock: readField")
99
    readField_lock ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src_lock.txt", dest@finest, useGhost, !useBin, condition, separator)
100
101
102
103
104
105
    stopTimer ("Lock: readField")

    checkEquality@finest ()
    print ( 'Passed lock test' )

    // write csv for paraview
106
    //printField_lock ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src_vis.csv", src@finest, useGhost, !useBin, condition, separator)
107
108
109
110
  }
  
  if (fppIO) {
      startTimer ("FPP: writeField")
111
      writeField_fpp ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src_fpp_$blockId.bin", src@finest, useGhost, useBin, condition)
112
113
114
      stopTimer ("FPP: writeField")

      startTimer ("FPP: readField")
115
      readField_fpp ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src_fpp_$blockId.bin", dest@finest, useGhost, useBin, condition)
116
117
118
119
120
      stopTimer ("FPP: readField")
      
      checkEquality@finest ()
      print ( 'Passed fpp test' )
      
121
      // write xdmf file for paraview/visit
122
123
      //printField_fpp ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src_vis_fpp_bin.xmf", src@finest, useBin)
      //printField_fpp ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src_vis_fpp.xmf", src@finest)
124
125
126
127
  }
  
  if (hdfIO) {
    startTimer ("HDF5: writeField")
128
    writeField_hdf5 ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src.h5", "/test/abs/path/src", src@finest)
129
130
131
    stopTimer ("HDF5: writeField")

    startTimer ("HDF5: readField")
132
    readField_hdf5 ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src.h5", "/test/abs/path/src", dest@finest)
133
134
135
136
137
    stopTimer ("HDF5: readField")

    checkEquality@finest ()
    print ( 'Passed hdf5 test' )

138
    // write xdmf file for paraview/visit
139
    //printField_hdf5 ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src_vis_h5.xmf", src@finest, useCanonicalLayout)
140
141
142
143
144
  }
  
  if (mpiIO) {
    Val repr : String = "native"
    startTimer ("MPIIO: writeField")
145
    writeField_mpiio ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src.bin", src@finest, !useGhost, !useCanonicalLayout, repr)
146
147
148
    stopTimer ("MPIIO: writeField")

    startTimer ("MPIIO: readField")
149
    readField_mpiio ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src.bin", dest@finest, !useGhost, !useCanonicalLayout, repr)
150
151
152
153
154
    stopTimer ("MPIIO: readField")

    checkEquality@finest ()
    print ( 'Passed MPI I/O test' )

155
    // write xdmf file for paraview/visit
156
    //printField_mpiio ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src_vis_mpiio.xmf", src@finest, !useCanonicalLayout)
157
158
159
160
  }
  
  if (ncIO) {
    startTimer ("PnetCDF: writeField")
161
    writeField_nc ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src.nc", "field_src", src@finest, useGhost, !useCanonicalLayout)
162
163
164
    stopTimer ("PnetCDF: writeField")

    startTimer ("PnetCDF: readField")
165
    readField_nc ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src.nc", "field_src", dest@finest, useGhost, !useCanonicalLayout)
166
167
168
169
170
    stopTimer ("PnetCDF: readField")

    checkEquality@finest ()
    print ( 'Passed nc test' )

171
    // write nc file for paraview/visit
172
    //printField_nc ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src_vis.nc", src@finest, useCanonicalLayout)
173
174
175
176
177
  }
   
  
  if(sionIO) {
    startTimer ("SionLib: writeField")
178
    writeField_sion ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src.sion", src@finest, !useGhost, condition)
179
180
181
    stopTimer ("SionLib: writeField")

    startTimer ("SionLib: readField")
182
    readField_sion ("data/2D_Scalar_CheckEquality_ReadAfterWrite/src.sion", dest@finest, !useGhost, condition)
183
184
185
186
187
188
189
190
191
192
193
    stopTimer ("SionLib: readField")

    checkEquality@finest ()
    print ( 'Passed sion test' )
  }
  
  
  // de-init
  printAllTimers ( )
  destroyGlobals ( )
}