Skip to content

Commit

Permalink
Update to Cython 3.0.0 (#258)
Browse files Browse the repository at this point in the history
This PR bumps the pinning and fixes the new warnings that appeared

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Ray Douglass (https://github.com/raydouglass)
  - Alexey Kamenev (https://github.com/Alexey-Kamenev)
  - Vukasin Milovanovic (https://github.com/vuule)
  - https://github.com/jakirkham

URL: #258
  • Loading branch information
vyasr authored Aug 14, 2023
1 parent 622a525 commit 55829bf
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- cudf==23.10.*
- cupy>=12.0.0
- cxx-compiler
- cython>=0.29,<0.30
- cython>=3.0.0
- dask>=2022.05.2
- distributed>=2022.05.2
- doxygen=1.8.20
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-120_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- cudf==23.10.*
- cupy>=12.0.0
- cxx-compiler
- cython>=0.29,<0.30
- cython>=3.0.0
- dask>=2022.05.2
- distributed>=2022.05.2
- doxygen=1.8.20
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/kvikio/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ requirements:
- python
- setuptools
- pip
- cython >=0.29,<0.30
- cython >=3.0.0
{% if cuda_major == "11" %}
- cudatoolkit
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ dependencies:
- output_types: [conda, requirements, pyproject]
packages:
- cmake>=3.26.4
- cython>=0.29,<0.30
- cython>=3.0.0
- ninja
- scikit-build>=0.13.1
- output_types: conda
Expand Down
2 changes: 1 addition & 1 deletion legate/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
build-backend = "setuptools.build_meta"
requires = [
"cmake>=3.26.4",
"cython>=0.29,<0.30",
"cython>=3.0.0",
"ninja",
"scikit-build>=0.13.1",
"setuptools",
Expand Down
11 changes: 6 additions & 5 deletions python/kvikio/_lib/libkvikio.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# cython: language_level=3

import pathlib
from typing import Optional

from libc.stdint cimport uintptr_t
from libcpp.utility cimport move, pair
Expand Down Expand Up @@ -49,7 +50,7 @@ def memory_deregister(buf) -> None:
kvikio_cxx_api.memory_deregister(<void*>arr.ptr)


def compat_mode() -> int:
def compat_mode() -> bool:
return kvikio_cxx_api.compat_mode()


Expand Down Expand Up @@ -124,7 +125,7 @@ cdef class CuFile:
def open_flags(self) -> int:
return self._handle.fd_open_flags()

def pread(self, buf, size: int, file_offset: int, task_size) -> IOFuture:
def pread(self, buf, size: Optional[int], file_offset: int, task_size) -> IOFuture:
cdef pair[uintptr_t, size_t] info = _parse_buffer(buf, size, True)
return _wrap_io_future(
self._handle.pread(
Expand All @@ -135,7 +136,7 @@ cdef class CuFile:
)
)

def pwrite(self, buf, size: int, file_offset: int, task_size) -> IOFuture:
def pwrite(self, buf, size: Optional[int], file_offset: int, task_size) -> IOFuture:
cdef pair[uintptr_t, size_t] info = _parse_buffer(buf, size, True)
return _wrap_io_future(
self._handle.pwrite(
Expand All @@ -146,7 +147,7 @@ cdef class CuFile:
)
)

def read(self, buf, size: int, file_offset: int, dev_offset: int) -> int:
def read(self, buf, size: Optional[int], file_offset: int, dev_offset: int) -> int:
cdef pair[uintptr_t, size_t] info = _parse_buffer(buf, size, False)
return self._handle.read(
<void*>info.first,
Expand All @@ -155,7 +156,7 @@ cdef class CuFile:
dev_offset,
)

def write(self, buf, size: int, file_offset: int, dev_offset: int) -> int:
def write(self, buf, size: Optional[int], file_offset: int, dev_offset: int) -> int:
cdef pair[uintptr_t, size_t] info = _parse_buffer(buf, size, False)
return self._handle.write(
<void*>info.first,
Expand Down
12 changes: 7 additions & 5 deletions python/kvikio/_lib/libnvcomp_ll.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
# See file LICENSE for terms.

from __future__ import annotations

from abc import ABC, abstractmethod
from enum import IntEnum

Expand Down Expand Up @@ -84,7 +86,7 @@ class nvCompBatchAlgorithm(ABC):
self,
size_t batch_size,
size_t max_uncompressed_chunk_bytes,
) -> (nvcompStatus_t, size_t):
) -> tuple[nvcompStatus_t, size_t]:
"""Algorithm-specific implementation."""
...

Expand Down Expand Up @@ -409,7 +411,7 @@ class nvCompBatchAlgorithmLZ4(nvCompBatchAlgorithm):
self,
size_t batch_size,
size_t max_uncompressed_chunk_bytes,
) -> (nvcompStatus_t, size_t):
) -> tuple[nvcompStatus_t, size_t]:
cdef size_t temp_bytes = 0

err = nvcompBatchedLZ4CompressGetTempSize(
Expand Down Expand Up @@ -671,7 +673,7 @@ class nvCompBatchAlgorithmGdeflate(nvCompBatchAlgorithm):
self,
size_t batch_size,
size_t max_uncompressed_chunk_bytes,
) -> (nvcompStatus_t, size_t):
) -> tuple[nvcompStatus_t, size_t]:
cdef size_t temp_bytes = 0

err = nvcompBatchedGdeflateCompressGetTempSize(
Expand Down Expand Up @@ -806,7 +808,7 @@ class nvCompBatchAlgorithmZstd(nvCompBatchAlgorithm):
self,
size_t batch_size,
size_t max_uncompressed_chunk_bytes,
) -> (nvcompStatus_t, size_t):
) -> tuple[nvcompStatus_t, size_t]:
cdef size_t temp_bytes = 0

err = nvcompBatchedZstdCompressGetTempSize(
Expand Down Expand Up @@ -941,7 +943,7 @@ class nvCompBatchAlgorithmSnappy(nvCompBatchAlgorithm):
self,
size_t batch_size,
size_t max_uncompressed_chunk_bytes,
) -> (nvcompStatus_t, size_t):
) -> tuple[nvcompStatus_t, size_t]:
cdef size_t temp_bytes = 0

err = nvcompBatchedSnappyCompressGetTempSize(
Expand Down
10 changes: 8 additions & 2 deletions python/kvikio/_lib/nvcomp_cxx_api.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,23 @@ cdef extern from "nvcomp/nvcompManager.hpp" namespace 'nvcomp':
size_t uncompressed_buffer_size) except +
nvcompStatus_t* get_status() const
CompressionConfig(CompressionConfig& other)
CompressionConfig& operator=(CompressionConfig&& other) except +
CompressionConfig& operator=(const CompressionConfig& other) except +
# Commented as Cython doesn't support rvalues, but a user can call
# `move` with the existing operator and generate correct C++ code
# xref: https://github.com/cython/cython/issues/1445
# CompressionConfig& operator=(CompressionConfig&& other) except +

cdef cppclass DecompressionConfig "nvcomp::DecompressionConfig":
size_t decomp_data_size
uint32_t num_chunks
DecompressionConfig(PinnedPtrPool[nvcompStatus_t]& pool) except +
nvcompStatus_t* get_status() const
DecompressionConfig(DecompressionConfig& other)
DecompressionConfig& operator=(DecompressionConfig&& other) except +
DecompressionConfig& operator=(const DecompressionConfig& other) except +
# Commented as Cython doesn't support rvalues, but a user can call
# `move` with the existing operator and generate correct C++ code
# xref: https://github.com/cython/cython/issues/1445
# DecompressionConfig& operator=(DecompressionConfig&& other) except +

cdef cppclass nvcompManagerBase "nvcomp::nvcompManagerBase":
CompressionConfig configure_compression(
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
build-backend = "setuptools.build_meta"
requires = [
"cmake>=3.26.4",
"cython>=0.29,<0.30",
"cython>=3.0.0",
"ninja",
"scikit-build>=0.13.1",
"setuptools",
Expand Down

0 comments on commit 55829bf

Please sign in to comment.