PyQUDA-Utils 0.9.9.dev5__tar.gz → 0.9.9.dev6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/PKG-INFO +1 -1
  2. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/PyQUDA_Utils.egg-info/PKG-INFO +1 -1
  3. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/PyQUDA_Utils.egg-info/SOURCES.txt +1 -0
  4. pyquda_utils-0.9.9.dev6/pyquda_utils/_version.py +1 -0
  5. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/io/__init__.py +41 -23
  6. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/io/chroma.py +21 -20
  7. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/io/kyu.py +13 -13
  8. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/io/lime.py +3 -0
  9. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/io/milc.py +29 -29
  10. pyquda_utils-0.9.9.dev6/pyquda_utils/io/mpi_file.py +77 -0
  11. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/io/nersc.py +7 -8
  12. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/io/npy.py +18 -17
  13. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/io/openqcd.py +10 -9
  14. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/io/xqcd.py +17 -15
  15. pyquda_utils-0.9.9.dev5/pyquda_utils/_version.py +0 -1
  16. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/LICENSE +0 -0
  17. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/MANIFEST.in +0 -0
  18. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/PyQUDA_Utils.egg-info/dependency_links.txt +0 -0
  19. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/PyQUDA_Utils.egg-info/requires.txt +0 -0
  20. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/PyQUDA_Utils.egg-info/top_level.txt +0 -0
  21. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/README.md +0 -0
  22. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyproject.toml +0 -0
  23. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/__init__.py +0 -0
  24. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/convert.py +0 -0
  25. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/core.py +0 -0
  26. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/deprecated.py +0 -0
  27. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/gamma.py +0 -0
  28. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/gpt.py +0 -0
  29. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/hmc_param.py +0 -0
  30. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/io/io_general.py +0 -0
  31. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/milc_rhmc_param.py +0 -0
  32. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/phase.py +0 -0
  33. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/quasi_axial_gauge_fixing.py +0 -0
  34. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/pyquda_utils/source.py +0 -0
  35. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/setup.cfg +0 -0
  36. {pyquda_utils-0.9.9.dev5 → pyquda_utils-0.9.9.dev6}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyQUDA-Utils
3
- Version: 0.9.9.dev5
3
+ Version: 0.9.9.dev6
4
4
  Summary: Utility scripts based on PyQUDA
5
5
  Author-email: SaltyChiang <SaltyChiang@users.noreply.github.com>
6
6
  Maintainer-email: SaltyChiang <SaltyChiang@users.noreply.github.com>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyQUDA-Utils
3
- Version: 0.9.9.dev5
3
+ Version: 0.9.9.dev6
4
4
  Summary: Utility scripts based on PyQUDA
5
5
  Author-email: SaltyChiang <SaltyChiang@users.noreply.github.com>
6
6
  Maintainer-email: SaltyChiang <SaltyChiang@users.noreply.github.com>
@@ -26,6 +26,7 @@ pyquda_utils/io/io_general.py
26
26
  pyquda_utils/io/kyu.py
27
27
  pyquda_utils/io/lime.py
28
28
  pyquda_utils/io/milc.py
29
+ pyquda_utils/io/mpi_file.py
29
30
  pyquda_utils/io/nersc.py
30
31
  pyquda_utils/io/npy.py
31
32
  pyquda_utils/io/openqcd.py
@@ -0,0 +1 @@
1
+ __version__ = "0.9.9.dev6"
@@ -70,23 +70,26 @@ def rotateToDeGrandRossi(propagator: LatticePropagator):
70
70
 
71
71
 
72
72
  def readChromaQIOGauge(filename: str, checksum: bool = True):
73
+ from pyquda import getGridSize
73
74
  from .chroma import readQIOGauge as read
74
75
 
75
- latt_size, gauge_raw = read(filename, checksum)
76
+ latt_size, gauge_raw = read(filename, getGridSize(), checksum)
76
77
  return LatticeGauge(LatticeInfo(latt_size), cb2(gauge_raw, [1, 2, 3, 4]))
77
78
 
78
79
 
79
80
  def readILDGBinGauge(filename: str, dtype: str, latt_size: List[int]):
81
+ from pyquda import getGridSize
80
82
  from .chroma import readILDGBinGauge as read
81
83
 
82
- gauge_raw = read(filename, dtype, latt_size)
84
+ gauge_raw = read(filename, dtype, latt_size, getGridSize())
83
85
  return LatticeGauge(LatticeInfo(latt_size), cb2(gauge_raw, [1, 2, 3, 4]))
84
86
 
85
87
 
86
88
  def readChromaQIOPropagator(filename: str, checksum: bool = True):
89
+ from pyquda import getGridSize
87
90
  from .chroma import readQIOPropagator as read
88
91
 
89
- latt_size, staggered, propagator_raw = read(filename, checksum)
92
+ latt_size, staggered, propagator_raw = read(filename, getGridSize(), checksum)
90
93
  if not staggered:
91
94
  return LatticePropagator(LatticeInfo(latt_size), cb2(propagator_raw, [0, 1, 2, 3]))
92
95
  else:
@@ -94,22 +97,24 @@ def readChromaQIOPropagator(filename: str, checksum: bool = True):
94
97
 
95
98
 
96
99
  def readMILCGauge(filename: str, checksum: bool = True):
100
+ from pyquda import getGridSize
97
101
  from .milc import readGauge as read
98
102
 
99
- latt_size, gauge_raw = read(filename, checksum)
103
+ latt_size, gauge_raw = read(filename, getGridSize(), checksum)
100
104
  return LatticeGauge(LatticeInfo(latt_size), cb2(gauge_raw, [1, 2, 3, 4]))
101
105
 
102
106
 
103
107
  def writeMILCGauge(filename: str, gauge: LatticeGauge):
104
108
  from .milc import writeGauge as write
105
109
 
106
- write(filename, gauge.latt_info.global_size, gauge.lexico())
110
+ write(filename, gauge.latt_info.global_size, gauge.latt_info.grid_size, gauge.lexico())
107
111
 
108
112
 
109
113
  def readMILCQIOPropagator(filename: str):
114
+ from pyquda import getGridSize
110
115
  from .milc import readQIOPropagator as read
111
116
 
112
- latt_size, staggered, propagator_raw = read(filename)
117
+ latt_size, staggered, propagator_raw = read(filename, getGridSize())
113
118
  if not staggered:
114
119
  return LatticePropagator(LatticeInfo(latt_size), cb2(propagator_raw, [0, 1, 2, 3]))
115
120
  else:
@@ -117,35 +122,42 @@ def readMILCQIOPropagator(filename: str):
117
122
 
118
123
 
119
124
  def readKYUGauge(filename: str, latt_size: List[int]):
125
+ from pyquda import getGridSize
120
126
  from .kyu import readGauge as read
121
127
 
122
- gauge_raw = read(filename, latt_size)
128
+ gauge_raw = read(filename, latt_size, getGridSize())
123
129
  return LatticeGauge(LatticeInfo(latt_size), cb2(gauge_raw, [1, 2, 3, 4]))
124
130
 
125
131
 
126
132
  def writeKYUGauge(filename: str, gauge: LatticeGauge):
127
133
  from .kyu import writeGauge as write
128
134
 
129
- write(filename, gauge.latt_info.global_size, gauge.lexico())
135
+ write(filename, gauge.latt_info.global_size, gauge.latt_info.grid_size, gauge.lexico())
130
136
 
131
137
 
132
138
  def readKYUPropagator(filename: str, latt_size: List[int]):
139
+ from pyquda import getGridSize
133
140
  from .kyu import readPropagator as read
134
141
 
135
- propagator_raw = read(filename, latt_size)
136
- return rotateToDeGrandRossi(LatticePropagator(LatticeInfo(latt_size), cb2(propagator_raw, [0, 1, 2, 3])))
142
+ propagator_raw = read(filename, latt_size, getGridSize())
143
+ propagator = LatticePropagator(LatticeInfo(latt_size), cb2(propagator_raw, [0, 1, 2, 3]))
144
+ propagator = rotateToDeGrandRossi(propagator)
145
+ return propagator
137
146
 
138
147
 
139
148
  def writeKYUPropagator(filename: str, propagator: LatticePropagator):
140
149
  from .kyu import writePropagator as write
141
150
 
142
- write(filename, propagator.latt_info.global_size, rotateToDiracPauli(propagator).lexico())
151
+ propagator = rotateToDiracPauli(propagator)
152
+ propagator_raw = propagator.lexico()
153
+ write(filename, propagator.latt_info.global_size, propagator.latt_info.grid_size, propagator_raw)
143
154
 
144
155
 
145
156
  def readXQCDPropagator(filename: str, latt_size: List[int], staggered: bool):
157
+ from pyquda import getGridSize
146
158
  from .xqcd import readPropagator as read
147
159
 
148
- propagator_raw = read(filename, latt_size, staggered)
160
+ propagator_raw = read(filename, latt_size, getGridSize(), staggered)
149
161
  if not staggered:
150
162
  return rotateToDeGrandRossi(LatticePropagator(LatticeInfo(latt_size), cb2(propagator_raw, [0, 1, 2, 3])))
151
163
  else:
@@ -156,19 +168,21 @@ def writeXQCDPropagator(filename: str, propagator: Union[LatticePropagator, Latt
156
168
  from .xqcd import writePropagator as write
157
169
 
158
170
  latt_size = propagator.latt_info.global_size
171
+ grid_size = propagator.latt_info.grid_size
159
172
  staggered = isinstance(propagator, LatticeStaggeredPropagator)
160
173
  if not staggered:
161
- write(filename, latt_size, rotateToDiracPauli(propagator).lexico(), staggered)
174
+ write(filename, latt_size, grid_size, rotateToDiracPauli(propagator).lexico(), staggered)
162
175
  else:
163
- write(filename, latt_size, propagator.lexico(), staggered)
176
+ write(filename, latt_size, grid_size, propagator.lexico(), staggered)
164
177
 
165
178
 
166
179
  def readXQCDPropagatorFast(filename: str, latt_size: List[int]):
180
+ from pyquda import getGridSize
167
181
  from .xqcd import readPropagatorFast as read
168
182
 
169
183
  latt_info = LatticeInfo(latt_size)
170
184
  Lx, Ly, Lz, Lt = latt_info.size
171
- propagator_raw = read(filename, latt_size)
185
+ propagator_raw = read(filename, getGridSize(), latt_size)
172
186
  propagator = LatticePropagator(latt_info, cb2(propagator_raw, [2, 3, 4, 5]))
173
187
  propagator.data = propagator.data.reshape(Ns, Nc, 2, Lt, Lz, Ly, Lx // 2, Ns, Nc)
174
188
  propagator.toDevice()
@@ -187,14 +201,15 @@ def writeXQCDPropagatorFast(filename: str, propagator: LatticePropagator):
187
201
  propagator.toHost()
188
202
  propagator.data = propagator.data.reshape(Ns, Nc, 2, Lt, Lz, Ly, Lx // 2, Ns, Nc)
189
203
  propagator_raw = lexico(propagator.data, [2, 3, 4, 5, 6])
190
- write(filename, latt_info.global_size, propagator_raw)
204
+ write(filename, latt_info.global_size, latt_info.grid_size, propagator_raw)
191
205
 
192
206
 
193
207
  def readNPYGauge(filename: str):
208
+ from pyquda import getGridSize
194
209
  from .npy import readGauge as read
195
210
 
196
211
  filename = filename if filename.endswith(".npy") else filename + ".npy"
197
- latt_size, gauge_raw = read(filename)
212
+ latt_size, gauge_raw = read(filename, getGridSize())
198
213
  return LatticeGauge(LatticeInfo(latt_size), cb2(gauge_raw, [1, 2, 3, 4]))
199
214
 
200
215
 
@@ -202,27 +217,29 @@ def writeNPYGauge(filename: str, gauge: LatticeGauge):
202
217
  from .npy import writeGauge as write
203
218
 
204
219
  filename = filename if filename.endswith(".npy") else filename + ".npy"
205
- write(filename, gauge.latt_info.global_size, gauge.lexico())
220
+ write(filename, gauge.latt_info.global_size, gauge.latt_info.grid_size, gauge.lexico())
206
221
 
207
222
 
208
223
  def readNPYPropagator(filename: str):
224
+ from pyquda import getGridSize
209
225
  from .npy import readPropagator as read
210
226
 
211
- latt_size, propagator_raw = read(filename)
227
+ latt_size, propagator_raw = read(filename, getGridSize())
212
228
  return LatticePropagator(LatticeInfo(latt_size), cb2(propagator_raw, [0, 1, 2, 3]))
213
229
 
214
230
 
215
231
  def writeNPYPropagator(filename: str, propagator: LatticePropagator):
216
232
  from .npy import writePropagator as write
217
233
 
218
- write(filename, propagator.latt_info.global_size, propagator.lexico())
234
+ write(filename, propagator.latt_info.global_size, propagator.latt_info.grid_size, propagator.lexico())
219
235
 
220
236
 
221
237
  def readOpenQCDGauge(filename: str):
238
+ from pyquda import getGridSize
222
239
  from pyquda.field import X, Y, Z, T
223
240
  from .openqcd import readGauge as read
224
241
 
225
- latt_size, plaquette, gauge_ = read(filename)
242
+ latt_size, plaquette, gauge_ = read(filename, getGridSize())
226
243
  gauge_ = LatticeGauge(LatticeInfo(latt_size), gauge_)
227
244
  gauge_.toDevice()
228
245
  gauge = gauge_.shift([X, Y, Z, T])
@@ -239,13 +256,14 @@ def writeOpenQCDGauge(filename: str, gauge: LatticeGauge):
239
256
  plaquette = gauge.plaquette()[0]
240
257
  gauge_ = gauge.shift([-X, -Y, -Z, -T])
241
258
  gauge_.data[:, 0] = gauge.data[:, 1]
242
- write(filename, gauge.latt_info.global_size, plaquette, gauge_.getHost())
259
+ write(filename, gauge.latt_info.global_size, gauge.latt_info.grid_size, plaquette, gauge_.getHost())
243
260
 
244
261
 
245
262
  def readNERSCGauge(filename: str, return_plaquette: bool = False, link_trace: bool = True, checksum: bool = True):
263
+ from pyquda import getGridSize
246
264
  from .nersc import readGauge as read
247
265
 
248
- latt_size, plaquette, gauge_raw = read(filename, link_trace, checksum)
266
+ latt_size, plaquette, gauge_raw = read(filename, getGridSize(), link_trace, checksum)
249
267
  if not return_plaquette:
250
268
  return LatticeGauge(LatticeInfo(latt_size), cb2(gauge_raw, [1, 2, 3, 4]))
251
269
  else:
@@ -2,19 +2,20 @@ from os import path
2
2
  from typing import List
3
3
  from xml.etree import ElementTree as ET
4
4
 
5
- from pyquda import getSublatticeSize, getMPIComm, getGridCoord, readMPIFile
5
+ from mpi4py import MPI
6
+
7
+ from .mpi_file import getSublatticeSize, getGridCoord, readMPIFile
6
8
 
7
9
  Nd, Ns, Nc = 4, 4, 3
8
10
  _precision_map = {"D": 8, "F": 4, "S": 4}
9
11
 
10
12
 
11
- def checksum_qio(latt_size: List[int], data):
13
+ def checksum_qio(latt_size: List[int], grid_size: List[int], data):
12
14
  import zlib
13
15
  import numpy
14
- from mpi4py import MPI
15
16
 
16
- gx, gy, gz, gt = getGridCoord()
17
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
17
+ gx, gy, gz, gt = getGridCoord(grid_size)
18
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
18
19
  gLx, gLy, gLz, gLt = gx * Lx, gy * Ly, gz * Lz, gt * Lt
19
20
  GLx, GLy, GLz, GLt = latt_size
20
21
  work = numpy.empty((Lt * Lz * Ly * Lx), "<u4")
@@ -27,12 +28,12 @@ def checksum_qio(latt_size: List[int], data):
27
28
  )
28
29
  rank29 = (rank % 29).astype("<u4")
29
30
  rank31 = (rank % 31).astype("<u4")
30
- sum29 = getMPIComm().allreduce(numpy.bitwise_xor.reduce(work << rank29 | work >> (32 - rank29)), MPI.BXOR)
31
- sum31 = getMPIComm().allreduce(numpy.bitwise_xor.reduce(work << rank31 | work >> (32 - rank31)), MPI.BXOR)
31
+ sum29 = MPI.COMM_WORLD.allreduce(numpy.bitwise_xor.reduce(work << rank29 | work >> (32 - rank29)), MPI.BXOR)
32
+ sum31 = MPI.COMM_WORLD.allreduce(numpy.bitwise_xor.reduce(work << rank31 | work >> (32 - rank31)), MPI.BXOR)
32
33
  return sum29, sum31
33
34
 
34
35
 
35
- def readQIOGauge(filename: str, checksum: bool = True):
36
+ def readQIOGauge(filename: str, grid_size: List[int], checksum: bool = True):
36
37
  from .lime import Lime
37
38
 
38
39
  lime = Lime(filename)
@@ -55,12 +56,12 @@ def readQIOGauge(filename: str, checksum: bool = True):
55
56
  assert int(scidac_private_record_xml.find("datacount").text) == Nd
56
57
  assert int(scidac_private_file_xml.find("spacetime").text) == Nd
57
58
  latt_size = [int(L) for L in scidac_private_file_xml.find("dims").text.split()]
58
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
59
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
59
60
  dtype = f">c{2 * precision}"
60
61
 
61
- gauge = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nd, Nc, Nc), (3, 2, 1, 0))
62
+ gauge = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nd, Nc, Nc), (3, 2, 1, 0), grid_size)
62
63
  if checksum:
63
- assert checksum_qio(latt_size, gauge.reshape(Lt * Lz * Ly * Lx, Nd * Nc * Nc)) == (
64
+ assert checksum_qio(latt_size, grid_size, gauge.reshape(Lt * Lz * Ly * Lx, Nd * Nc * Nc)) == (
64
65
  int(scidac_checksum_xml.find("suma").text, 16),
65
66
  int(scidac_checksum_xml.find("sumb").text, 16),
66
67
  ), f"Bad checksum for {filename}"
@@ -68,17 +69,17 @@ def readQIOGauge(filename: str, checksum: bool = True):
68
69
  return latt_size, gauge
69
70
 
70
71
 
71
- def readILDGBinGauge(filename: str, dtype: str, latt_size: List[int]):
72
+ def readILDGBinGauge(filename: str, dtype: str, latt_size: List[int], grid_size: List[int]):
72
73
  filename = path.expanduser(path.expandvars(filename))
73
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
74
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
74
75
  offset = 0
75
76
 
76
- gauge = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nd, Nc, Nc), (3, 2, 1, 0))
77
+ gauge = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nd, Nc, Nc), (3, 2, 1, 0), grid_size)
77
78
  gauge = gauge.transpose(4, 0, 1, 2, 3, 5, 6).astype("<c16")
78
79
  return gauge
79
80
 
80
81
 
81
- def readQIOPropagator(filename: str, checksum: bool = True):
82
+ def readQIOPropagator(filename: str, grid_size: List[int], checksum: bool = True):
82
83
  from .lime import Lime
83
84
 
84
85
  lime = Lime(filename)
@@ -107,21 +108,21 @@ def readQIOPropagator(filename: str, checksum: bool = True):
107
108
  assert int(scidac_private_record_xml.find("datacount").text) == 1
108
109
  assert int(scidac_private_file_xml.find("spacetime").text) == Nd
109
110
  latt_size = [int(L) for L in scidac_private_file_xml.find("dims").text.split()]
110
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
111
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
111
112
  dtype = f">c{2 * precision}"
112
113
 
113
114
  if not staggered:
114
- propagator = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Ns, Ns, Nc, Nc), (3, 2, 1, 0))
115
+ propagator = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Ns, Ns, Nc, Nc), (3, 2, 1, 0), grid_size)
115
116
  if checksum:
116
- assert checksum_qio(latt_size, propagator.reshape(Lt * Lz * Ly * Lx, Ns * Ns * Nc * Nc)) == (
117
+ assert checksum_qio(latt_size, grid_size, propagator.reshape(Lt * Lz * Ly * Lx, Ns * Ns * Nc * Nc)) == (
117
118
  int(scidac_checksum_xml.find("suma").text, 16),
118
119
  int(scidac_checksum_xml.find("sumb").text, 16),
119
120
  ), f"Bad checksum for {filename}"
120
121
  propagator = propagator.astype("<c16")
121
122
  else:
122
- propagator = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nc, Nc), (3, 2, 1, 0))
123
+ propagator = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nc, Nc), (3, 2, 1, 0), grid_size)
123
124
  if checksum:
124
- assert checksum_qio(latt_size, propagator.reshape(Lt * Lz * Ly * Lx, Nc * Nc)) == (
125
+ assert checksum_qio(latt_size, grid_size, propagator.reshape(Lt * Lz * Ly * Lx, Nc * Nc)) == (
125
126
  int(scidac_checksum_xml.find("suma").text, 16),
126
127
  int(scidac_checksum_xml.find("sumb").text, 16),
127
128
  ), f"Bad checksum for {filename}"
@@ -3,17 +3,17 @@ from typing import List
3
3
 
4
4
  import numpy
5
5
 
6
- from pyquda import getSublatticeSize, readMPIFile, writeMPIFile
6
+ from .mpi_file import getSublatticeSize, readMPIFile, writeMPIFile
7
7
 
8
8
  Nd, Ns, Nc = 4, 4, 3
9
9
 
10
10
 
11
- def readGauge(filename: str, latt_size: List[int]):
11
+ def readGauge(filename: str, latt_size: List[int], grid_size: List[int]):
12
12
  filename = path.expanduser(path.expandvars(filename))
13
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
13
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
14
14
  dtype, offset = ">f8", 0
15
15
 
16
- gauge = readMPIFile(filename, dtype, offset, (Nd, Nc, Nc, 2, Lt, Lz, Ly, Lx), (7, 6, 5, 4))
16
+ gauge = readMPIFile(filename, dtype, offset, (Nd, Nc, Nc, 2, Lt, Lz, Ly, Lx), (7, 6, 5, 4), grid_size)
17
17
  gauge = (
18
18
  gauge.transpose(0, 4, 5, 6, 7, 2, 1, 3)
19
19
  .astype("<f8")
@@ -24,23 +24,23 @@ def readGauge(filename: str, latt_size: List[int]):
24
24
  return gauge
25
25
 
26
26
 
27
- def writeGauge(filename: str, latt_size: List[int], gauge: numpy.ndarray):
27
+ def writeGauge(filename: str, latt_size: List[int], grid_size: List[int], gauge: numpy.ndarray):
28
28
  filename = path.expanduser(path.expandvars(filename))
29
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
29
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
30
30
  dtype, offset = ">f8", 0
31
31
 
32
32
  gauge = (
33
33
  gauge.view("<f8").reshape(Nd, Lt, Lz, Ly, Lx, Nc, Nc, 2).astype(dtype).transpose(0, 6, 5, 7, 1, 2, 3, 4).copy()
34
34
  )
35
- writeMPIFile(filename, dtype, offset, (Nd, Nc, Nc, 2, Lt, Lz, Ly, Lx), (7, 6, 5, 4), gauge)
35
+ writeMPIFile(filename, dtype, offset, (Nd, Nc, Nc, 2, Lt, Lz, Ly, Lx), (7, 6, 5, 4), grid_size, gauge)
36
36
 
37
37
 
38
- def readPropagator(filename: str, latt_size: List[int]):
38
+ def readPropagator(filename: str, latt_size: List[int], grid_size: List[int]):
39
39
  filename = path.expanduser(path.expandvars(filename))
40
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
40
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
41
41
  dtype, offset = ">f8", 0
42
42
 
43
- propagator = readMPIFile(filename, dtype, offset, (Ns, Nc, 2, Ns, Nc, Lt, Lz, Ly, Lx), (8, 7, 6, 5))
43
+ propagator = readMPIFile(filename, dtype, offset, (Ns, Nc, 2, Ns, Nc, Lt, Lz, Ly, Lx), (8, 7, 6, 5), grid_size)
44
44
  propagator = (
45
45
  propagator.transpose(5, 6, 7, 8, 3, 0, 4, 1, 2)
46
46
  .astype("<f8")
@@ -51,9 +51,9 @@ def readPropagator(filename: str, latt_size: List[int]):
51
51
  return propagator
52
52
 
53
53
 
54
- def writePropagator(filename: str, latt_size: List[int], propagator: numpy.ndarray):
54
+ def writePropagator(filename: str, latt_size: List[int], grid_size: List[int], propagator: numpy.ndarray):
55
55
  filename = path.expanduser(path.expandvars(filename))
56
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
56
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
57
57
  dtype, offset = ">f8", 0
58
58
 
59
59
  propagator = (
@@ -63,4 +63,4 @@ def writePropagator(filename: str, latt_size: List[int], propagator: numpy.ndarr
63
63
  .transpose(5, 7, 8, 4, 6, 0, 1, 2, 3)
64
64
  .copy()
65
65
  )
66
- writeMPIFile(filename, dtype, offset, (Ns, Nc, 2, Ns, Nc, Lt, Lz, Ly, Lx), (8, 7, 6, 5), propagator)
66
+ writeMPIFile(filename, dtype, offset, (Ns, Nc, 2, Ns, Nc, Lt, Lz, Ly, Lx), (8, 7, 6, 5), grid_size, propagator)
@@ -24,6 +24,9 @@ class Lime:
24
24
  f.seek((length + 7) // 8 * 8, io.SEEK_CUR)
25
25
  buffer = f.read(8)
26
26
 
27
+ def keys(self):
28
+ return [record.name for record in self._records]
29
+
27
30
  def records(self, key: str):
28
31
  return [record for record in self._records if record.name == key]
29
32
 
@@ -5,40 +5,38 @@ from typing import List
5
5
  from xml.etree import ElementTree as ET
6
6
 
7
7
  import numpy
8
+ from mpi4py import MPI
8
9
 
9
- from pyquda import getSublatticeSize, getMPIComm, getMPISize, getMPIRank, getGridCoord, readMPIFile, writeMPIFile
10
+ from .mpi_file import getGridCoord, getSublatticeSize, readMPIFile, writeMPIFile
10
11
 
11
12
  Nd, Ns, Nc = 4, 4, 3
12
13
  _precision_map = {"D": 8, "F": 4, "S": 4}
13
14
 
14
15
 
15
- def checksum_milc(latt_size: List[int], data):
16
- from mpi4py import MPI
17
-
18
- gx, gy, gz, gt = getGridCoord()
19
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
16
+ def checksum_milc(latt_size: List[int], grid_size: List[int], data):
17
+ gx, gy, gz, gt = getGridCoord(grid_size)
18
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
20
19
  gLx, gLy, gLz, gLt = gx * Lx, gy * Ly, gz * Lz, gt * Lt
21
20
  GLx, GLy, GLz, GLt = latt_size
22
21
 
23
22
  work = data.view("<u4")
24
23
  rank = (
25
- numpy.arange(getMPISize() * work.size, dtype="<u8")
24
+ numpy.arange(MPI.COMM_WORLD.Get_size() * work.size, dtype="<u8")
26
25
  .reshape(GLt, GLz, GLy, GLx, -1)[gLt : gLt + Lt, gLz : gLz + Lz, gLy : gLy + Ly, gLx : gLx + Lx]
27
26
  .reshape(-1)
28
27
  )
29
28
  rank29 = (rank % 29).astype("<u4")
30
29
  rank31 = (rank % 31).astype("<u4")
31
- sum29 = getMPIComm().allreduce(numpy.bitwise_xor.reduce(work << rank29 | work >> (32 - rank29)), MPI.BXOR)
32
- sum31 = getMPIComm().allreduce(numpy.bitwise_xor.reduce(work << rank31 | work >> (32 - rank31)), MPI.BXOR)
30
+ sum29 = MPI.COMM_WORLD.allreduce(numpy.bitwise_xor.reduce(work << rank29 | work >> (32 - rank29)), MPI.BXOR)
31
+ sum31 = MPI.COMM_WORLD.allreduce(numpy.bitwise_xor.reduce(work << rank31 | work >> (32 - rank31)), MPI.BXOR)
33
32
  return sum29, sum31
34
33
 
35
34
 
36
- def checksum_qio(latt_size: List[int], data):
35
+ def checksum_qio(latt_size: List[int], grid_size: List[int], data):
37
36
  import zlib
38
- from mpi4py import MPI
39
37
 
40
- gx, gy, gz, gt = getGridCoord()
41
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
38
+ gx, gy, gz, gt = getGridCoord(grid_size)
39
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
42
40
  gLx, gLy, gLz, gLt = gx * Lx, gy * Ly, gz * Lz, gt * Lt
43
41
  GLx, GLy, GLz, GLt = latt_size
44
42
  work = numpy.empty((Lt * Lz * Ly * Lx), "<u4")
@@ -51,12 +49,12 @@ def checksum_qio(latt_size: List[int], data):
51
49
  )
52
50
  rank29 = rank % 29
53
51
  rank31 = rank % 31
54
- sum29 = getMPIComm().allreduce(numpy.bitwise_xor.reduce(work << rank29 | work >> (32 - rank29)), MPI.BXOR)
55
- sum31 = getMPIComm().allreduce(numpy.bitwise_xor.reduce(work << rank31 | work >> (32 - rank31)), MPI.BXOR)
52
+ sum29 = MPI.COMM_WORLD.allreduce(numpy.bitwise_xor.reduce(work << rank29 | work >> (32 - rank29)), MPI.BXOR)
53
+ sum31 = MPI.COMM_WORLD.allreduce(numpy.bitwise_xor.reduce(work << rank31 | work >> (32 - rank31)), MPI.BXOR)
56
54
  return sum29, sum31
57
55
 
58
56
 
59
- def readGauge(filename: str, checksum: bool = True):
57
+ def readGauge(filename: str, grid_size: List[int], checksum: bool = True):
60
58
  filename = path.expanduser(path.expandvars(filename))
61
59
  with open(filename, "rb") as f:
62
60
  magic = f.read(4)
@@ -70,12 +68,12 @@ def readGauge(filename: str, checksum: bool = True):
70
68
  assert struct.unpack(f"{endian}i", f.read(4))[0] == 0 # order
71
69
  sum29, sum31 = struct.unpack(f"{endian}II", f.read(8))
72
70
  offset = f.tell()
73
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
71
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
74
72
  dtype = f"{endian}c8"
75
73
 
76
- gauge = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nd, Nc, Nc), (3, 2, 1, 0))
74
+ gauge = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nd, Nc, Nc), (3, 2, 1, 0), grid_size)
77
75
  if checksum:
78
- assert checksum_milc(latt_size, gauge.astype("<c8").reshape(-1)) == (
76
+ assert checksum_milc(latt_size, grid_size, gauge.astype("<c8").reshape(-1)) == (
79
77
  sum29,
80
78
  sum31,
81
79
  ), f"Bad checksum for {filename}"
@@ -83,14 +81,14 @@ def readGauge(filename: str, checksum: bool = True):
83
81
  return latt_size, gauge
84
82
 
85
83
 
86
- def writeGauge(filename: str, latt_size: List[int], gauge: numpy.ndarray):
84
+ def writeGauge(filename: str, latt_size: List[int], grid_size: List[int], gauge: numpy.ndarray):
87
85
  filename = path.expanduser(path.expandvars(filename))
88
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
86
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
89
87
  dtype, offset = "<c8", None
90
88
 
91
89
  gauge = numpy.ascontiguousarray(gauge.transpose(1, 2, 3, 4, 0, 5, 6).astype(dtype))
92
- sum29, sum31 = checksum_milc(latt_size, gauge.reshape(-1))
93
- if getMPIRank() == 0:
90
+ sum29, sum31 = checksum_milc(latt_size, grid_size, gauge.reshape(-1))
91
+ if MPI.COMM_WORLD.Get_rank() == 0:
94
92
  with open(filename, "wb") as f:
95
93
  f.write(struct.pack("<i", 20103))
96
94
  f.write(struct.pack("<iiii", *latt_size))
@@ -98,12 +96,12 @@ def writeGauge(filename: str, latt_size: List[int], gauge: numpy.ndarray):
98
96
  f.write(struct.pack("<i", 0)) # order
99
97
  f.write(struct.pack("<II", sum29, sum31))
100
98
  offset = f.tell()
101
- offset = getMPIComm().bcast(offset)
99
+ offset = MPI.COMM_WORLD.bcast(offset)
102
100
 
103
- writeMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nd, Nc, Nc), (3, 2, 1, 0), gauge)
101
+ writeMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nd, Nc, Nc), (3, 2, 1, 0), grid_size, gauge)
104
102
 
105
103
 
106
- def readQIOPropagator(filename: str):
104
+ def readQIOPropagator(filename: str, grid_size: List[int]):
107
105
  from .lime import Lime
108
106
 
109
107
  lime = Lime(filename)
@@ -129,7 +127,7 @@ def readQIOPropagator(filename: str):
129
127
  assert int(scidac_private_record_xml.find("datacount").text) == 1
130
128
  assert int(scidac_private_file_xml.find("spacetime").text) == Nd
131
129
  latt_size = [int(L) for L in scidac_private_file_xml.find("dims").text.split()]
132
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
130
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
133
131
  dtype = f">c{2 * precision}"
134
132
 
135
133
  if not staggered:
@@ -137,12 +135,14 @@ def readQIOPropagator(filename: str):
137
135
  for spin in range(Ns):
138
136
  for color in range(Nc):
139
137
  propagator[spin, color] = readMPIFile(
140
- filename, dtype, offset[spin * Nc + color], (Lt, Lz, Ly, Lx, Ns, Nc), (3, 2, 1, 0)
138
+ filename, dtype, offset[spin * Nc + color], (Lt, Lz, Ly, Lx, Ns, Nc), (3, 2, 1, 0), grid_size
141
139
  )
142
140
  propagator = propagator.transpose(2, 3, 4, 5, 6, 0, 7, 1).astype("<c16")
143
141
  else:
144
142
  propagator = numpy.empty((Nc, Lt, Lz, Ly, Lx, Nc), dtype)
145
143
  for color in range(Nc):
146
- propagator[color] = readMPIFile(filename, dtype, offset[color], (Lt, Lz, Ly, Lx, Nc), (3, 2, 1, 0))
144
+ propagator[color] = readMPIFile(
145
+ filename, dtype, offset[color], (Lt, Lz, Ly, Lx, Nc), (3, 2, 1, 0), grid_size
146
+ )
147
147
  propagator = propagator.transpose(1, 2, 3, 4, 5, 0).astype("<c16")
148
148
  return latt_size, staggered, propagator
@@ -0,0 +1,77 @@
1
+ from typing import Sequence
2
+
3
+ import numpy
4
+ from mpi4py import MPI
5
+ from mpi4py.util import dtlib
6
+
7
+
8
+ def getSublatticeSize(latt_size: Sequence[int], grid_size: Sequence[int]):
9
+ GLx, GLy, GLz, GLt = latt_size
10
+ Gx, Gy, Gz, Gt = grid_size
11
+ assert GLx % Gx == 0 and GLy % Gy == 0 and GLz % Gz == 0 and GLt % Gt == 0
12
+ return [GLx // Gx, GLy // Gy, GLz // Gz, GLt // Gt]
13
+
14
+
15
+ def getGridCoord(grid_size: Sequence[int]):
16
+ rank = MPI.COMM_WORLD.Get_rank()
17
+ Gx, Gy, Gz, Gt = grid_size
18
+ gx, gy, gz, gt = rank // Gt // Gz // Gy % Gx, rank // Gt // Gz % Gy, rank // Gt % Gz, rank % Gt
19
+ return [gx, gy, gz, gt]
20
+
21
+
22
+ def getSubarray(shape: Sequence[int], axes: Sequence[int], grid: Sequence[int]):
23
+ sizes = [d for d in shape]
24
+ subsizes = [d for d in shape]
25
+ starts = [d if i in axes else 0 for i, d in enumerate(shape)]
26
+ coord = getGridCoord(grid)
27
+ for j, i in enumerate(axes):
28
+ sizes[i] *= grid[j]
29
+ starts[i] *= coord[j]
30
+ return sizes, subsizes, starts
31
+
32
+
33
+ def readMPIFile(
34
+ filename: str,
35
+ dtype: str,
36
+ offset: int,
37
+ shape: Sequence[int],
38
+ axes: Sequence[int],
39
+ grid: Sequence[int],
40
+ ):
41
+ assert MPI.COMM_WORLD.Get_size() == int(numpy.prod(grid))
42
+ sizes, subsizes, starts = getSubarray(shape, axes, grid)
43
+ native_dtype = dtype if not dtype.startswith(">") else dtype.replace(">", "<")
44
+ buf = numpy.empty(subsizes, native_dtype)
45
+
46
+ fh = MPI.File.Open(MPI.COMM_WORLD, filename, MPI.MODE_RDONLY)
47
+ filetype = dtlib.from_numpy_dtype(native_dtype).Create_subarray(sizes, subsizes, starts)
48
+ filetype.Commit()
49
+ fh.Set_view(disp=offset, filetype=filetype)
50
+ fh.Read_all(buf)
51
+ filetype.Free()
52
+ fh.Close()
53
+
54
+ return buf.view(dtype)
55
+
56
+
57
+ def writeMPIFile(
58
+ filename: str,
59
+ dtype: str,
60
+ offset: int,
61
+ shape: Sequence[int],
62
+ axes: Sequence[int],
63
+ grid: Sequence[int],
64
+ buf: numpy.ndarray,
65
+ ):
66
+ assert MPI.COMM_WORLD.Get_size() == int(numpy.prod(grid))
67
+ sizes, subsizes, starts = getSubarray(shape, axes, grid)
68
+ native_dtype = dtype if not dtype.startswith(">") else dtype.replace(">", "<")
69
+ buf = buf.view(native_dtype)
70
+
71
+ fh = MPI.File.Open(MPI.COMM_WORLD, filename, MPI.MODE_WRONLY | MPI.MODE_CREATE)
72
+ filetype = dtlib.from_numpy_dtype(native_dtype).Create_subarray(sizes, subsizes, starts)
73
+ filetype.Commit()
74
+ fh.Set_view(disp=offset, filetype=filetype)
75
+ fh.Write_all(buf)
76
+ filetype.Free()
77
+ fh.Close()
@@ -1,20 +1,19 @@
1
1
  from os import path
2
- from typing import Dict
2
+ from typing import Dict, List
3
3
 
4
4
  import numpy
5
+ from mpi4py import MPI
5
6
 
6
- from pyquda import getSublatticeSize, readMPIFile, writeMPIFile, getMPIComm, getMPIRank
7
+ from .mpi_file import getSublatticeSize, readMPIFile, writeMPIFile
7
8
 
8
9
  Nd, Ns, Nc = 4, 4, 3
9
10
 
10
11
 
11
12
  def checksum_nersc(data: numpy.ndarray) -> int:
12
- from mpi4py import MPI
13
+ return MPI.COMM_WORLD.allreduce(numpy.sum(data.view("<u4"), dtype="<u4"), MPI.SUM)
13
14
 
14
- return getMPIComm().allreduce(numpy.sum(data.view("<u4"), dtype="<u4"), MPI.SUM)
15
15
 
16
-
17
- def readGauge(filename: str, link_trace: bool = True, checksum: bool = True):
16
+ def readGauge(filename: str, grid_size: List[int], link_trace: bool = True, checksum: bool = True):
18
17
  filename = path.expanduser(path.expandvars(filename))
19
18
  header: Dict[str, str] = {}
20
19
  with open(filename, "rb") as f:
@@ -31,7 +30,7 @@ def readGauge(filename: str, link_trace: bool = True, checksum: bool = True):
31
30
  int(header["DIMENSION_3"]),
32
31
  int(header["DIMENSION_4"]),
33
32
  ]
34
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
33
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
35
34
  assert header["FLOATING_POINT"].startswith("IEEE")
36
35
  if header["FLOATING_POINT"][6:] == "BIG":
37
36
  endian = ">"
@@ -44,7 +43,7 @@ def readGauge(filename: str, link_trace: bool = True, checksum: bool = True):
44
43
  plaquette = float(header["PLAQUETTE"])
45
44
 
46
45
  if header["DATATYPE"] == "4D_SU3_GAUGE_3x3":
47
- gauge = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nd, Nc, Nc), (3, 2, 1, 0))
46
+ gauge = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Nd, Nc, Nc), (3, 2, 1, 0), grid_size)
48
47
  if link_trace:
49
48
  assert numpy.isclose(
50
49
  numpy.einsum("tzyxdaa->", gauge.real) / (gauge.size // Nc), float(header["LINK_TRACE"])
@@ -3,8 +3,9 @@ from typing import List
3
3
 
4
4
  import numpy
5
5
  from numpy.lib.format import dtype_to_descr, read_magic, read_array_header_1_0, write_array_header_1_0
6
+ from mpi4py import MPI
6
7
 
7
- from pyquda import getSublatticeSize, getMPIComm, getMPIRank, readMPIFile, writeMPIFile
8
+ from .mpi_file import getSublatticeSize, readMPIFile, writeMPIFile
8
9
 
9
10
  Nd, Ns, Nc = 4, 4, 3
10
11
 
@@ -19,49 +20,49 @@ def _readHeader(filename: str):
19
20
  return shape, dtype, offset
20
21
 
21
22
 
22
- def readGauge(filename: str):
23
+ def readGauge(filename: str, grid_size: List[int]):
23
24
  filename = path.expanduser(path.expandvars(filename))
24
25
  shape, dtype, offset = _readHeader(filename)
25
26
  latt_size = [shape[i] for i in [4, 3, 2, 1]]
26
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
27
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
27
28
 
28
- gauge = readMPIFile(filename, dtype, offset, (Nd, Lt, Lz, Ly, Lx, Nc, Nc), (4, 3, 2, 1))
29
+ gauge = readMPIFile(filename, dtype, offset, (Nd, Lt, Lz, Ly, Lx, Nc, Nc), (4, 3, 2, 1), grid_size)
29
30
  return latt_size, gauge
30
31
 
31
32
 
32
- def writeGauge(filename: str, latt_size: List[int], gauge: numpy.ndarray):
33
+ def writeGauge(filename: str, latt_size: List[int], grid_size: List[int], gauge: numpy.ndarray):
33
34
  filename = path.expanduser(path.expandvars(filename))
34
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
35
- if getMPIRank() == 0:
35
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
36
+ if MPI.COMM_WORLD.Get_rank() == 0:
36
37
  with open(filename, "wb") as f:
37
38
  write_array_header_1_0(
38
39
  f, {"shape": (Nd, *latt_size[::-1], Nc, Nc), "fortran_order": False, "descr": "<c16"}
39
40
  )
40
- getMPIComm().Barrier()
41
+ MPI.COMM_WORLD.Barrier()
41
42
  shape, dtype, offset = _readHeader(filename)
42
43
 
43
- writeMPIFile(filename, dtype, offset, (Nd, Lt, Lz, Ly, Lx, Nc, Nc), (4, 3, 2, 1), gauge)
44
+ writeMPIFile(filename, dtype, offset, (Nd, Lt, Lz, Ly, Lx, Nc, Nc), (4, 3, 2, 1), grid_size, gauge)
44
45
 
45
46
 
46
- def readPropagator(filename: str):
47
+ def readPropagator(filename: str, grid_size: List[int]):
47
48
  filename = path.expanduser(path.expandvars(filename))
48
49
  shape, dtype, offset = _readHeader(filename)
49
50
  latt_size = [shape[i] for i in [3, 2, 1, 0]]
50
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
51
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
51
52
 
52
- propagator = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Ns, Ns, Nc, Nc), (3, 2, 1, 0))
53
+ propagator = readMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Ns, Ns, Nc, Nc), (3, 2, 1, 0), grid_size)
53
54
  return latt_size, propagator
54
55
 
55
56
 
56
- def writePropagator(filename: str, latt_size: List[int], propagator: numpy.ndarray):
57
+ def writePropagator(filename: str, latt_size: List[int], grid_size: List[int], propagator: numpy.ndarray):
57
58
  filename = path.expanduser(path.expandvars(filename))
58
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
59
- if getMPIRank() == 0:
59
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
60
+ if MPI.COMM_WORLD.Get_rank() == 0:
60
61
  with open(filename, "wb") as f:
61
62
  write_array_header_1_0(
62
63
  f, {"shape": (*latt_size[::-1], Ns, Ns, Nc, Nc), "fortran_order": False, "descr": "<c16"}
63
64
  )
64
- getMPIComm().Barrier()
65
+ MPI.COMM_WORLD.Barrier()
65
66
  shape, dtype, offset = _readHeader(filename)
66
67
 
67
- writeMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Ns, Ns, Nc, Nc), (3, 2, 1, 0), propagator)
68
+ writeMPIFile(filename, dtype, offset, (Lt, Lz, Ly, Lx, Ns, Ns, Nc, Nc), (3, 2, 1, 0), grid_size, propagator)
@@ -3,22 +3,23 @@ import struct
3
3
  from typing import List
4
4
 
5
5
  import numpy
6
+ from mpi4py import MPI
6
7
 
7
- from pyquda import getSublatticeSize, getMPIRank, getMPIComm, readMPIFile, writeMPIFile
8
+ from .mpi_file import getSublatticeSize, readMPIFile, writeMPIFile
8
9
 
9
10
  Nd, Ns, Nc = 4, 4, 3
10
11
 
11
12
 
12
- def readGauge(filename: str):
13
+ def readGauge(filename: str, grid_size: List[int]):
13
14
  filename = path.expanduser(path.expandvars(filename))
14
15
  with open(filename, "rb") as f:
15
16
  latt_size = struct.unpack("<iiii", f.read(16))[::-1]
16
17
  plaquette = struct.unpack("<d", f.read(8))[0] / Nc
17
18
  offset = f.tell()
18
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
19
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
19
20
  dtype = "<c16"
20
21
 
21
- gauge_reorder = readMPIFile(filename, dtype, offset, (Lt, Lx, Ly, Lz // 2, Nd, 2, Nc, Nc), (1, 2, 3, 0))
22
+ gauge_reorder = readMPIFile(filename, dtype, offset, (Lt, Lx, Ly, Lz // 2, Nd, 2, Nc, Nc), (1, 2, 3, 0), grid_size)
22
23
 
23
24
  gauge = numpy.zeros((Nd, 2, Lt, Lz, Ly, Lx // 2, Nc, Nc), dtype="<c16")
24
25
  for t in range(Lt):
@@ -33,9 +34,9 @@ def readGauge(filename: str):
33
34
  return latt_size, plaquette, gauge
34
35
 
35
36
 
36
- def writeGauge(filename: str, latt_size: List[int], plaquette: float, gauge: numpy.ndarray):
37
+ def writeGauge(filename: str, latt_size: List[int], grid_size: List[int], plaquette: float, gauge: numpy.ndarray):
37
38
  filename = path.expanduser(path.expandvars(filename))
38
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
39
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
39
40
  dtype, offset = "<c16", None
40
41
 
41
42
  gauge_reorder = numpy.zeros((Lt, Lx, Ly, Lz // 2, Nd, 2, Nc, Nc), dtype="<c16")
@@ -48,11 +49,11 @@ def writeGauge(filename: str, latt_size: List[int], plaquette: float, gauge: num
48
49
  gauge_reorder[t, x_, y, z_] = gauge[[3, 0, 1, 2], :, t, z, y, x, :, :]
49
50
 
50
51
  gauge = gauge_reorder.astype(dtype)
51
- if getMPIRank() == 0:
52
+ if MPI.COMM_WORLD.Get_rank() == 0:
52
53
  with open(filename, "wb") as f:
53
54
  f.write(struct.pack("<iiii", *latt_size[::-1]))
54
55
  f.write(struct.pack("<d", plaquette * Nc))
55
56
  offset = f.tell()
56
- offset = getMPIComm().bcast(offset)
57
+ offset = MPI.COMM_WORLD.bcast(offset)
57
58
 
58
- writeMPIFile(filename, dtype, offset, (Lt, Lx, Ly, Lz // 2, Nd, 2, Nc, Nc), (1, 2, 3, 0), gauge)
59
+ writeMPIFile(filename, dtype, offset, (Lt, Lx, Ly, Lz // 2, Nd, 2, Nc, Nc), (1, 2, 3, 0), grid_size, gauge)
@@ -3,55 +3,57 @@ from typing import List
3
3
 
4
4
  import numpy
5
5
 
6
- from pyquda import getSublatticeSize, readMPIFile, writeMPIFile
6
+ from .mpi_file import getSublatticeSize, readMPIFile, writeMPIFile
7
7
 
8
8
  Ns, Nc = 4, 3
9
9
 
10
10
 
11
- def readPropagator(filename: str, latt_size: List[int], staggered: bool):
11
+ def readPropagator(filename: str, latt_size: List[int], grid_size: List[int], staggered: bool):
12
12
  filename = path.expanduser(path.expandvars(filename))
13
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
13
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
14
14
  dtype, offset = "<c8", 0
15
15
 
16
16
  if not staggered:
17
- propagator = readMPIFile(filename, dtype, offset, (Ns, Nc, Lt, Lz, Ly, Lx, Ns, Nc), (5, 4, 3, 2))
17
+ propagator = readMPIFile(filename, dtype, offset, (Ns, Nc, Lt, Lz, Ly, Lx, Ns, Nc), (5, 4, 3, 2), grid_size)
18
18
  propagator = propagator.transpose(2, 3, 4, 5, 6, 0, 7, 1).astype("<c16")
19
19
  else:
20
20
  # QDP_ALIGN16 makes the last Nc to be aligned with 16 Bytes.
21
- propagator_align16 = readMPIFile(filename, dtype, offset, (Nc, Lt, Lz, Ly, Lx, 4), (4, 3, 2, 1))
21
+ propagator_align16 = readMPIFile(filename, dtype, offset, (Nc, Lt, Lz, Ly, Lx, 4), (4, 3, 2, 1), grid_size)
22
22
  propagator = propagator_align16[:, :, :, :, :, :Nc]
23
23
  propagator = propagator.transpose(1, 2, 3, 4, 5, 0).astype("<c16")
24
24
  return propagator
25
25
 
26
26
 
27
- def writePropagator(filename: str, latt_size: List[int], propagator: numpy.ndarray, staggered: bool):
27
+ def writePropagator(
28
+ filename: str, latt_size: List[int], grid_size: List[int], propagator: numpy.ndarray, staggered: bool
29
+ ):
28
30
  filename = path.expanduser(path.expandvars(filename))
29
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
31
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
30
32
  dtype, offset = "<c8", 0
31
33
 
32
34
  if not staggered:
33
35
  propagator = propagator.astype(dtype).transpose(5, 7, 0, 1, 2, 3, 4, 6).copy()
34
- writeMPIFile(filename, dtype, offset, (Ns, Nc, Lt, Lz, Ly, Lx, Ns, Nc), (5, 4, 3, 2), propagator)
36
+ writeMPIFile(filename, dtype, offset, (Ns, Nc, Lt, Lz, Ly, Lx, Ns, Nc), (5, 4, 3, 2), grid_size, propagator)
35
37
  else:
36
38
  # QDP_ALIGN16 makes the last Nc to be aligned with 16 Bytes.
37
39
  propagator = propagator.astype(dtype).transpose(5, 0, 1, 2, 3, 4)
38
40
  propagator_align16 = numpy.zeros((Nc, Lt, Lz, Ly, Lx, 4), dtype)
39
41
  propagator_align16[:, :, :, :, :, :Nc] = propagator
40
- writeMPIFile(filename, dtype, offset, (Nc, Lt, Lz, Ly, Lx, 4), (4, 3, 2, 1), propagator_align16)
42
+ writeMPIFile(filename, dtype, offset, (Nc, Lt, Lz, Ly, Lx, 4), (4, 3, 2, 1), grid_size, propagator_align16)
41
43
 
42
44
 
43
- def readPropagatorFast(filename: str, latt_size: List[int]):
45
+ def readPropagatorFast(filename: str, latt_size: List[int], grid_size: List[int]):
44
46
  filename = path.expanduser(path.expandvars(filename))
45
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
47
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
46
48
  dtype, offset = "<c8", 0
47
49
 
48
- propagator = readMPIFile(filename, dtype, offset, (Ns, Nc, Lt, Lz, Ly, Lx, Ns, Nc), (5, 4, 3, 2))
50
+ propagator = readMPIFile(filename, dtype, offset, (Ns, Nc, Lt, Lz, Ly, Lx, Ns, Nc), (5, 4, 3, 2), grid_size)
49
51
  return propagator
50
52
 
51
53
 
52
- def writePropagatorFast(filename: str, latt_size: List[int], propagator: numpy.ndarray):
54
+ def writePropagatorFast(filename: str, latt_size: List[int], grid_size: List[int], propagator: numpy.ndarray):
53
55
  filename = path.expanduser(path.expandvars(filename))
54
- Lx, Ly, Lz, Lt = getSublatticeSize(latt_size)
56
+ Lx, Ly, Lz, Lt = getSublatticeSize(latt_size, grid_size)
55
57
  dtype, offset = "<c8", 0
56
58
 
57
- writeMPIFile(filename, dtype, offset, (Ns, Nc, Lt, Lz, Ly, Lx, Ns, Nc), (5, 4, 3, 2), propagator)
59
+ writeMPIFile(filename, dtype, offset, (Ns, Nc, Lt, Lz, Ly, Lx, Ns, Nc), (5, 4, 3, 2), grid_size, propagator)
@@ -1 +0,0 @@
1
- __version__ = "0.9.9.dev5"