Skip to content

Commit

Permalink
Fix compatibility with Cython<3.
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltyChiang committed Nov 6, 2024
1 parent b513491 commit ec57c4d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pyquda_core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools", "wheel", "Cython>=3", "numpy"]
requires = ["setuptools", "wheel", "Cython", "numpy"]

[tool.setuptools.packages.find]
include = ["pyquda*"]
Expand Down
2 changes: 1 addition & 1 deletion pyquda_core/pyquda/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.9.3"
__version__ = "0.9.4"
16 changes: 11 additions & 5 deletions pyquda_core/pyquda/dirac/gauge.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
QudaGaugeSmearType,
QudaLinkType,
QudaMassNormalization,
QudaPrecision,
QudaReconstructType,
QudaSolveType,
)
Expand All @@ -53,13 +54,18 @@ def __init__(self, latt_info: Union[LatticeInfo, LaplaceLatticeInfo]) -> None:
self.newQudaInvertParam()
self.newQudaGaugeSmearParam()
self.newQudaGaugeObservableParam()
self.setPrecision()
self.setPrecision(
cuda=QudaPrecision.QUDA_DOUBLE_PRECISION,
sloppy=QudaPrecision.QUDA_DOUBLE_PRECISION,
precondition=QudaPrecision.QUDA_DOUBLE_PRECISION,
eigensolver=QudaPrecision.QUDA_DOUBLE_PRECISION,
)
# Use QUDA_RECONSTRUCT_NO to ensure slight deviations from SU(3) can be preserved
self.setReconstruct(
cuda=max(self.reconstruct.cuda, QudaReconstructType.QUDA_RECONSTRUCT_NO),
sloppy=max(self.reconstruct.sloppy, QudaReconstructType.QUDA_RECONSTRUCT_NO),
precondition=max(self.reconstruct.precondition, QudaReconstructType.QUDA_RECONSTRUCT_NO),
eigensolver=max(self.reconstruct.eigensolver, QudaReconstructType.QUDA_RECONSTRUCT_NO),
cuda=QudaReconstructType.QUDA_RECONSTRUCT_NO,
sloppy=QudaReconstructType.QUDA_RECONSTRUCT_NO,
precondition=QudaReconstructType.QUDA_RECONSTRUCT_NO,
eigensolver=QudaReconstructType.QUDA_RECONSTRUCT_NO,
)

def newQudaGaugeParam(self):
Expand Down
8 changes: 4 additions & 4 deletions pyquda_core/pyquda/dirac/hisq.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def __init__(
else:
self.setPrecision()
self.setReconstruct(
cuda=max(self.reconstruct.cuda, QudaReconstructType.QUDA_RECONSTRUCT_NO),
sloppy=max(self.reconstruct.sloppy, QudaReconstructType.QUDA_RECONSTRUCT_NO),
precondition=max(self.reconstruct.precondition, QudaReconstructType.QUDA_RECONSTRUCT_NO),
eigensolver=max(self.reconstruct.eigensolver, QudaReconstructType.QUDA_RECONSTRUCT_NO),
cuda=QudaReconstructType.QUDA_RECONSTRUCT_NO,
sloppy=QudaReconstructType.QUDA_RECONSTRUCT_NO,
precondition=QudaReconstructType.QUDA_RECONSTRUCT_NO,
eigensolver=QudaReconstructType.QUDA_RECONSTRUCT_NO,
)

def newPathCoeff(self):
Expand Down
8 changes: 4 additions & 4 deletions pyquda_core/pyquda/dirac/staggered.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def __init__(
else:
self.setPrecision()
self.setReconstruct(
cuda=max(self.reconstruct.cuda, QudaReconstructType.QUDA_RECONSTRUCT_NO),
sloppy=max(self.reconstruct.sloppy, QudaReconstructType.QUDA_RECONSTRUCT_NO),
precondition=max(self.reconstruct.precondition, QudaReconstructType.QUDA_RECONSTRUCT_NO),
eigensolver=max(self.reconstruct.eigensolver, QudaReconstructType.QUDA_RECONSTRUCT_NO),
cuda=QudaReconstructType.QUDA_RECONSTRUCT_NO,
sloppy=QudaReconstructType.QUDA_RECONSTRUCT_NO,
precondition=QudaReconstructType.QUDA_RECONSTRUCT_NO,
eigensolver=QudaReconstructType.QUDA_RECONSTRUCT_NO,
)

def newQudaGaugeParam(self, tadpole_coeff: float):
Expand Down
19 changes: 10 additions & 9 deletions pyquda_core/pyquda/src/pyquda.in.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ cdef class _NDArray:
cdef void **ptrs
cdef void ***ptrss

def __cinit__(self, ndarray data):
def __cinit__(self, data):
shape = data.shape
ndim = data.ndim
cdef size_t ptr_uint64
if ndim == 1:
Expand All @@ -50,18 +51,18 @@ cdef class _NDArray:
ptr_uint64 = data.ctypes.data
self.ptr = <void *>ptr_uint64
elif ndim == 2:
self.n0, self.n1 = data.shape[0], 0
self.ptrs = <void **>malloc(self.n0 * sizeof(void *))
for i in range(self.n0):
self.n0, self.n1 = shape[0], 0
self.ptrs = <void **>malloc(shape[0] * sizeof(void *))
for i in range(shape[0]):
assert data[i].flags["C_CONTIGUOUS"]
ptr_uint64 = data[i].ctypes.data
self.ptrs[i] = <void *>ptr_uint64
elif ndim == 3:
self.n0, self.n1 = data.shape[0], data.shape[1]
self.ptrss = <void ***>malloc(self.n0 * sizeof(void **))
for i in range(self.n0):
self.ptrss[i] = <void **>malloc(self.n1 * sizeof(void *))
for j in range(self.n1):
self.n0, self.n1 = shape[0], shape[1]
self.ptrss = <void ***>malloc(shape[0] * sizeof(void **))
for i in range(shape[0]):
self.ptrss[i] = <void **>malloc(shape[1] * sizeof(void *))
for j in range(shape[1]):
assert data[i, j].flags["C_CONTIGUOUS"]
ptr_uint64 = data[i, j].ctypes.data
self.ptrss[i][j] = <void *>ptr_uint64
Expand Down

0 comments on commit ec57c4d

Please sign in to comment.